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
@@ -74,7 +75,7 @@ void ompi_ialltoallw_f(char *sendbuf, MPI_Fint *sendcounts,
7475 MPI_Fint * comm , MPI_Fint * request , MPI_Fint * ierr )
7576{
7677 MPI_Comm c_comm ;
77- MPI_Datatype * c_sendtypes , * c_recvtypes ;
78+ MPI_Datatype * c_sendtypes = NULL , * c_recvtypes ;
7879 MPI_Request c_request ;
7980 int size , c_ierr ;
8081 OMPI_ARRAY_NAME_DECL (sendcounts );
@@ -83,20 +84,22 @@ 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 }
101104
102105 sendbuf = (char * ) OMPI_F2C_IN_PLACE (sendbuf );
@@ -118,6 +121,8 @@ void ompi_ialltoallw_f(char *sendbuf, MPI_Fint *sendcounts,
118121 OMPI_ARRAY_FINT_2_INT_CLEANUP (sdispls );
119122 OMPI_ARRAY_FINT_2_INT_CLEANUP (recvcounts );
120123 OMPI_ARRAY_FINT_2_INT_CLEANUP (rdispls );
121- free (c_sendtypes );
124+ if (NULL != c_sendtypes ) {
125+ free (c_sendtypes );
126+ }
122127 free (c_recvtypes );
123128}
0 commit comments