|
| 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 | +} |
0 commit comments