Skip to content

Commit

Permalink
Convert MPI_Neighbor_alltoall* functions for Fortran
Browse files Browse the repository at this point in the history
Signed-off-by: Jake Tronge <[email protected]>
  • Loading branch information
jtronge committed Sep 19, 2024
1 parent d4fe783 commit 89ed3e5
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 232 deletions.
3 changes: 0 additions & 3 deletions ompi/mpi/fortran/use-mpi-f08/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,8 @@ mpi_api_files = \
mprobe_f08.F90 \
neighbor_allgather_init_f08.F90 \
neighbor_allgatherv_init_f08.F90 \
neighbor_alltoall_f08.F90 \
neighbor_alltoall_init_f08.F90 \
neighbor_alltoallv_f08.F90 \
neighbor_alltoallv_init_f08.F90 \
neighbor_alltoallw_f08.F90 \
neighbor_alltoallw_init_f08.F90 \
op_commutative_f08.F90 \
op_create_f08.F90 \
Expand Down
6 changes: 3 additions & 3 deletions ompi/mpi/fortran/use-mpi-f08/Makefile.prototype_files
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
# $(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/f_sync_reg_ts.c.in

incomplete_prototype_files = \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/neighbor_alltoall_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/neighbor_alltoallv_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/neighbor_alltoallw_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/put_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/raccumulate_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/recv_init_ts.c.in \
Expand Down Expand Up @@ -116,6 +113,9 @@ complete_prototype_files = \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/mrecv_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/neighbor_allgather_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/neighbor_allgatherv_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/neighbor_alltoall_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/neighbor_alltoallv_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/neighbor_alltoallw_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/recv_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/reduce_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/send_ts.c.in \
Expand Down
46 changes: 0 additions & 46 deletions ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-interfaces.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3207,21 +3207,6 @@ subroutine MPI_Neighbor_allgatherv_init_f08(sendbuf,sendcount,sendtype,recvbuf,r
end subroutine MPI_Neighbor_allgatherv_init_f08
end interface MPI_Neighbor_allgatherv_init

interface MPI_Neighbor_alltoall
subroutine MPI_Neighbor_alltoall_f08(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype, &
comm,ierror)
use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm
implicit none
@OMPI_FORTRAN_IGNORE_TKR_PREDECL@ sendbuf, recvbuf
@OMPI_FORTRAN_IGNORE_TKR_TYPE@, INTENT(IN) :: sendbuf
@OMPI_FORTRAN_IGNORE_TKR_TYPE@ :: recvbuf
INTEGER, INTENT(IN) :: sendcount, recvcount
TYPE(MPI_Datatype), INTENT(IN) :: sendtype, recvtype
TYPE(MPI_Comm), INTENT(IN) :: comm
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
end subroutine MPI_Neighbor_alltoall_f08
end interface MPI_Neighbor_alltoall

interface MPI_Neighbor_alltoall_init
subroutine MPI_Neighbor_alltoall_init_f08(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype, &
comm,info,request,ierror)
Expand All @@ -3239,21 +3224,6 @@ subroutine MPI_Neighbor_alltoall_init_f08(sendbuf,sendcount,sendtype,recvbuf,rec
end subroutine MPI_Neighbor_alltoall_init_f08
end interface MPI_Neighbor_alltoall_init

interface MPI_Neighbor_alltoallv
subroutine MPI_Neighbor_alltoallv_f08(sendbuf,sendcounts,sdispls,sendtype,recvbuf,recvcounts, &
rdispls,recvtype,comm,ierror)
use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm
implicit none
@OMPI_FORTRAN_IGNORE_TKR_PREDECL@ sendbuf, recvbuf
@OMPI_FORTRAN_IGNORE_TKR_TYPE@, INTENT(IN) :: sendbuf
@OMPI_FORTRAN_IGNORE_TKR_TYPE@ :: recvbuf
INTEGER, INTENT(IN) :: sendcounts(*), sdispls(*), recvcounts(*), rdispls(*)
TYPE(MPI_Datatype), INTENT(IN) :: sendtype, recvtype
TYPE(MPI_Comm), INTENT(IN) :: comm
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
end subroutine MPI_Neighbor_alltoallv_f08
end interface MPI_Neighbor_alltoallv

interface MPI_Neighbor_alltoallv_init
subroutine MPI_Neighbor_alltoallv_init_f08(sendbuf,sendcounts,sdispls,sendtype,recvbuf,recvcounts, &
rdispls,recvtype,comm,info,request,ierror)
Expand All @@ -3271,22 +3241,6 @@ subroutine MPI_Neighbor_alltoallv_init_f08(sendbuf,sendcounts,sdispls,sendtype,r
end subroutine MPI_Neighbor_alltoallv_init_f08
end interface MPI_Neighbor_alltoallv_init

interface MPI_Neighbor_alltoallw
subroutine MPI_Neighbor_alltoallw_f08(sendbuf,sendcounts,sdispls,sendtypes,recvbuf,recvcounts, &
rdispls,recvtypes,comm,ierror)
use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm, MPI_ADDRESS_KIND
implicit none
@OMPI_FORTRAN_IGNORE_TKR_PREDECL@ sendbuf, recvbuf
@OMPI_FORTRAN_IGNORE_TKR_TYPE@, INTENT(IN) :: sendbuf
@OMPI_FORTRAN_IGNORE_TKR_TYPE@ :: recvbuf
INTEGER, INTENT(IN) :: sendcounts(*), recvcounts(*)
INTEGER(MPI_ADDRESS_KIND), INTENT(IN) :: sdispls(*), rdispls(*)
TYPE(MPI_Datatype), INTENT(IN) :: sendtypes(*), recvtypes(*)
TYPE(MPI_Comm), INTENT(IN) :: comm
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
end subroutine MPI_Neighbor_alltoallw_f08
end interface MPI_Neighbor_alltoallw

interface MPI_Neighbor_alltoallw_init
subroutine MPI_Neighbor_alltoallw_init_f08(sendbuf,sendcounts,sdispls,sendtypes,recvbuf,recvcounts, &
rdispls,recvtypes,comm,info,request,ierror)
Expand Down
33 changes: 0 additions & 33 deletions ompi/mpi/fortran/use-mpi-f08/neighbor_alltoall_f08.F90

This file was deleted.

27 changes: 9 additions & 18 deletions ompi/mpi/fortran/use-mpi-f08/neighbor_alltoall_ts.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,9 @@
* $HEADER$
*/

#include "ompi_config.h"

#include "ompi/communicator/communicator.h"
#include "ompi/errhandler/errhandler.h"
#include "ompi/mpi/fortran/use-mpi-f08/ts/bindings.h"
#include "ompi/mpi/fortran/base/constants.h"

static const char FUNC_NAME[] = "MPI_Neighbor_alltoall";

void ompi_neighbor_alltoall_ts(CFI_cdesc_t *x1, MPI_Fint *sendcount, MPI_Fint *sendtype,
CFI_cdesc_t *x2, MPI_Fint *recvcount, MPI_Fint *recvtype,
MPI_Fint *comm, MPI_Fint *ierr)
PROTOTYPE VOID neighbor_alltoall(BUFFER x1, COUNT sendcount, DATATYPE sendtype,
BUFFER_OUT x2, COUNT recvcount, DATATYPE recvtype,
COMM comm)
{
int c_ierr;
MPI_Comm c_comm = PMPI_Comm_f2c(*comm);
Expand All @@ -60,11 +51,11 @@ void ompi_neighbor_alltoall_ts(CFI_cdesc_t *x1, MPI_Fint *sendcount, MPI_Fint *s
sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);

c_ierr = PMPI_Neighbor_alltoall(sendbuf,
OMPI_FINT_2_INT(*sendcount),
c_sendtype,
recvbuf,
OMPI_FINT_2_INT(*recvcount),
c_recvtype, c_comm);
c_ierr = @INNER_CALL@(sendbuf,
(@COUNT_TYPE@) *sendcount,
c_sendtype,
recvbuf,
(@COUNT_TYPE@) *recvcount,
c_recvtype, c_comm);
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
}
34 changes: 0 additions & 34 deletions ompi/mpi/fortran/use-mpi-f08/neighbor_alltoallv_f08.F90

This file was deleted.

57 changes: 24 additions & 33 deletions ompi/mpi/fortran/use-mpi-f08/neighbor_alltoallv_ts.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,19 @@
* $HEADER$
*/

#include "ompi_config.h"

#include "ompi/communicator/communicator.h"
#include "ompi/errhandler/errhandler.h"
#include "ompi/mpi/fortran/use-mpi-f08/ts/bindings.h"
#include "ompi/mpi/fortran/base/constants.h"

static const char FUNC_NAME[] = "MPI_Neighbor_alltoallv";

void ompi_neighbor_alltoallv_ts(CFI_cdesc_t *x1, MPI_Fint *sendcounts, MPI_Fint *sdispls,
MPI_Fint *sendtype, CFI_cdesc_t *x2, MPI_Fint *recvcounts,
MPI_Fint *rdispls, MPI_Fint *recvtype,
MPI_Fint *comm, MPI_Fint *ierr)
PROTOTYPE VOID neighbor_alltoallv(BUFFER x1, COUNT_ARRAY sendcounts, DISP_ARRAY sdispls,
DATATYPE sendtype, BUFFER_OUT x2, COUNT_ARRAY recvcounts,
DISP_ARRAY rdispls, DATATYPE recvtype,
COMM comm)
{
MPI_Comm c_comm = PMPI_Comm_f2c(*comm);
MPI_Datatype c_sendtype, c_recvtype;
int size, c_ierr;
char *sendbuf = OMPI_CFI_BASE_ADDR(x1), *recvbuf = OMPI_CFI_BASE_ADDR(x2);
OMPI_ARRAY_NAME_DECL(sendcounts);
OMPI_ARRAY_NAME_DECL(sdispls);
OMPI_ARRAY_NAME_DECL(recvcounts);
OMPI_ARRAY_NAME_DECL(rdispls);
@COUNT_TYPE@ *tmp_sendcounts = NULL;
@DISP_TYPE@ *tmp_sdispls = NULL;
@COUNT_TYPE@ *tmp_recvcounts = NULL;
@DISP_TYPE@ *tmp_rdispls = NULL;

OMPI_CFI_CHECK_CONTIGUOUS(x1, c_ierr);
if (MPI_SUCCESS != c_ierr) {
Expand All @@ -61,27 +52,27 @@ void ompi_neighbor_alltoallv_ts(CFI_cdesc_t *x1, MPI_Fint *sendcounts, MPI_Fint
c_recvtype = PMPI_Type_f2c(*recvtype);

PMPI_Comm_size(c_comm, &size);
OMPI_ARRAY_FINT_2_INT(sendcounts, size);
OMPI_ARRAY_FINT_2_INT(sdispls, size);
OMPI_ARRAY_FINT_2_INT(recvcounts, size);
OMPI_ARRAY_FINT_2_INT(rdispls, size);
OMPI_FORTRAN_BIGCOUNT_ARRAY_SET(sendcounts, tmp_sendcounts, size);
OMPI_FORTRAN_BIGCOUNT_ARRAY_SET(sdispls, tmp_sdispls, size);
OMPI_FORTRAN_BIGCOUNT_ARRAY_SET(recvcounts, tmp_recvcounts, size);
OMPI_FORTRAN_BIGCOUNT_ARRAY_SET(rdispls, tmp_rdispls, size);

sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf);
sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);

c_ierr = PMPI_Neighbor_alltoallv(sendbuf,
OMPI_ARRAY_NAME_CONVERT(sendcounts),
OMPI_ARRAY_NAME_CONVERT(sdispls),
c_sendtype,
recvbuf,
OMPI_ARRAY_NAME_CONVERT(recvcounts),
OMPI_ARRAY_NAME_CONVERT(rdispls),
c_recvtype, c_comm);
c_ierr = @INNER_CALL@(sendbuf,
tmp_sendcounts,
tmp_sdispls,
c_sendtype,
recvbuf,
tmp_recvcounts,
tmp_rdispls,
c_recvtype, c_comm);
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);

OMPI_ARRAY_FINT_2_INT_CLEANUP(sendcounts);
OMPI_ARRAY_FINT_2_INT_CLEANUP(sdispls);
OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts);
OMPI_ARRAY_FINT_2_INT_CLEANUP(rdispls);
OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(sendcounts, tmp_sendcounts);
OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(sdispls, tmp_sdispls);
OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(recvcounts, tmp_recvcounts);
OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(rdispls, tmp_rdispls);
}
34 changes: 0 additions & 34 deletions ompi/mpi/fortran/use-mpi-f08/neighbor_alltoallw_f08.F90

This file was deleted.

47 changes: 19 additions & 28 deletions ompi/mpi/fortran/use-mpi-f08/neighbor_alltoallw_ts.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,18 @@
* $HEADER$
*/

#include "ompi_config.h"

#include "ompi/communicator/communicator.h"
#include "ompi/errhandler/errhandler.h"
#include "ompi/mpi/fortran/use-mpi-f08/ts/bindings.h"
#include "ompi/mpi/fortran/base/constants.h"

static const char FUNC_NAME[] = "MPI_Neighbor_alltoallw";

void ompi_neighbor_alltoallw_ts(CFI_cdesc_t *x1, MPI_Fint *sendcounts,
MPI_Aint *sdispls, MPI_Fint *sendtypes,
CFI_cdesc_t *x2, MPI_Fint *recvcounts,
MPI_Aint *rdispls, MPI_Fint *recvtypes,
MPI_Fint *comm, MPI_Fint *ierr)
PROTOTYPE VOID neighbor_alltoallw(BUFFER x1, COUNT_ARRAY sendcounts,
AINT_ARRAY sdispls, DATATYPE_ARRAY sendtypes,
BUFFER_OUT x2, COUNT_ARRAY recvcounts,
AINT_ARRAY rdispls, DATATYPE_ARRAY recvtypes,
COMM comm)
{
MPI_Comm c_comm = PMPI_Comm_f2c(*comm);
MPI_Datatype *c_sendtypes, *c_recvtypes;
int size, c_ierr;
char *sendbuf = OMPI_CFI_BASE_ADDR(x1), *recvbuf = OMPI_CFI_BASE_ADDR(x2);
OMPI_ARRAY_NAME_DECL(sendcounts);
OMPI_ARRAY_NAME_DECL(recvcounts);
@COUNT_TYPE@ *tmp_sendcounts = NULL;
@COUNT_TYPE@ *tmp_recvcounts = NULL;

OMPI_CFI_CHECK_CONTIGUOUS(x1, c_ierr);
if (MPI_SUCCESS != c_ierr) {
Expand All @@ -61,8 +52,8 @@ void ompi_neighbor_alltoallw_ts(CFI_cdesc_t *x1, MPI_Fint *sendcounts,
c_sendtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype));
c_recvtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype));

