Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add mpi allgatherv pair ring
authorPaul Bédaride <paul.bedaride@gmail.com>
Fri, 12 Apr 2013 08:44:33 +0000 (10:44 +0200)
committerPaul Bédaride <paul.bedaride@gmail.com>
Fri, 12 Apr 2013 08:44:33 +0000 (10:44 +0200)
buildtools/Cmake/AddTests.cmake
buildtools/Cmake/DefinePackages.cmake
src/include/smpi/smpi_interface.h
src/simgrid/sg_config.c
src/smpi/colls/allgatherv-pair.c [new file with mode: 0644]
src/smpi/colls/allgatherv-ring.c [new file with mode: 0644]
src/smpi/colls/colls.h
src/smpi/smpi_coll.c
src/smpi/smpi_global.c
src/smpi/smpi_pmpi.c
teshsuite/smpi/CMakeLists.txt

index b48cb41..bf7b8fb 100644 (file)
@@ -374,6 +374,9 @@ if(NOT enable_memcheck)
                            smp_simple spreading_simple)
         ADD_TEST(smpi-allgather-coll-${ALLGATHER_COLL} ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg smpi/allgather:${ALLGATHER_COLL} --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/allgather_coll.tesh)
     ENDFOREACH()
+    FOREACH (ALLGATHERV_COLL default pair ring)
+        ADD_TEST(smpi-allgatherv-coll-${ALLGATHERV_COLL} ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg smpi/allgatherv:${ALLGATHERV_COLL} --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/allgatherv_coll.tesh)
+    ENDFOREACH()
     FOREACH (ALLREDUCE_COLL default lr NTS rab1 rab2 rab_rsag rdb smp_binomial smp_rdb smp_rsag
                            smp_rsag_lr smp_rsag_rab redbcast)
         ADD_TEST(smpi-allreduce-coll-${ALLREDUCE_COLL} ${CMAKE_BINARY_DIR}/bin/tesh ${TESH_OPTION} --cfg smpi/allreduce:${ALLREDUCE_COLL} --cd ${CMAKE_BINARY_DIR}/teshsuite/smpi ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/allreduce_coll.tesh)
