Skip to content

Commit

Permalink
Convert MPI_Ineighbor_alltoall* functions for Fortran
Browse files Browse the repository at this point in the history
Signed-off-by: Jake Tronge <jtronge@lanl.gov>
  • Loading branch information
jtronge committed Sep 3, 2024
1 parent 5650c84 commit 2c05a74
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 238 deletions.
18 changes: 18 additions & 0 deletions ompi/mpi/bindings/ompi_bindings/fortran_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ def use(self):
def c_parameter(self):
return f'MPI_Aint *{self.name}'


@FortranType.add('AINT_OUT')
class AintOut(FortranType):
"""MPI_Aint out type."""
Expand All @@ -452,6 +453,7 @@ def use(self):
def c_parameter(self):
return f'MPI_Aint *{self.name}'


@FortranType.add('AINT_COUNT_INOUT')
class AintCountTypeInOut(FortranType):
"""AINT/COUNT type with INOUT INTENT"""
Expand All @@ -471,6 +473,7 @@ def c_parameter(self):
type_ = 'MPI_Count' if self.bigcount else 'MPI_Aint'
return f'{type_} *{self.name}'


@FortranType.add('AINT_COUNT_OUT')
class AintCountTypeOut(FortranType):
"""AINT/COUNT type with OUT INTENT"""
Expand All @@ -491,6 +494,21 @@ def c_parameter(self):
return f'{type_} *{self.name}'


@FortranType.add('AINT_ARRAY')
class AintArrayType(FortranType):
"""Array of MPI_Aint."""

def declare(self):
# TODO: Should there be a separate ASYNC version here, when the OMPI_ASYNCHRONOUS attr is required?
return f'INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(IN) OMPI_ASYNCHRONOUS :: {self.name}'

def use(self):
return [('mpi_f08_types', 'MPI_ADDRESS_KIND')]

def c_parameter(self):
return f'MPI_Aint *{self.name}'


@FortranType.add('DISP')
class Disp(FortranType):
"""Displacecment type."""
Expand Down
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 @@ -243,9 +243,6 @@ mpi_api_files = \
group_union_f08.F90 \
ibarrier_f08.F90 \
improbe_f08.F90 \
ineighbor_alltoall_f08.F90 \
ineighbor_alltoallv_f08.F90 \
ineighbor_alltoallw_f08.F90 \
info_create_f08.F90 \
info_create_env_f08.F90 \
info_delete_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/ineighbor_alltoall_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/ineighbor_alltoallv_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/ineighbor_alltoallw_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/ireduce_scatter_block_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/ireduce_scatter_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/ireduce_ts.c.in \
Expand Down Expand Up @@ -114,6 +111,9 @@ complete_prototype_files = \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/imrecv_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/ineighbor_allgather_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/ineighbor_allgatherv_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/ineighbor_alltoall_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/ineighbor_alltoallv_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/ineighbor_alltoallw_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/irecv_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/isend_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/recv_ts.c.in \
Expand Down
34 changes: 0 additions & 34 deletions ompi/mpi/fortran/use-mpi-f08/ineighbor_alltoall_f08.F90

This file was deleted.

27 changes: 9 additions & 18 deletions ompi/mpi/fortran/use-mpi-f08/ineighbor_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_Ineighbor_alltoall";

void ompi_ineighbor_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 *request, MPI_Fint *ierr)
PROTOTYPE VOID ineighbor_alltoall(BUFFER_ASYNC x1, COUNT sendcount, DATATYPE sendtype,
BUFFER_ASYNC_OUT x2, COUNT recvcount, DATATYPE recvtype,
COMM comm, REQUEST_OUT request)
{
int c_ierr;
MPI_Comm c_comm = PMPI_Comm_f2c(*comm);
Expand Down Expand Up @@ -61,12 +52,12 @@ void ompi_ineighbor_alltoall_ts(CFI_cdesc_t *x1, MPI_Fint *sendcount, MPI_Fint *
sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);

c_ierr = PMPI_Ineighbor_alltoall(sendbuf,
OMPI_FINT_2_INT(*sendcount),
c_sendtype,
recvbuf,
OMPI_FINT_2_INT(*recvcount),
c_recvtype, c_comm, &c_req);
c_ierr = @INNER_CALL@(sendbuf,
(@COUNT_TYPE@) *sendcount,
c_sendtype,
recvbuf,
(@COUNT_TYPE@) *recvcount,
c_recvtype, c_comm, &c_req);
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);

