10
10
* Copyright (c) 2004-2005 The Regents of the University of California.
11
11
* All rights reserved.
12
12
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
13
- * Copyright (c) 2015 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.
15
15
* $COPYRIGHT$
16
16
*
17
17
* Additional copyrights may follow
23
23
24
24
#include "ompi/mpi/fortran/mpif-h/bindings.h"
25
25
#include "ompi/mpi/fortran/base/constants.h"
26
+ #include "ompi/communicator/communicator.h"
26
27
27
28
#if OMPI_BUILD_MPI_PROFILING
28
29
#if OPAL_HAVE_WEAK_SYMBOLS
@@ -83,21 +84,24 @@ void ompi_ialltoallw_f(char *sendbuf, MPI_Fint *sendcounts,
83
84
OMPI_ARRAY_NAME_DECL (rdispls );
84
85
85
86
c_comm = PMPI_Comm_f2c (* comm );
86
- PMPI_Comm_size (c_comm , & size );
87
+ size = OMPI_COMM_IS_INTER (c_comm )? ompi_comm_remote_size ( c_comm ): ompi_comm_size ( c_comm );
87
88
88
- c_sendtypes = (MPI_Datatype * ) malloc (size * sizeof (MPI_Datatype ));
89
- c_recvtypes = (MPI_Datatype * ) malloc (size * sizeof (MPI_Datatype ));
89
+ if (!OMPI_IS_FORTRAN_IN_PLACE (sendbuf )) {
90
+ c_sendtypes = (MPI_Datatype * ) malloc (size * sizeof (MPI_Datatype ));
91
+ OMPI_ARRAY_FINT_2_INT (sendcounts , size );
92
+ OMPI_ARRAY_FINT_2_INT (sdispls , size );
93
+ for (int i = 0 ; i < size ; i ++ ) {
94
+ c_sendtypes [i ] = PMPI_Type_f2c (sendtypes [i ]);
95
+ }
96
+ }
90
97
91
- OMPI_ARRAY_FINT_2_INT (sendcounts , size );
92
- OMPI_ARRAY_FINT_2_INT (sdispls , size );
98
+ c_recvtypes = (MPI_Datatype * ) malloc (size * sizeof (MPI_Datatype ));
93
99
OMPI_ARRAY_FINT_2_INT (recvcounts , size );
94
100
OMPI_ARRAY_FINT_2_INT (rdispls , size );
95
-
96
- while (size > 0 ) {
97
- c_sendtypes [size - 1 ] = PMPI_Type_f2c (sendtypes [size - 1 ]);
98
- c_recvtypes [size - 1 ] = PMPI_Type_f2c (recvtypes [size - 1 ]);
99
- -- size ;
101
+ for (int i = 0 ; i < size ; i ++ ) {
102
+ c_recvtypes [i ] = PMPI_Type_f2c (recvtypes [i ]);
100
103
}
104
+ c_recvtypes = (MPI_Datatype * ) malloc (size * sizeof (MPI_Datatype ));
101
105
102
106
sendbuf = (char * ) OMPI_F2C_IN_PLACE (sendbuf );
103
107
sendbuf = (char * ) OMPI_F2C_BOTTOM (sendbuf );
@@ -118,6 +122,8 @@ void ompi_ialltoallw_f(char *sendbuf, MPI_Fint *sendcounts,
118
122
OMPI_ARRAY_FINT_2_INT_CLEANUP (sdispls );
119
123
OMPI_ARRAY_FINT_2_INT_CLEANUP (recvcounts );
120
124
OMPI_ARRAY_FINT_2_INT_CLEANUP (rdispls );
121
- free (c_sendtypes );
125
+ if (MPI_IN_PLACE != sendbuf ) {
126
+ free (c_sendtypes );
127
+ }
122
128
free (c_recvtypes );
123
129
}
0 commit comments