index e06d8a3..b2f2b7a 100644 (file)
@@ -126,6 +126,8 @@ set(SMPI_SRC
   src/smpi/colls/allgather-SMP-NTS.c
   src/smpi/colls/allgather-smp-simple.c
   src/smpi/colls/allgather-spreading-simple.c
+  src/smpi/colls/allgatherv-pair.c
+  src/smpi/colls/allgatherv-ring.c
   src/smpi/colls/allreduce-lr.c
   src/smpi/colls/allreduce-NTS.c
   src/smpi/colls/allreduce-rab1.c
index 6c5852f..d172618 100644 (file)
@@ -30,6 +30,14 @@ XBT_PUBLIC_DATA(int (*mpi_coll_allgather_fun)
                 (void *, int, MPI_Datatype, void *, int, MPI_Datatype,
                  MPI_Comm));
 
+/** \ingroup MPI allgather
+ *  \brief The list of all available allgather collectives
+ */
+XBT_PUBLIC_DATA(s_mpi_coll_description_t) mpi_coll_allgatherv_description[];
+XBT_PUBLIC_DATA(int (*mpi_coll_allgatherv_fun)
+                (void *, int, MPI_Datatype, void *, int*, int*, MPI_Datatype,
+                 MPI_Comm));
+
 
 /** \ingroup MPI allreduce
  *  \brief The list of all available allgather collectives
index 80df369..63f1a02 100644 (file)
@@ -250,9 +250,12 @@ static void _sg_cfg_cb__coll(const char *category,
 static void _sg_cfg_cb__coll_allgather(const char *name, int pos){
   _sg_cfg_cb__coll("allgather", mpi_coll_allgather_description, name, pos);
 }
+static void _sg_cfg_cb__coll_allgatherv(const char *name, int pos){
+  _sg_cfg_cb__coll("allgatherv", mpi_coll_allgatherv_description, name, pos);
+}
 static void _sg_cfg_cb__coll_allreduce(const char *name, int pos)
 {
-  _sg_cfg_cb__coll("allreduce", mpi_coll_allreduce_description, name, pos);  
+  _sg_cfg_cb__coll("allreduce", mpi_coll_allreduce_description, name, pos);
 }
 static void _sg_cfg_cb__coll_alltoall(const char *name, int pos)
 {
@@ -763,6 +766,12 @@ void sg_config_init(int *argc, char **argv)
                     xbt_cfgelm_string, &default_value, 1, 1, &_sg_cfg_cb__coll_allgather,
                     NULL);
 
+    default_value = xbt_strdup("default");
+    xbt_cfg_register(&_sg_cfg_set, "smpi/allgatherv",
+                    "Which collective to use for allgatherv",
+                    xbt_cfgelm_string, &default_value, 1, 1, &_sg_cfg_cb__coll_allgatherv,
+                    NULL);
+
     default_value = xbt_strdup("default");
     xbt_cfg_register(&_sg_cfg_set, "smpi/allreduce",
                     "Which collective to use for allreduce",
diff --git a/src/smpi/colls/allgatherv-pair.c b/src/smpi/colls/allgatherv-pair.c
new file mode 100644 (file)
index 0000000..d60e77a
--- /dev/null
@@ -0,0 +1,92 @@
+#include "colls_private.h"
+
+/*****************************************************************************
+
+Copyright (c) 2006, Ahmad Faraj & Xin Yuan,
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+  * Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+
+  * Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+  * Neither the name of the Florida State University nor the names of its
+    contributors may be used to endorse or promote products derived from this
+    software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+  *************************************************************************
+  *     Any results obtained from executing this software require the     *
+  *     acknowledgment and citation of the software and its owners.       *
+  *     The full citation is given below:                                 *
+  *                                                                       *
+  *     A. Faraj and X. Yuan. "Automatic Generation and Tuning of MPI     *
+  *     Collective Communication Routines." The 19th ACM International    *
+  *     Conference on Supercomputing (ICS), Cambridge, Massachusetts,     *
+  *     June 20-22, 2005.                                                 *
+  *************************************************************************
+
+*****************************************************************************/
+
+/*****************************************************************************
+ * Function: allgather_pair
+ * return: int
+ *  inputs:
+ *   send_buff: send input buffer
+ *   send_count: number of elements to send
+ *   send_type: data type of elements being sent
+ *   recv_buff: receive output buffer
+ *   recv_count: number of elements to received
+ *   recv_type: data type of elements being received
+ *   comm: communication
+ * Descrp: Function works when P is power of two. In each phase of P - 1
+ *         phases, nodes in pair communicate their data.
+ * Auther: Ahmad Faraj
+ ****************************************************************************/
+int
+smpi_coll_tuned_allgatherv_pair(void *send_buff, int send_count,
+                               MPI_Datatype send_type, void *recv_buff,
+                               int *recv_counts, int *recv_disps, MPI_Datatype recv_type,
+                               MPI_Comm comm)
+{
+
+  MPI_Aint extent;
+  int i, src, dst, rank, num_procs;
+  int tag = 1;
+  MPI_Status status;
+
+  char *send_ptr = (char *) send_buff;
+  char *recv_ptr = (char *) recv_buff;
+
+  rank = smpi_comm_rank(comm);
+  num_procs = smpi_comm_size(comm);
+  extent = smpi_datatype_get_extent(send_type);
+
+  // local send/recv
+  smpi_mpi_sendrecv(send_ptr, send_count, send_type, rank, tag,
+               recv_ptr + recv_disps[rank] * extent,
+               recv_counts[rank], recv_type, rank, tag, comm, &status);
+  for (i = 1; i < num_procs; i++) {
+    src = dst = rank ^ i;
+    smpi_mpi_sendrecv(send_ptr, send_count, send_type, dst, tag,
+                 recv_ptr + recv_disps[src] * extent, recv_counts[src], recv_type,
+                 src, tag, comm, &status);
+  }
+
+  return MPI_SUCCESS;
+}
diff --git a/src/smpi/colls/allgatherv-ring.c b/src/smpi/colls/allgatherv-ring.c
new file mode 100644 (file)
index 0000000..4c1e14f
--- /dev/null
@@ -0,0 +1,94 @@
+#include "colls_private.h"
+
+/*****************************************************************************
+
+Copyright (c) 2006, Ahmad Faraj & Xin Yuan,
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+  * Redistributions of source code must retain the above copyright notice,
+    this list of conditions and the following disclaimer.
+
+  * Redistributions in binary form must reproduce the above copyright notice,
+    this list of conditions and the following disclaimer in the documentation
+    and/or other materials provided with the distribution.
+
+  * Neither the name of the Florida State University nor the names of its
+    contributors may be used to endorse or promote products derived from this
+    software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+  *************************************************************************
+  *     Any results obtained from executing this software require the     *
+  *     acknowledgment and citation of the software and its owners.       *
+  *     The full citation is given below:                                 *
+  *                                                                       *
+  *     A. Faraj and X. Yuan. "Automatic Generation and Tuning of MPI     *
+  *     Collective Communication Routines." The 19th ACM International    *
+  *     Conference on Supercomputing (ICS), Cambridge, Massachusetts,     *
+  *     June 20-22, 2005.                                                 *
+  *************************************************************************
+
+*****************************************************************************/
+
+/*****************************************************************************
+ * Function: allgather_ring
+ * return: int
+ * inputs:
+ *   send_buff: send input buffer
+ *   send_count: number of elements to send
+ *   send_type: data type of elements being sent
+ *   recv_buff: receive output buffer
+ *   recv_count: number of elements to received
+ *   recv_type: data type of elements being received
+ *   comm: communication
+ * Descrp: Function works in P - 1 steps. In step i, node j - i -> j -> j+ i.
+ * Auther: Ahmad Faraj
+ ****************************************************************************/
+int
+smpi_coll_tuned_allgatherv_ring(void *send_buff, int send_count,
+                               MPI_Datatype send_type, void *recv_buff,
+                               int *recv_counts, int *recv_disps, MPI_Datatype recv_type,
+                               MPI_Comm comm)
+{
+
+  MPI_Aint extent;
+  int i, src, dst, rank, num_procs;
+  int tag = 1;
+  MPI_Status status;
+
+  char *sendptr = (char *) send_buff;
+  char *recvptr = (char *) recv_buff;
+
+  rank = smpi_comm_rank(comm);
+  num_procs = smpi_comm_size(comm);
+  extent = smpi_datatype_get_extent(send_type);
+
+  // local send/recv
+  smpi_mpi_sendrecv(sendptr, send_count, send_type, rank, tag,
+               recvptr + recv_disps[rank] * extent,
+               recv_counts[rank], recv_type, rank, tag, comm, &status);
+
+  for (i = 1; i < num_procs; i++) {
+    src = (rank - i + num_procs) % num_procs;
+    dst = (rank + i) % num_procs;
+    
+    smpi_mpi_sendrecv(sendptr, send_count, send_type, dst, tag,
+                 recvptr + recv_disps[src] * extent, recv_counts[src], recv_type,
+                 src, tag, comm, &status);
+  }
+
+  return MPI_SUCCESS;
+}
index 97f51d1..d09c6d0 100644 (file)
@@ -48,6 +48,19 @@ COLL_APPLY(action, COLL_ALLGATHER_SIG, spreading_simple)
 
 COLL_ALLGATHERS(COLL_PROTO, COLL_NOsep)
 
+/**************
+ * ALLGATHERV *
+ **************/
+#define COLL_ALLGATHERV_SIG allgatherv, int, \
+                         (void *send_buff, int send_count, MPI_Datatype send_type, \
+                          void *recv_buff, int *recv_count, int *recv_disps, \
+                          MPI_Datatype recv_type, MPI_Comm comm)
+
+#define COLL_ALLGATHERVS(action, COLL_sep) \
+COLL_APPLY(action, COLL_ALLGATHERV_SIG, pair) COLL_sep \
+COLL_APPLY(action, COLL_ALLGATHERV_SIG, ring)
+
+COLL_ALLGATHERVS(COLL_PROTO, COLL_NOsep)
 
 /*************
  * ALLREDUCE *
index 08eaf9c..96ccc0d 100644 (file)
@@ -21,6 +21,14 @@ COLL_ALLGATHERS(COLL_DESCRIPTION, COLL_COMMA),
   {NULL, NULL, NULL}      /* this array must be NULL terminated */
 };
 
