]> AND Public Git Repository - simgrid.git/blobdiff - src/smpi/bindings/smpi_f77_coll.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of github.com:simgrid/simgrid
[simgrid.git] / src / smpi / bindings / smpi_f77_coll.cpp
index 64f89ddcba1e5a2d289186f4514701b870f16448..0db71ca5ea3d9aaea1875702db79720beaebdfb0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -105,7 +105,6 @@ void mpi_alltoallv_(void* sendbuf, int* sendcounts, int* senddisps, int* sendtyp
 }
 
 void mpi_reduce_local_ (void *inbuf, void *inoutbuf, int* count, int* datatype, int* op, int* ierr){
-
  *ierr = MPI_Reduce_local(inbuf, inoutbuf, *count, simgrid::smpi::Datatype::f2c(*datatype), simgrid::smpi::Op::f2c(*op));
 }
 
@@ -120,13 +119,14 @@ void mpi_reduce_scatter_block_ (void *sendbuf, void *recvbuf, int* recvcount, in
 void mpi_alltoallw_ ( void *sendbuf, int *sendcnts, int *sdispls, int* old_sendtypes, void *recvbuf, int *recvcnts,
                       int *rdispls, int* old_recvtypes, int* comm, int* ierr){
   int size = simgrid::smpi::Comm::f2c(*comm)->size();
-  sendbuf = static_cast<char *>( FORT_IN_PLACE(sendbuf));
-  MPI_Datatype* sendtypes = new MPI_Datatype[size];
-  MPI_Datatype* recvtypes = new MPI_Datatype[size];
+  auto* sendtypes = new MPI_Datatype[size];
+  auto* recvtypes = new MPI_Datatype[size];
   for(int i=0; i< size; i++){
-    sendtypes[i] = simgrid::smpi::Datatype::f2c(old_sendtypes[i]);
+    if(FORT_IN_PLACE(sendbuf)!=MPI_IN_PLACE)
+      sendtypes[i] = simgrid::smpi::Datatype::f2c(old_sendtypes[i]);
     recvtypes[i] = simgrid::smpi::Datatype::f2c(old_recvtypes[i]);
   }
+  sendbuf = static_cast<char *>( FORT_IN_PLACE(sendbuf));
  *ierr = MPI_Alltoallw( sendbuf, sendcnts, sdispls, sendtypes, recvbuf, recvcnts, rdispls,
                         recvtypes, simgrid::smpi::Comm::f2c(*comm));
   delete[] sendtypes;
@@ -301,13 +301,14 @@ void mpi_ialltoallw_ ( void *sendbuf, int *sendcnts, int *sdispls, int* old_send
                       int *rdispls, int* old_recvtypes, int* comm, int* request, int* ierr){
   MPI_Request req;
   int size = simgrid::smpi::Comm::f2c(*comm)->size();
-  sendbuf = static_cast<char *>( FORT_IN_PLACE(sendbuf));
-  MPI_Datatype* sendtypes = new MPI_Datatype[size];
-  MPI_Datatype* recvtypes = new MPI_Datatype[size];
+  auto* sendtypes = new MPI_Datatype[size];
+  auto* recvtypes = new MPI_Datatype[size];
   for(int i=0; i< size; i++){
-    sendtypes[i] = simgrid::smpi::Datatype::f2c(old_sendtypes[i]);
+    if(FORT_IN_PLACE(sendbuf)!=MPI_IN_PLACE)
+      sendtypes[i] = simgrid::smpi::Datatype::f2c(old_sendtypes[i]);
     recvtypes[i] = simgrid::smpi::Datatype::f2c(old_recvtypes[i]);
   }
+  sendbuf = static_cast<char *>( FORT_IN_PLACE(sendbuf));
  *ierr = MPI_Ialltoallw( sendbuf, sendcnts, sdispls, sendtypes, recvbuf, recvcnts, rdispls,
                         recvtypes, simgrid::smpi::Comm::f2c(*comm), &req);
   if(*ierr == MPI_SUCCESS) {