OMPI_ARRAY_FINT_2_INT(sendcounts, size);
OMPI_ARRAY_FINT_2_INT(recvcounts, size);
OMPI_FORTRAN_BIGCOUNT_ARRAY_SET(sendcounts, tmp_sendcounts, size);
OMPI_FORTRAN_BIGCOUNT_ARRAY_SET(recvcounts, tmp_recvcounts, size);

while (size > 0) {
c_sendtypes[size - 1] = PMPI_Type_f2c(sendtypes[size - 1]);
Expand All @@ -74,18 +65,18 @@ void ompi_neighbor_alltoallw_ts(CFI_cdesc_t *x1, MPI_Fint *sendcounts,
sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);

c_ierr = PMPI_Neighbor_alltoallw(sendbuf,
OMPI_ARRAY_NAME_CONVERT(sendcounts),
sdispls,
c_sendtypes,
recvbuf,
OMPI_ARRAY_NAME_CONVERT(recvcounts),
rdispls,
c_recvtypes, c_comm);
c_ierr = @INNER_CALL@(sendbuf,
tmp_sendcounts,
sdispls,
c_sendtypes,
recvbuf,
tmp_recvcounts,
rdispls,
c_recvtypes, c_comm);
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);

OMPI_ARRAY_FINT_2_INT_CLEANUP(sendcounts);
OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts);
OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(sendcounts, tmp_sendcounts);
OMPI_FORTRAN_BIGCOUNT_ARRAY_CLEANUP(recvcounts, tmp_recvcounts);
free(c_sendtypes);
free(c_recvtypes);
}

0 comments on commit 89ed3e5

Please sign in to comment.