+s_mpi_coll_description_t mpi_coll_allgatherv_description[] = {
+  {"default",
+   "allgatherv default collective",
+   smpi_mpi_allgatherv},
+COLL_ALLGATHERVS(COLL_DESCRIPTION, COLL_COMMA),
+  {NULL, NULL, NULL}      /* this array must be NULL terminated */
+};
+
 s_mpi_coll_description_t mpi_coll_allreduce_description[] = {
   {"default",
    "allreduce default collective",
@@ -107,6 +115,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_coll, smpi,
                                 "Logging specific to SMPI (coll)");
 
 int (*mpi_coll_allgather_fun)(void *, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm);
+int (*mpi_coll_allgatherv_fun)(void *, int, MPI_Datatype, void*, int*, int*, MPI_Datatype, MPI_Comm);
 int (*mpi_coll_allreduce_fun)(void *sbuf, void *rbuf, int rcount, MPI_Datatype dtype, MPI_Op op, MPI_Comm comm);
 int (*mpi_coll_alltoall_fun)(void *, int, MPI_Datatype, void*, int, MPI_Datatype, MPI_Comm);
 int (*mpi_coll_alltoallv_fun)(void *, int*, int*, MPI_Datatype, void*, int*, int*, MPI_Datatype, MPI_Comm);
index 302c3ed..8854995 100644 (file)
@@ -366,6 +366,12 @@ int smpi_main(int (*realmain) (int argc, char *argv[]),int argc, char *argv[])
                                    void*, int, MPI_Datatype, MPI_Comm))
                           mpi_coll_allgather_description[allgather_id].coll;
 
