Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'xbt_random' into 'master'
[simgrid.git] / src / smpi / colls / smpi_coll.cpp
index 56830ad..fdc25ee 100644 (file)
 #include "smpi_request.hpp"
 #include "xbt/config.hpp"
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_coll, smpi, "Logging specific to SMPI (coll)");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_coll, smpi, "Logging specific to SMPI collectives.");
 
 #define COLL_SETTER(cat, ret, args, args2)                                                                             \
   int(*Colls::cat) args;                                                                                               \
-  void Colls::set_##cat(const std::string& name)                                                                       \
+  void Colls::_XBT_CONCAT(set_, cat)(const std::string& name)                                                          \
   {                                                                                                                    \
-    int id = find_coll_description(mpi_coll_##cat##_description, name, #cat);                                          \
-    cat    = reinterpret_cast<ret(*) args>(mpi_coll_##cat##_description[id].coll);                                     \
+    int id = find_coll_description(_XBT_CONCAT3(mpi_coll_, cat, _description), name, _XBT_STRINGIFY(cat));             \
+    cat    = reinterpret_cast<ret(*) args>(_XBT_CONCAT3(mpi_coll_, cat, _description)[id].coll);                       \
     if (cat == nullptr)                                                                                                \
-      xbt_die("Collective " #cat " set to nullptr!");                                                                  \
+      xbt_die("Collective " _XBT_STRINGIFY(cat) " set to nullptr!");                                                   \
   }
 
 namespace simgrid{
@@ -81,7 +81,20 @@ int Colls::find_coll_description(s_mpi_coll_description_t* table, const std::str
   return -1;
 }
 
-COLL_APPLY(COLL_SETTER,COLL_GATHER_SIG,"");
+int(*Colls::gather) (const void *send_buff, int send_count, MPI_Datatype send_type,
+                     void *recv_buff, int recv_count, MPI_Datatype recv_type,
+                         int root, MPI_Comm comm);
+void Colls::set_gather(const std::string& name)
+{
+  int id = find_coll_description(mpi_coll_gather_description, name, "gather");
+  gather = reinterpret_cast<int(*)(const void *send_buff, int send_count, MPI_Datatype send_type,
+                                    void *recv_buff, int recv_count, MPI_Datatype recv_type,
+                                        int root, MPI_Comm comm)>(mpi_coll_gather_description[id].coll);
+  if (gather == nullptr)
+    xbt_die("Collective gather set to nullptr!");
+}
+
+//COLL_APPLY(COLL_SETTER,COLL_GATHER_SIG,"");
 COLL_APPLY(COLL_SETTER,COLL_ALLGATHER_SIG,"");
 COLL_APPLY(COLL_SETTER,COLL_ALLGATHERV_SIG,"");
 COLL_APPLY(COLL_SETTER,COLL_REDUCE_SIG,"");
@@ -121,7 +134,7 @@ int Colls::gatherv(const void *sendbuf, int sendcount, MPI_Datatype sendtype, vo
                       MPI_Datatype recvtype, int root, MPI_Comm comm)
 {
   MPI_Request request;
-  Colls::igatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, root, comm, &request);
+  Colls::igatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, root, comm, &request, 0);
   return Request::wait(&request, MPI_STATUS_IGNORE);
 }
 
@@ -130,7 +143,7 @@ int Colls::scatterv(const void *sendbuf, const int *sendcounts, const int *displ
                        MPI_Datatype recvtype, int root, MPI_Comm comm)
 {
   MPI_Request request;
-  Colls::iscatterv(sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype, root, comm, &request);
+  Colls::iscatterv(sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype, root, comm, &request, 0);
   return Request::wait(&request, MPI_STATUS_IGNORE);
 }
 
@@ -267,7 +280,7 @@ int Colls::alltoallw(const void *sendbuf, const int *sendcounts, const int *send
                               void *recvbuf, const int *recvcounts, const int *recvdisps, const MPI_Datatype* recvtypes, MPI_Comm comm)
 {
   MPI_Request request;
-  Colls::ialltoallw(sendbuf, sendcounts, senddisps, sendtypes, recvbuf, recvcounts, recvdisps, recvtypes, comm, &request);  
+  Colls::ialltoallw(sendbuf, sendcounts, senddisps, sendtypes, recvbuf, recvcounts, recvdisps, recvtypes, comm, &request, 0);
   return Request::wait(&request, MPI_STATUS_IGNORE);
 }