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-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.
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
#include "ompi/mpiext/pcollreq/mpif-h/mpiext_pcollreq_prototypes.h"
27
28
28
29
#if OMPI_BUILD_MPI_PROFILING
@@ -85,22 +86,22 @@ void ompix_alltoallw_init_f(char *sendbuf, MPI_Fint *sendcounts,
85
86
OMPI_ARRAY_NAME_DECL (rdispls );
86
87
87
88
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
+ }
89
99
90
- c_sendtypes = (MPI_Datatype * ) malloc (size * sizeof (MPI_Datatype ));
91
100
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 );
97
101
OMPI_ARRAY_FINT_2_INT (recvcounts , size );
98
102
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 ]);
104
105
}
105
106
106
107
sendbuf = (char * ) OMPI_F2C_IN_PLACE (sendbuf );
@@ -122,6 +123,8 @@ void ompix_alltoallw_init_f(char *sendbuf, MPI_Fint *sendcounts,
122
123
OMPI_ARRAY_FINT_2_INT_CLEANUP (sdispls );
123
124
OMPI_ARRAY_FINT_2_INT_CLEANUP (recvcounts );
124
125
OMPI_ARRAY_FINT_2_INT_CLEANUP (rdispls );
125
- free (c_sendtypes );
126
+ if (NULL != c_sendtypes ) {
127
+ free (c_sendtypes );
128
+ }
126
129
free (c_recvtypes );
127
130
}
0 commit comments