if (MPI_SUCCESS == c_ierr) *request = PMPI_Request_c2f(c_req);
Expand Down
35 changes: 0 additions & 35 deletions ompi/mpi/fortran/use-mpi-f08/ineighbor_alltoallv_f08.F90

This file was deleted.

57 changes: 24 additions & 33 deletions ompi/mpi/fortran/use-mpi-f08/ineighbor_alltoallv_ts.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,20 @@
* $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_Ineighbor_alltoallv";

void ompi_ineighbor_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 *request, MPI_Fint *ierr)
PROTOTYPE VOID ineighbor_alltoallv(BUFFER_ASYNC x1, COUNT_ARRAY sendcounts, DISP_ARRAY sdispls,
DATATYPE sendtype, BUFFER_ASYNC_OUT x2, COUNT_ARRAY recvcounts,
DISP_ARRAY rdispls, DATATYPE recvtype,
COMM comm, REQUEST_OUT request)
{
MPI_Comm c_comm = PMPI_Comm_f2c(*comm);
MPI_Datatype c_sendtype, c_recvtype;
MPI_Request c_request;
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 @@ -63,28 +54,28 @@ void ompi_ineighbor_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_Ineighbor_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_request);
c_ierr = @INNER_CALL@(sendbuf,
tmp_sendcounts,
tmp_sdispls,
c_sendtype,
recvbuf,
tmp_recvcounts,
tmp_rdispls,
c_recvtype, c_comm, &c_request);
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
if (MPI_SUCCESS == c_ierr) *request = PMPI_Request_c2f(c_request);

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);
}
35 changes: 0 additions & 35 deletions ompi/mpi/fortran/use-mpi-f08/ineighbor_alltoallw_f08.F90

This file was deleted.

47 changes: 19 additions & 28 deletions ompi/mpi/fortran/use-mpi-f08/ineighbor_alltoallw_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_Ineighbor_alltoallw";

void ompi_ineighbor_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 *request, MPI_Fint *ierr)
PROTOTYPE VOID ineighbor_alltoallw(BUFFER_ASYNC x1, COUNT_ARRAY sendcounts,
AINT_ARRAY sdispls, DATATYPE_ARRAY sendtypes,
BUFFER_ASYNC_OUT x2, COUNT_ARRAY recvcounts,
AINT_ARRAY rdispls, DATATYPE_ARRAY recvtypes,
COMM comm, REQUEST_OUT request)
{
MPI_Comm c_comm = PMPI_Comm_f2c(*comm);
MPI_Datatype *c_sendtypes, *c_recvtypes;
MPI_Request c_request;
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 @@ -62,8 +53,8 @@ void ompi_ineighbor_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 @@ -75,19 +66,19 @@ void ompi_ineighbor_alltoallw_ts(CFI_cdesc_t *x1, MPI_Fint *sendcounts,
sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);

c_ierr = PMPI_Ineighbor_alltoallw(sendbuf,
OMPI_ARRAY_NAME_CONVERT(sendcounts),
sdispls,
c_sendtypes,
recvbuf,
OMPI_ARRAY_NAME_CONVERT(recvcounts),
rdispls,
c_recvtypes, c_comm, &c_request);
c_ierr = @INNER_CALL@(sendbuf,
tmp_sendcounts,
sdispls,
c_sendtypes,
recvbuf,
tmp_recvcounts,
rdispls,
c_recvtypes, c_comm, &c_request);
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
if (MPI_SUCCESS == c_ierr) *request = PMPI_Request_c2f(c_request);

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);
}
Loading

0 comments on commit 2c05a74

Please sign in to comment.