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 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
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
2728#if OMPI_BUILD_MPI_PROFILING
2829#if OPAL_HAVE_WEAK_SYMBOLS
@@ -83,21 +84,24 @@ void ompi_ialltoallw_f(char *sendbuf, MPI_Fint *sendcounts,
8384 OMPI_ARRAY_NAME_DECL (rdispls );
8485
8586 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 );
8788
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+ }
9097
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 ));
9399 OMPI_ARRAY_FINT_2_INT (recvcounts , size );
94100 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 ]);
100103 }
104+ c_recvtypes = (MPI_Datatype * ) malloc (size * sizeof (MPI_Datatype ));
101105
102106 sendbuf = (char * ) OMPI_F2C_IN_PLACE (sendbuf );
103107 sendbuf = (char * ) OMPI_F2C_BOTTOM (sendbuf );
@@ -118,6 +122,8 @@ void ompi_ialltoallw_f(char *sendbuf, MPI_Fint *sendcounts,
118122 OMPI_ARRAY_FINT_2_INT_CLEANUP (sdispls );
119123 OMPI_ARRAY_FINT_2_INT_CLEANUP (recvcounts );
120124 OMPI_ARRAY_FINT_2_INT_CLEANUP (rdispls );
121- free (c_sendtypes );
125+ if (MPI_IN_PLACE != sendbuf ) {
126+ free (c_sendtypes );
127+ }
122128 free (c_recvtypes );
123129}
0 commit comments