+  int allgatherv_id = find_coll_description(mpi_coll_allgatherv_description,
+                                           sg_cfg_get_string("smpi/allgatherv"));
+  mpi_coll_allgatherv_fun = (int (*)(void *, int, MPI_Datatype,
+                                   void*, int*, int*, MPI_Datatype, MPI_Comm))
+                          mpi_coll_allgatherv_description[allgatherv_id].coll;
+
   int allreduce_id = find_coll_description(mpi_coll_allreduce_description,
                                            sg_cfg_get_string("smpi/allreduce"));
   mpi_coll_allreduce_fun = (int (*)(void *sbuf, void *rbuf, int rcount, \
index 378f42a..3d91b73 100644 (file)
@@ -1706,7 +1706,7 @@ int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype,
   } else if (recvcounts == NULL || displs == NULL) {
     retval = MPI_ERR_ARG;
   } else {
-    smpi_mpi_allgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
+    mpi_coll_allgatherv_fun(sendbuf, sendcount, sendtype, recvbuf, recvcounts,
                         displs, recvtype, comm);
     retval = MPI_SUCCESS;
   }
index 4c1f968..e74b5a5 100644 (file)
@@ -12,9 +12,10 @@ if(enable_smpi)
   include_directories("${CMAKE_HOME_DIRECTORY}/include/smpi")
 
   add_executable(allgather_coll allgather_coll.c)
+  add_executable(allgatherv_coll allgatherv_coll.c)
   add_executable(alltoall2 alltoall2.c)
   add_executable(alltoall_basic alltoall_basic.c)
-  add_executable(alltoall_coll alltoall_coll.c)        
+  add_executable(alltoall_coll alltoall_coll.c)
   add_executable(alltoallv_coll alltoallv_coll.c)
   add_executable(allreduce allreduce.c)
   add_executable(allreduce_coll allreduce_coll.c)  
@@ -35,10 +36,11 @@ if(enable_smpi)
   add_executable(indexed_test indexed_test.c)
   add_executable(struct_test struct_test.c)
 
-  target_link_libraries(allgather_coll simgrid)    
+  target_link_libraries(allgather_coll simgrid)
+  target_link_libraries(allgatherv_coll simgrid)
   target_link_libraries(alltoall2 simgrid)
   target_link_libraries(alltoall_basic simgrid)
-  target_link_libraries(alltoall_coll simgrid)    
+  target_link_libraries(alltoall_coll simgrid)
   target_link_libraries(alltoallv_coll simgrid)
   target_link_libraries(allreduce simgrid)
   target_link_libraries(allreduce_coll simgrid)      
@@ -72,8 +74,10 @@ endif()
 set(tesh_files
   ${tesh_files}
   ${CMAKE_CURRENT_SOURCE_DIR}/allgather_coll.tesh
+  ${CMAKE_CURRENT_SOURCE_DIR}/allgatherv_coll.tesh  
   ${CMAKE_CURRENT_SOURCE_DIR}/allreduce_coll.tesh
-  ${CMAKE_CURRENT_SOURCE_DIR}/alltoall_coll.tesh  
+  ${CMAKE_CURRENT_SOURCE_DIR}/alltoall_coll.tesh
+  ${CMAKE_CURRENT_SOURCE_DIR}/alltoallv_coll.tesh
   ${CMAKE_CURRENT_SOURCE_DIR}/bcast.tesh
   ${CMAKE_CURRENT_SOURCE_DIR}/bcast_coll.tesh  
   ${CMAKE_CURRENT_SOURCE_DIR}/compute.tesh
@@ -93,8 +97,10 @@ set(xml_files
 set(examples_src
   ${examples_src}
   ${CMAKE_CURRENT_SOURCE_DIR}/allgather_coll.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/allgatherv_coll.c  
   ${CMAKE_CURRENT_SOURCE_DIR}/allreduce_coll.c
   ${CMAKE_CURRENT_SOURCE_DIR}/alltoall_coll.c
+  ${CMAKE_CURRENT_SOURCE_DIR}/alltoallv_coll.c  
   ${CMAKE_CURRENT_SOURCE_DIR}/bcast_coll.c
   ${CMAKE_CURRENT_SOURCE_DIR}/reduce_coll.c
   ${CMAKE_CURRENT_SOURCE_DIR}/alltoallv_coll.c