Skip to content

Commit

Permalink
Convert MPI_{Ibcast, Ibsend, Iexscan, Igather} 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 Aug 29, 2024
1 parent 45e42c8 commit a5de974
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 262 deletions.
4 changes: 0 additions & 4 deletions ompi/mpi/fortran/use-mpi-f08/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,6 @@ mpi_api_files = \
group_translate_ranks_f08.F90 \
group_union_f08.F90 \
ibarrier_f08.F90 \
ibcast_f08.F90 \
ibsend_f08.F90 \
iexscan_f08.F90 \
igather_f08.F90 \
igatherv_f08.F90 \
improbe_f08.F90 \
imrecv_f08.F90 \
Expand Down
8 changes: 4 additions & 4 deletions ompi/mpi/fortran/use-mpi-f08/Makefile.prototype_files
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +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/ibcast_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/ibsend_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/iexscan_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/igather_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/igatherv_ts.c.in \
$(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 \
Expand Down Expand Up @@ -118,6 +114,10 @@ complete_prototype_files = \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/ialltoall_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/ialltoallv_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/ialltoallw_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/ibcast_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/ibsend_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/iexscan_ts.c.in \
$(abs_top_srcdir)/ompi/mpi/fortran/use-mpi-f08/igather_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
30 changes: 0 additions & 30 deletions ompi/mpi/fortran/use-mpi-f08/ibcast_f08.F90

This file was deleted.

29 changes: 10 additions & 19 deletions ompi/mpi/fortran/use-mpi-f08/ibcast_ts.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,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_Ibcast";

void ompi_ibcast_ts(CFI_cdesc_t* x, MPI_Fint *count, MPI_Fint *datatype,
MPI_Fint *root, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *ierr)
PROTOTYPE VOID ibcast(BUFFER_ASYNC_OUT x, COUNT count, DATATYPE datatype,
RANK root, COMM comm, REQUEST_OUT request)
{
int c_ierr;
MPI_Comm c_comm = PMPI_Comm_f2c(*comm);
MPI_Datatype c_datatype = NULL, c_type = NULL;
int c_root = OMPI_FINT_2_INT(*root);
void *buffer = OMPI_CFI_BASE_ADDR(x);
int c_count = 0;
@COUNT_TYPE@ c_count = 0;
MPI_Request c_req;

if (OMPI_COMM_IS_INTRA(c_comm) || MPI_PROC_NULL != c_root) {
c_type = PMPI_Type_f2c(*datatype);
c_count = OMPI_FINT_2_INT(*count);
c_count = (@COUNT_TYPE@) *count;
OMPI_CFI_2_C(x, c_count, c_type, c_datatype, c_ierr);
if (MPI_SUCCESS != c_ierr) {
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
Expand All @@ -50,12 +41,12 @@ void ompi_ibcast_ts(CFI_cdesc_t* x, MPI_Fint *count, MPI_Fint *datatype,
}
}

c_ierr = PMPI_Ibcast(OMPI_F2C_BOTTOM(buffer),
c_count,
c_datatype,
c_root,
c_comm,
&c_req);
c_ierr = @INNER_CALL@(OMPI_F2C_BOTTOM(buffer),
c_count,
c_datatype,
c_root,
c_comm,
&c_req);

if (c_datatype != c_type) {
ompi_datatype_destroy(&c_datatype);
Expand Down
29 changes: 0 additions & 29 deletions ompi/mpi/fortran/use-mpi-f08/ibsend_f08.F90

This file was deleted.

25 changes: 8 additions & 17 deletions ompi/mpi/fortran/use-mpi-f08/ibsend_ts.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,17 @@
* $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_Ibsend";

void ompi_ibsend_ts(CFI_cdesc_t* x, MPI_Fint *count, MPI_Fint *datatype,
MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm,
MPI_Fint *request, MPI_Fint *ierr)
PROTOTYPE VOID ibsend(BUFFER_ASYNC x, COUNT count, DATATYPE datatype,
RANK dest, TAG tag, COMM comm,
REQUEST_OUT request)
{
int c_ierr;
MPI_Datatype c_datatype, c_type = PMPI_Type_f2c(*datatype);
MPI_Request c_req;
MPI_Comm c_comm = PMPI_Comm_f2c (*comm);

void *buf = OMPI_CFI_BASE_ADDR(x);
int c_count = OMPI_FINT_2_INT(*count);
@COUNT_TYPE@ c_count = (@COUNT_TYPE@) *count;

OMPI_CFI_2_C(x, c_count, c_type, c_datatype, c_ierr);
if (MPI_SUCCESS != c_ierr) {
Expand All @@ -47,10 +38,10 @@ void ompi_ibsend_ts(CFI_cdesc_t* x, MPI_Fint *count, MPI_Fint *datatype,
return;
}

c_ierr = PMPI_Ibsend(OMPI_F2C_BOTTOM(buf), c_count,
c_datatype, OMPI_FINT_2_INT(*dest),
OMPI_FINT_2_INT(*tag),
c_comm, &c_req);
c_ierr = @INNER_CALL@(OMPI_F2C_BOTTOM(buf), c_count,
c_datatype, OMPI_FINT_2_INT(*dest),
OMPI_FINT_2_INT(*tag),
c_comm, &c_req);
if (c_datatype != c_type) {
ompi_datatype_destroy(&c_datatype);
}
Expand Down
32 changes: 0 additions & 32 deletions ompi/mpi/fortran/use-mpi-f08/iexscan_f08.F90

This file was deleted.

21 changes: 6 additions & 15 deletions ompi/mpi/fortran/use-mpi-f08/iexscan_ts.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,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_Iexscan";

void ompi_iexscan_ts(CFI_cdesc_t *x1, CFI_cdesc_t *x2, MPI_Fint *count,
MPI_Fint *datatype, MPI_Fint *op, MPI_Fint *comm,
MPI_Fint *request, MPI_Fint *ierr)
PROTOTYPE VOID iexscan(BUFFER_ASYNC x1, BUFFER_ASYNC_OUT x2, COUNT count,
DATATYPE datatype, OP op, COMM comm,
REQUEST_OUT request)
{
int c_ierr;
MPI_Comm c_comm = PMPI_Comm_f2c(*comm);
Expand Down Expand Up @@ -58,9 +49,9 @@ void ompi_iexscan_ts(CFI_cdesc_t *x1, CFI_cdesc_t *x2, MPI_Fint *count,
sendbuf = (char *) OMPI_F2C_BOTTOM (sendbuf);
recvbuf = (char *) OMPI_F2C_BOTTOM (recvbuf);

c_ierr = PMPI_Iexscan(sendbuf, recvbuf,
OMPI_FINT_2_INT(*count),
c_type, c_op, c_comm, &c_request);
c_ierr = @INNER_CALL@(sendbuf, recvbuf,
OMPI_FINT_2_INT(*count),
c_type, c_op, 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);
}
33 changes: 0 additions & 33 deletions ompi/mpi/fortran/use-mpi-f08/igather_f08.F90

This file was deleted.

28 changes: 9 additions & 19 deletions ompi/mpi/fortran/use-mpi-f08/igather_ts.c.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,22 @@
* $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_Igather";

void ompi_igather_ts(CFI_cdesc_t *x1, MPI_Fint *sendcount, MPI_Fint *sendtype,
CFI_cdesc_t *x2, MPI_Fint *recvcount, MPI_Fint *recvtype,
MPI_Fint *root, MPI_Fint *comm, MPI_Fint *request,
MPI_Fint *ierr)
PROTOTYPE VOID igather(BUFFER_ASYNC x1, COUNT sendcount, DATATYPE sendtype,
BUFFER_ASYNC_OUT x2, COUNT recvcount, DATATYPE recvtype,
RANK root, COMM comm, REQUEST_OUT request)
{
int c_ierr;
MPI_Comm c_comm = PMPI_Comm_f2c(*comm);
int c_root = OMPI_FINT_2_INT(*root);
MPI_Datatype c_senddatatype = NULL, c_sendtype = NULL, c_recvtype = NULL;
int c_sendcount = 0, c_recvcount = 0;
@COUNT_TYPE@ c_sendcount = 0, c_recvcount = 0;
char *sendbuf = OMPI_CFI_BASE_ADDR(x1), *recvbuf = OMPI_CFI_BASE_ADDR(x2);
MPI_Request c_request;

if (OMPI_COMM_IS_INTER(c_comm)) {
if (MPI_ROOT == c_root) {
c_recvtype = PMPI_Type_f2c(*recvtype);
c_recvcount = OMPI_FINT_2_INT(*recvcount);
c_recvcount = (@COUNT_TYPE@) *recvcount;
OMPI_CFI_CHECK_CONTIGUOUS(x2, c_ierr);
if (MPI_SUCCESS != c_ierr) {
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
Expand All @@ -53,7 +43,7 @@ void ompi_igather_ts(CFI_cdesc_t *x1, MPI_Fint *sendcount, MPI_Fint *sendtype,
}
} else if (MPI_PROC_NULL != c_root) {
c_sendtype = PMPI_Type_f2c(*sendtype);
c_sendcount = OMPI_FINT_2_INT(*sendcount);
c_sendcount = (@COUNT_TYPE@) *sendcount;
OMPI_CFI_2_C(x1, c_sendcount, c_sendtype, c_senddatatype, c_ierr);
if (MPI_SUCCESS != c_ierr) {
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
Expand All @@ -64,7 +54,7 @@ void ompi_igather_ts(CFI_cdesc_t *x1, MPI_Fint *sendcount, MPI_Fint *sendtype,
} else {
if (ompi_comm_rank(c_comm) == c_root) {
c_recvtype = PMPI_Type_f2c(*recvtype);
c_recvcount = OMPI_FINT_2_INT(*recvcount);
c_recvcount = (@COUNT_TYPE@) *recvcount;
OMPI_CFI_CHECK_CONTIGUOUS(x2, c_ierr);
if (MPI_SUCCESS != c_ierr) {
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
Expand All @@ -76,7 +66,7 @@ void ompi_igather_ts(CFI_cdesc_t *x1, MPI_Fint *sendcount, MPI_Fint *sendtype,
sendbuf = MPI_IN_PLACE;
} else {
c_sendtype = PMPI_Type_f2c(*sendtype);
c_sendcount = OMPI_FINT_2_INT(*sendcount);
c_sendcount = (@COUNT_TYPE@) *sendcount;
OMPI_CFI_2_C(x1, c_sendcount, c_sendtype, c_senddatatype, c_ierr);
if (MPI_SUCCESS != c_ierr) {
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
Expand All @@ -89,7 +79,7 @@ void ompi_igather_ts(CFI_cdesc_t *x1, MPI_Fint *sendcount, MPI_Fint *sendtype,
sendbuf = (char *) OMPI_F2C_BOTTOM(sendbuf);
recvbuf = (char *) OMPI_F2C_BOTTOM(recvbuf);

c_ierr = PMPI_Igather(sendbuf, c_sendcount,
c_ierr = @INNER_CALL@(sendbuf, c_sendcount,
c_senddatatype, recvbuf,
c_recvcount,
c_recvtype,
Expand Down
Loading

0 comments on commit a5de974

Please sign in to comment.