Skip to content

Commit f283554

Browse files
committed
fortran/use-mpi-f08: sendrecv/sendrecv_replace
Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
1 parent 1a1d560 commit f283554

File tree

11 files changed

+196
-27
lines changed

11 files changed

+196
-27
lines changed

ompi/mpi/fortran/use-mpi-f08/bindings/mpi-f-interfaces-bind.h.in

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,11 @@ end subroutine ompi_send_f
349349

350350
subroutine ompi_sendrecv_f(sendbuf,sendcount,sendtype,dest,sendtag,recvbuf, &
351351
recvcount,recvtype,source,recvtag,comm,status,ierror) &
352-
BIND(C, name="ompi_sendrecv_f")
352+
BIND(C, name="ompi_sendrecv_@OMPI_F08_BINDINGS_EXTENSION@")
353353
use :: mpi_f08_types, only : MPI_Status
354354
implicit none
355-
OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf
356-
OMPI_FORTRAN_IGNORE_TKR_TYPE :: recvbuf
355+
OMPI_F08_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf
356+
OMPI_F08_IGNORE_TKR_TYPE :: recvbuf
357357
INTEGER, INTENT(IN) :: sendcount, dest, sendtag, recvcount, source, recvtag
358358
INTEGER, INTENT(IN) :: sendtype
359359
INTEGER, INTENT(IN) :: recvtype
@@ -364,10 +364,10 @@ end subroutine ompi_sendrecv_f
364364

365365
subroutine ompi_sendrecv_replace_f(buf,count,datatype,dest,sendtag,source, &
366366
recvtag,comm,status,ierror) &
367-
BIND(C, name="ompi_sendrecv_replace_f")
367+
BIND(C, name="ompi_sendrecv_replace_@OMPI_F08_BINDINGS_EXTENSION@")
368368
use :: mpi_f08_types, only : MPI_Status
369369
implicit none
370-
OMPI_FORTRAN_IGNORE_TKR_TYPE :: buf
370+
OMPI_F08_IGNORE_TKR_TYPE :: buf
371371
INTEGER, INTENT(IN) :: count, dest, sendtag, source, recvtag
372372
INTEGER, INTENT(IN) :: datatype
373373
INTEGER, INTENT(IN) :: comm

ompi/mpi/fortran/use-mpi-f08/cdesc/Makefile.am

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ libforce_usempif08_internal_cdesc_to_be_built_la_SOURCES = \
4646
isend_cdesc.c \
4747
recv_cdesc.c \
4848
send_cdesc.c \
49-
send_init_cdesc.c
49+
send_init_cdesc.c \
50+
sendrecv_cdesc.c \
51+
sendrecv_replace_cdesc.c
5052

5153
endif

ompi/mpi/fortran/use-mpi-f08/cdesc/bindings.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,14 @@ void ompi_send_init_cdesc(CFI_cdesc_t *x, MPI_Fint *count, MPI_Fint *datatype,
3636
MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm,
3737
MPI_Fint *request, MPI_Fint *ierr);
3838

