Skip to content

Commit b71af0e

Browse files
committed
pcollreq/mpif-h: fix MPIX_Alltoallw_init() binding
Signed-off-by: Gilles Gouaillardet <[email protected]>
1 parent ed703be commit b71af0e

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

ompi/mpiext/pcollreq/mpif-h/alltoallw_init_f.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
13-
* Copyright (c) 2015-2018 Research Organization for Information Science
14-
* and Technology (RIST). All rights reserved.
13+
* Copyright (c) 2015-2019 Research Organization for Information Science
14+
* and Technology (RIST). All rights reserved.
1515
* $COPYRIGHT$
1616
*
1717
* Additional copyrights may follow
@@ -23,6 +23,7 @@
2323

2424
#include "ompi/mpi/fortran/mpif-h/bindings.h"
2525
#include "ompi/mpi/fortran/base/constants.h"
26+
#include "ompi/communicator/communicator.h"
2627
#include "ompi/mpiext/pcollreq/mpif-h/mpiext_pcollreq_prototypes.h"
2728

2829
#if OMPI_BUILD_MPI_PROFILING
@@ -85,22 +86,22 @@ void ompix_alltoallw_init_f(char *sendbuf, MPI_Fint *sendcounts,
8586
OMPI_ARRAY_NAME_DECL(rdispls);
8687

8788
c_comm = PMPI_Comm_f2c(*comm);
88-
PMPI_Comm_size(c_comm, &size);
89+
size = OMPI_COMM_IS_INTER(c_comm)?ompi_comm_remote_size(c_comm):ompi_comm_size(c_comm);
90+
91+
if (!OMPI_IS_FORTRAN_IN_PLACE(sendbuf)) {
92+
c_sendtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype));
93+
OMPI_ARRAY_FINT_2_INT(sendcounts, size);
94+
OMPI_ARRAY_FINT_2_INT(sdispls, size);
95+
for (int i=0; i<size; i++) {
96+
c_sendtypes[i] = PMPI_Type_f2c(sendtypes[i]);
97+
}
98+
}
8999

90-
c_sendtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype));
91100
c_recvtypes = (MPI_Datatype *) malloc(size * sizeof(MPI_Datatype));
92-
93-
c_info = PMPI_Info_f2c(*info);
94-
95-
OMPI_ARRAY_FINT_2_INT(sendcounts, size);
96-
OMPI_ARRAY_FINT_2_INT(sdispls, size);
97101
OMPI_ARRAY_FINT_2_INT(recvcounts, size);
98102
OMPI_ARRAY_FINT_2_INT(rdispls, size);
99-
100-
while (size > 0) {
101-
c_sendtypes[size - 1] = PMPI_Type_f2c(sendtypes[size - 1]);
102-
c_recvtypes[size - 1] = PMPI_Type_f2c(recvtypes[size - 1]);
103-
--size;
103+
for (int i=0; i<size; i++) {
104+
c_recvtypes[i] = PMPI_Type_f2c(recvtypes[i]);
104105
}
105106

106107
sendbuf = (char *) OMPI_F2C_IN_PLACE(sendbuf);
@@ -122,6 +123,8 @@ void ompix_alltoallw_init_f(char *sendbuf, MPI_Fint *sendcounts,
122123
OMPI_ARRAY_FINT_2_INT_CLEANUP(sdispls);
123124
OMPI_ARRAY_FINT_2_INT_CLEANUP(recvcounts);
124125
OMPI_ARRAY_FINT_2_INT_CLEANUP(rdispls);
125-
free(c_sendtypes);
126+
if (NULL != c_sendtypes) {
127+
free(c_sendtypes);
128+
}
126129
free(c_recvtypes);
127130
}

0 commit comments

Comments
 (0)