Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add mpi alltoallv pairwise
authorPaul Bédaride <paul.bedaride@gmail.com>
Wed, 10 Apr 2013 15:03:54 +0000 (17:03 +0200)
committerPaul Bédaride <paul.bedaride@gmail.com>
Wed, 10 Apr 2013 15:03:54 +0000 (17:03 +0200)
buildtools/Cmake/AddTests.cmake
buildtools/Cmake/DefinePackages.cmake
src/smpi/colls/alltoallv-pairwise.c [new file with mode: 0644]
src/smpi/colls/colls.h
src/smpi/smpi_coll.c

index 7e05a67..59ef4d7 100644 (file)
@@ -383,7 +383,7 @@ if(NOT enable_memcheck)
                           simple bruck basic_linear pairwise)
         ADD_TEST(smpi-alltoall-coll-${ALLTOALL_COLL} ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg smpi/alltoall:${ALLTOALL_COLL} --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/alltoall_coll.tesh)
     ENDFOREACH()
-    FOREACH (ALLTOALLV_COLL default)
+    FOREACH (ALLTOALLV_COLL default pairwise)
         ADD_TEST(smpi-alltoallv-coll-${ALLTOALLV_COLL} ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg smpi/alltoallv:${ALLTOALLV_COLL} --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/alltoallv_coll.tesh)
     ENDFOREACH()
     FOREACH (BCAST_COLL default arrival_nb arrival_pattern_aware arrival_pattern_aware_wait arrival_scatter
index 8f3f30d..a387bc9 100644 (file)
@@ -154,6 +154,7 @@ set(SMPI_SRC
   src/smpi/colls/alltoall-ring-mpi-barrier.c
   src/smpi/colls/alltoall-ring-one-barrier.c
   src/smpi/colls/alltoall-simple.c
+  src/smpi/colls/alltoallv-pairwise.c  
   src/smpi/colls/bcast-arrival-nb.c
   src/smpi/colls/bcast-arrival-pattern-aware.c
   src/smpi/colls/bcast-arrival-pattern-aware-wait.c
diff --git a/src/smpi/colls/alltoallv-pairwise.c b/src/smpi/colls/alltoallv-pairwise.c
new file mode 100644 (file)
index 0000000..30e339d
--- /dev/null
@@ -0,0 +1,30 @@
+#include "colls_private.h"
+
+int smpi_coll_tuned_alltoallv_pairwise(void *sendbuf, int *sendcounts, int *senddisps,
+                                      MPI_Datatype sendtype, void *recvbuf,
+                                      int *recvcounts, int *recvdisps, MPI_Datatype recvtype,
+                                      MPI_Comm comm)
+{
+  int system_tag = 999;
+  int rank, size, step, sendto, recvfrom, sendsize, recvsize;
+
+  rank = smpi_comm_rank(comm);
+  size = smpi_comm_size(comm);
+  XBT_DEBUG("<%d> algorithm alltoallv_pairwise() called.", rank);
+  sendsize = smpi_datatype_size(sendtype);
+  recvsize = smpi_datatype_size(recvtype);
+  /* Perform pairwise exchange - starting from 1 so the local copy is last */
+  for (step = 1; step < size + 1; step++) {
+    /* who do we talk to in this step? */
+    sendto = (rank + step) % size;
+    recvfrom = (rank + size - step) % size;
+    /* send and receive */
+    smpi_mpi_sendrecv(&((char *) sendbuf)[senddisps[sendto] * sendsize * sendcounts[sendto]],
+                      sendcounts[sendto], sendtype, sendto, system_tag,
+                      &((char *) recvbuf)[recvdisps[recvfrom] * recvsize * recvcounts[recvfrom]],
+                      recvcounts[recvfrom], recvtype, recvfrom, system_tag, comm,
+                      MPI_STATUS_IGNORE);
+  }
+  return MPI_SUCCESS;
+}
+
index 35ce15c..5294eda 100644 (file)
@@ -101,6 +101,18 @@ COLL_APPLY(action, COLL_ALLTOALL_SIG, simple)
 
 COLL_ALLTOALLS(COLL_PROTO, COLL_NOsep)
 
+/*************
+ * ALLTOALLV *
+ *************/
+#define COLL_ALLTOALLV_SIG alltoallv, int, \
+                        (void *send_buff, int *send_counts, int *send_disps, MPI_Datatype send_type, \
+                         void *recv_buff, int *recv_counts, int *recv_disps, MPI_Datatype recv_type, \
+                          MPI_Comm com)
+
+#define COLL_ALLTOALLVS(action, COLL_sep) \
+COLL_APPLY(action, COLL_ALLTOALLV_SIG, pairwise)
+
+COLL_ALLTOALLVS(COLL_PROTO, COLL_NOsep)
 
 /*********
  * BCAST *
index 8f0115c..7c4c30e 100644 (file)
@@ -50,7 +50,7 @@ s_mpi_coll_description_t mpi_coll_alltoallv_description[] = {
   {"default",
    "Ompi alltoallv default collective",
    smpi_coll_basic_alltoallv},
-
+COLL_ALLTOALLVS(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };