Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use nullptr for recvbuf when myrank != 0.
[simgrid.git] / src / smpi / mpi / smpi_comm.cpp
index e1cf7e6..84b9e95 100644 (file)
@@ -242,9 +242,14 @@ MPI_Comm Comm::split(int color, int key)
   /* Gather all colors and keys on rank 0 */
   const std::array<int, 2> sendbuf = {{color, key}};
   std::vector<int> recvbuf;
-  if (myrank == 0)
+  int* recvbuf_ptr;
+  if (myrank == 0) {
     recvbuf.resize(2 * size);
-  gather__default(sendbuf.data(), 2, MPI_INT, recvbuf.data(), 2, MPI_INT, 0, this);
+    recvbuf_ptr = recvbuf.data();
+  } else {
+    recvbuf_ptr = nullptr;
+  }
+  gather__default(sendbuf.data(), 2, MPI_INT, recvbuf_ptr, 2, MPI_INT, 0, this);
   /* Do the actual job */
   if (myrank == 0) {
     std::vector<MPI_Group> group_snd(size);