Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
reduce_scatter default implementation was a mess
authorAugustin Degomme <degomme@idpann.imag.fr>
Mon, 17 Jun 2013 16:13:53 +0000 (18:13 +0200)
committerAugustin Degomme <degomme@idpann.imag.fr>
Tue, 18 Jun 2013 12:06:12 +0000 (14:06 +0200)
src/smpi/smpi_base.c

index 067cd82..8664524 100644 (file)
@@ -948,6 +948,8 @@ void smpi_mpi_reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
     int i, size, count;
     int *displs;
     int rank = smpi_process_index();
     int i, size, count;
     int *displs;
     int rank = smpi_process_index();
+    void *tmpbuf;
+
     /* arbitrarily choose root as rank 0 */
     size = smpi_comm_size(comm);
     count = 0;
     /* arbitrarily choose root as rank 0 */
     size = smpi_comm_size(comm);
     count = 0;
@@ -956,10 +958,12 @@ void smpi_mpi_reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts,
       displs[i] = count;
       count += recvcounts[i];
     }
       displs[i] = count;
       count += recvcounts[i];
     }
-    mpi_coll_reduce_fun(sendbuf, recvbuf, count, datatype, op, 0, comm);
-    smpi_mpi_scatterv(recvbuf, recvcounts, displs, datatype, recvbuf,
+    tmpbuf=(void*)xbt_malloc(count*smpi_datatype_get_extent(datatype));
+    mpi_coll_reduce_fun(sendbuf, tmpbuf, count, datatype, op, 0, comm);
+    smpi_mpi_scatterv(tmpbuf, recvcounts, displs, datatype, recvbuf,
                       recvcounts[rank], datatype, 0, comm);
     xbt_free(displs);
                       recvcounts[rank], datatype, 0, comm);
     xbt_free(displs);
+    xbt_free(tmpbuf);
 }
 
 void smpi_mpi_gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
 }
 
 void smpi_mpi_gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,