39+
void ompi_sendrecv_cdesc(CFI_cdesc_t* x1, MPI_Fint *sendcount, MPI_Fint *sendtype,
40+
MPI_Fint *dest, MPI_Fint *sendtag, CFI_cdesc_t* x2,
41+
MPI_Fint *recvcount, MPI_Fint *recvtype,
42+
MPI_Fint *source, MPI_Fint *recvtag, MPI_Fint *comm,
43+
MPI_Fint *status, MPI_Fint *ierr);
44+
45+
void ompi_sendrecv_replace_cdesc(CFI_cdesc_t* x, MPI_Fint *count, MPI_Fint *datatype,
46+
MPI_Fint *dest, MPI_Fint *sendtag,
47+
MPI_Fint *source, MPI_Fint *recvtag,
48+
MPI_Fint *comm, MPI_Fint *status, MPI_Fint *ierr);
3949
#endif /* OMPI_CDESC_BINDINGS_H */
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3+
* University Research and Technology
4+
* Corporation. All rights reserved.
5+
* Copyright (c) 2004-2005 The University of Tennessee and The University
6+
* of Tennessee Research Foundation. All rights
7+
* reserved.
8+
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9+
* University of Stuttgart. All rights reserved.
10+
* Copyright (c) 2004-2005 The Regents of the University of California.
11+
* All rights reserved.
12+
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
13+
* Copyright (c) 2015-2019 Research Organization for Information Science
14+
* and Technology (RIST). All rights reserved.
15+
* $COPYRIGHT$
16+
*
17+
* Additional copyrights may follow
18+
*
19+
* $HEADER$
20+
*/
21+
22+
#include "ompi_config.h"
23+
24+
#include "ompi/mpi/fortran/mpif-h/bindings.h"
25+
#include "ompi/mpi/fortran/use-mpi-f08/cdesc/bindings.h"
26+
#include "ompi/mpi/fortran/base/constants.h"
27+
28+
void ompi_sendrecv_cdesc(CFI_cdesc_t* x1, MPI_Fint *sendcount, MPI_Fint *sendtype,
29+
MPI_Fint *dest, MPI_Fint *sendtag, CFI_cdesc_t* x2,
30+
MPI_Fint *recvcount, MPI_Fint *recvtype,
31+
MPI_Fint *source, MPI_Fint *recvtag, MPI_Fint *comm,
32+
MPI_Fint *status, MPI_Fint *ierr)
33+
{
34+
int c_ierr;
35+
MPI_Comm c_comm;
36+
MPI_Datatype c_senddatatype, c_sendtype = PMPI_Type_f2c(*sendtype);
37+
MPI_Datatype c_recvdatatype, c_recvtype = PMPI_Type_f2c(*recvtype);
38+
MPI_Status c_status;
39+
void *sendbuf = x1->base_addr;
40+
int c_sendcount = OMPI_FINT_2_INT(*sendcount);
41+
void *recvbuf = x2->base_addr;
42+
int c_recvcount = OMPI_FINT_2_INT(*recvcount);
43+
44+
c_comm = PMPI_Comm_f2c (*comm);
45+
46+
c_senddatatype = c_sendtype;
47+
if (x1->rank != 0 && !CFI_is_contiguous(x1)) {
48+
c_ierr = cdesc_create_datatype(x1, c_sendcount, c_sendtype, &c_senddatatype);
49+
if (MPI_SUCCESS != c_ierr) {
50+
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
51+
return;
52+
}
53+
c_sendcount = 1;
54+
}
55+
c_recvdatatype = c_recvtype;
56+
if (x2->rank != 0 && !CFI_is_contiguous(x2)) {
57+
c_ierr = cdesc_create_datatype(x2, c_recvcount, c_recvtype, &c_recvdatatype);
58+
if (MPI_SUCCESS != c_ierr) {
59+
if (c_senddatatype != c_sendtype) {
60+
ompi_datatype_destroy(&c_senddatatype);
61+
}
62+
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
63+
return;
64+
}
65+
c_recvcount = 1;
66+
}
67+
c_ierr = PMPI_Sendrecv(OMPI_F2C_BOTTOM(sendbuf), c_sendcount,
68+
c_senddatatype,
69+
OMPI_FINT_2_INT(*dest),
70+
OMPI_FINT_2_INT(*sendtag),
71+
OMPI_F2C_BOTTOM(recvbuf), c_recvcount,
72+
c_recvdatatype, OMPI_FINT_2_INT(*source),
73+
OMPI_FINT_2_INT(*recvtag),
74+
c_comm, &c_status);
75+
if (c_senddatatype != c_sendtype) {
76+
ompi_datatype_destroy(&c_senddatatype);
77+
}
78+
if (c_recvdatatype != c_recvtype) {
79+
ompi_datatype_destroy(&c_recvdatatype);
80+
}
81+
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
82+
83+
if (MPI_SUCCESS == c_ierr &&
84+
!OMPI_IS_FORTRAN_STATUS_IGNORE(status)) {
85+
PMPI_Status_c2f(&c_status, status);
86+
}
87+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3+
* University Research and Technology
4+
* Corporation. All rights reserved.
5+
* Copyright (c) 2004-2005 The University of Tennessee and The University
6+
* of Tennessee Research Foundation. All rights
7+
* reserved.
8+
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9+
* University of Stuttgart. All rights reserved.
10+
* Copyright (c) 2004-2005 The Regents of the University of California.
11+
* All rights reserved.
12+
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
13+
* Copyright (c) 2015-2019 Research Organization for Information Science
14+
* and Technology (RIST). All rights reserved.
15+
* $COPYRIGHT$
16+
*
17+
* Additional copyrights may follow
18+
*
19+
* $HEADER$
20+
*/
21+
22+
#include "ompi_config.h"
23+
24+
#include "ompi/mpi/fortran/mpif-h/bindings.h"
25+
#include "ompi/mpi/fortran/use-mpi-f08/cdesc/bindings.h"
26+
#include "ompi/mpi/fortran/base/constants.h"
27+
28+
void ompi_sendrecv_replace_cdesc(CFI_cdesc_t* x, MPI_Fint *count, MPI_Fint *datatype,
29+
MPI_Fint *dest, MPI_Fint *sendtag,
30+
MPI_Fint *source, MPI_Fint *recvtag,
31+
MPI_Fint *comm, MPI_Fint *status, MPI_Fint *ierr)
32+
{
33+
int c_ierr;
34+
MPI_Datatype c_datatype, c_type = PMPI_Type_f2c(*datatype);
35+
MPI_Comm c_comm;
36+
MPI_Status c_status;
37+
void *buf = x->base_addr;
38+
int c_count = OMPI_FINT_2_INT(*count);
39+
40+
c_comm = PMPI_Comm_f2c (*comm);
41+
42+
c_datatype = c_type;
43+
if (x->rank != 0 && !CFI_is_contiguous(x)) {
44+
c_ierr = cdesc_create_datatype(x, c_count, c_type, &c_datatype);
45+
if (MPI_SUCCESS != c_ierr) {
46+
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
47+
return;
48+
}
49+
c_count = 1;
50+
}
51+
c_ierr = PMPI_Sendrecv_replace(OMPI_F2C_BOTTOM(buf),
52+
OMPI_FINT_2_INT(*count),
53+
c_type,
54+
OMPI_FINT_2_INT(*dest),
55+
OMPI_FINT_2_INT(*sendtag),
56+
OMPI_FINT_2_INT(*source),
57+
OMPI_FINT_2_INT(*recvtag),
58+
c_comm, &c_status);
59+
if (c_datatype != c_type) {
60+
ompi_datatype_destroy(&c_datatype);
61+
}
62+
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
63+
64+
if (MPI_SUCCESS == c_ierr &&
65+
!OMPI_IS_FORTRAN_STATUS_IGNORE(status)) {
66+
PMPI_Status_c2f(&c_status, status);
67+
}
68+
}

ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-interfaces.F90

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,13 @@ subroutine MPI_Sendrecv_f08(sendbuf,sendcount,sendtype,dest,sendtag,recvbuf, &
327327
use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm, MPI_Status
328328
implicit none
329329
!DEC$ ATTRIBUTES NO_ARG_CHECK :: sendbuf, recvbuf
330-
!GCC$ ATTRIBUTES NO_ARG_CHECK :: sendbuf, recvbuf
330+
OMPI_F08_GCC_ATTRIBUTES(sendbuf)
331+
OMPI_F08_GCC_ATTRIBUTES(recvbuf)
331332
!$PRAGMA IGNORE_TKR sendbuf, recvbuf
332333
!DIR$ IGNORE_TKR sendbuf, recvbuf
333334
!IBM* IGNORE_TKR sendbuf, recvbuf
334-
OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf
335-
OMPI_FORTRAN_IGNORE_TKR_TYPE :: recvbuf
335+
OMPI_F08_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf
336+
OMPI_F08_IGNORE_TKR_TYPE :: recvbuf
336337
INTEGER, INTENT(IN) :: sendcount, dest, sendtag, recvcount, source, recvtag
337338
TYPE(MPI_Datatype), INTENT(IN) :: sendtype, recvtype
338339
TYPE(MPI_Comm), INTENT(IN) :: comm
@@ -347,11 +348,11 @@ subroutine MPI_Sendrecv_replace_f08(buf,count,datatype,dest,sendtag,source,recvt
347348
use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm, MPI_Status
348349
implicit none
349350
!DEC$ ATTRIBUTES NO_ARG_CHECK :: buf
350-
!GCC$ ATTRIBUTES NO_ARG_CHECK :: buf
351+
OMPI_F08_GCC_ATTRIBUTES(buf)
351352
!$PRAGMA IGNORE_TKR buf
352353
!DIR$ IGNORE_TKR buf
353354
!IBM* IGNORE_TKR buf
354-
OMPI_FORTRAN_IGNORE_TKR_TYPE :: buf
355+
OMPI_F08_IGNORE_TKR_TYPE :: buf
355356
INTEGER, INTENT(IN) :: count, dest, sendtag, source, recvtag
356357
TYPE(MPI_Datatype), INTENT(IN) :: datatype
357358
TYPE(MPI_Comm), INTENT(IN) :: comm

ompi/mpi/fortran/use-mpi-f08/mod/pmpi-f08-interfaces.F90

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,13 @@ subroutine PMPI_Sendrecv_f08(sendbuf,sendcount,sendtype,dest,sendtag,recvbuf, &
327327
use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm, MPI_Status
328328
implicit none
329329
!DEC$ ATTRIBUTES NO_ARG_CHECK :: sendbuf, recvbuf
330-
!GCC$ ATTRIBUTES NO_ARG_CHECK :: sendbuf, recvbuf
330+
OMPI_F08_GCC_ATTRIBUTES(sendbuf)
331+
OMPI_F08_GCC_ATTRIBUTES(recvbuf)
331332
!$PRAGMA IGNORE_TKR sendbuf, recvbuf
332333
!DIR$ IGNORE_TKR sendbuf, recvbuf
333334
!IBM* IGNORE_TKR sendbuf, recvbuf
334-
OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf
335-
OMPI_FORTRAN_IGNORE_TKR_TYPE :: recvbuf
335+
OMPI_F08_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf
336+
OMPI_F08_IGNORE_TKR_TYPE :: recvbuf
336337
INTEGER, INTENT(IN) :: sendcount, dest, sendtag, recvcount, source, recvtag
337338
TYPE(MPI_Datatype), INTENT(IN) :: sendtype, recvtype
338339
TYPE(MPI_Comm), INTENT(IN) :: comm
@@ -347,11 +348,11 @@ subroutine PMPI_Sendrecv_replace_f08(buf,count,datatype,dest,sendtag,source,recv
347348
use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm, MPI_Status
348349
implicit none
349350
!DEC$ ATTRIBUTES NO_ARG_CHECK :: buf
350-
!GCC$ ATTRIBUTES NO_ARG_CHECK :: buf
351+
OMPI_F08_GCC_ATTRIBUTES(buf)
351352
!$PRAGMA IGNORE_TKR buf
352353
!DIR$ IGNORE_TKR buf
353354
!IBM* IGNORE_TKR buf
354-
OMPI_FORTRAN_IGNORE_TKR_TYPE :: buf
355+
OMPI_F08_IGNORE_TKR_TYPE :: buf
355356
INTEGER, INTENT(IN) :: count, dest, sendtag, source, recvtag
356357
TYPE(MPI_Datatype), INTENT(IN) :: datatype
357358
TYPE(MPI_Comm), INTENT(IN) :: comm

ompi/mpi/fortran/use-mpi-f08/profile/psendrecv_f08.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
! Copyright (c) 2009-2012 Cisco Systems, Inc. All rights reserved.
44
! Copyright (c) 2009-2012 Los Alamos National Security, LLC.
55
! All rights reserved.
6-
! Copyright (c) 2018 Research Organization for Information Science
6+
! Copyright (c) 2018-2019 Research Organization for Information Science
77
! and Technology (RIST). All rights reserved.
88
! Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
99
! $COPYRIGHT$
@@ -15,8 +15,8 @@ subroutine PMPI_Sendrecv_f08(sendbuf,sendcount,sendtype,dest,sendtag,recvbuf, &
1515
use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm, MPI_Status
1616
use :: ompi_mpifh_bindings, only : ompi_sendrecv_f
1717
implicit none
18-
OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf
19-
OMPI_FORTRAN_IGNORE_TKR_TYPE :: recvbuf
18+
OMPI_F08_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf
19+
OMPI_F08_IGNORE_TKR_TYPE :: recvbuf
2020
INTEGER, INTENT(IN) :: sendcount, dest, sendtag, recvcount, source, recvtag
2121
TYPE(MPI_Datatype), INTENT(IN) :: sendtype
2222
TYPE(MPI_Datatype), INTENT(IN) :: recvtype

ompi/mpi/fortran/use-mpi-f08/profile/psendrecv_replace_f08.F90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
! Copyright (c) 2009-2012 Cisco Systems, Inc. All rights reserved.
44
! Copyright (c) 2009-2012 Los Alamos National Security, LLC.
55
! All rights reserved.
6-
! Copyright (c) 2018 Research Organization for Information Science
6+
! Copyright (c) 2018-2019 Research Organization for Information Science
77
! and Technology (RIST). All rights reserved.
88
! Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
99
! $COPYRIGHT$
@@ -15,7 +15,7 @@ subroutine PMPI_Sendrecv_replace_f08(buf,count,datatype,dest,sendtag,source, &
1515
use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm, MPI_Status
1616
use :: ompi_mpifh_bindings, only : ompi_sendrecv_replace_f
1717
implicit none
18-
OMPI_FORTRAN_IGNORE_TKR_TYPE :: buf
18+
OMPI_F08_IGNORE_TKR_TYPE :: buf
1919
INTEGER, INTENT(IN) :: count, dest, sendtag, source, recvtag
2020
TYPE(MPI_Datatype), INTENT(IN) :: datatype
2121
TYPE(MPI_Comm), INTENT(IN) :: comm

ompi/mpi/fortran/use-mpi-f08/sendrecv_f08.F90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
! Copyright (c) 2009-2012 Cisco Systems, Inc. All rights reserved.
44
! Copyright (c) 2009-2012 Los Alamos National Security, LLC.
55
! All rights reserved.
6-
! Copyright (c) 2018 Research Organization for Information Science
6+
! Copyright (c) 2018-2019 Research Organization for Information Science
77
! and Technology (RIST). All rights reserved.
88
! Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
99
! $COPYRIGHT$
1010

1111
#include "ompi/mpi/fortran/configure-fortran-output.h"
1212

1313
subroutine MPI_Sendrecv_f08(sendbuf,sendcount,sendtype,dest,sendtag,recvbuf, &
14-
recvcount,recvtype,source,recvtag,comm,status,ierror)
14+
recvcount,recvtype,source,recvtag,comm,status,ierror)
1515
use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm, MPI_Status
1616
use :: ompi_mpifh_bindings, only : ompi_sendrecv_f
1717
implicit none
18-
OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf
19-
OMPI_FORTRAN_IGNORE_TKR_TYPE :: recvbuf
18+
OMPI_F08_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf
19+
OMPI_F08_IGNORE_TKR_TYPE :: recvbuf
2020
INTEGER, INTENT(IN) :: sendcount, dest, sendtag, recvcount, source, recvtag
2121
TYPE(MPI_Datatype), INTENT(IN) :: sendtype
2222
TYPE(MPI_Datatype), INTENT(IN) :: recvtype

0 commit comments

Comments
 (0)