Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Init : dont just crash with asserts, return errors (they will crash if errhandler...
[simgrid.git] / src / smpi / bindings / smpi_pmpi_coll.cpp
index ab4e193..95d8c7c 100644 (file)
@@ -120,7 +120,7 @@ int PMPI_Igather(const void* sendbuf, int sendcount, MPI_Datatype sendtype, void
       real_sendcount = 0;
       real_sendtype  = recvtype;
     } else if(recvtype->size() * recvcount !=  sendtype->size() * sendcount){
-      XBT_WARN("MPI_(I)Gather : received size at root differs from sent size %lu %lu", recvtype->size() * recvcount , sendtype->size() * sendcount);
+      XBT_WARN("MPI_(I)Gather : received size at root differs from sent size : %zu vs %zu", recvtype->size() * recvcount , sendtype->size() * sendcount);
       return MPI_ERR_TRUNCATE;
     }
   }
@@ -187,7 +187,7 @@ int PMPI_Igatherv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, voi
   int rank         = simgrid::s4u::this_actor::get_pid();
   int dt_size_recv = recvtype->is_replayable() ? 1 : recvtype->size();
 
-  auto* trace_recvcounts = new std::vector<int>();
+  auto trace_recvcounts = std::make_shared<std::vector<int>>();
   if (comm->rank() == root) {
     for (int i = 0; i < comm->size(); i++) // copy data to avoid bad free
       trace_recvcounts->push_back(recvcounts[i] * dt_size_recv);
@@ -237,7 +237,7 @@ int PMPI_Iallgather(const void* sendbuf, int sendcount, MPI_Datatype sendtype, v
   }
 
   if(recvtype->size() * recvcount !=  sendtype->size() * sendcount){
-    XBT_WARN("MPI_(I)Allgather : received size from each process differs from sent size");
+    XBT_WARN("MPI_(I)Allgather : received size from each process differs from sent size : %zu vs %zu", recvtype->size() * recvcount, sendtype->size() * sendcount);
     return MPI_ERR_TRUNCATE;
   }
 
@@ -293,7 +293,7 @@ int PMPI_Iallgatherv(const void* sendbuf, int sendcount, MPI_Datatype sendtype,
   int rank         = simgrid::s4u::this_actor::get_pid();
   int dt_size_recv = recvtype->is_replayable() ? 1 : recvtype->size();
 
-  auto* trace_recvcounts = new std::vector<int>();
+  auto trace_recvcounts = std::make_shared<std::vector<int>>();
   for (int i = 0; i < comm->size(); i++) { // copy data to avoid bad free
     trace_recvcounts->push_back(recvcounts[i] * dt_size_recv);
   }
@@ -402,7 +402,7 @@ int PMPI_Iscatterv(const void* sendbuf, const int* sendcounts, const int* displs
   int rank         = simgrid::s4u::this_actor::get_pid();
   int dt_size_send = sendtype->is_replayable() ? 1 : sendtype->size();
 
-  auto* trace_sendcounts = new std::vector<int>();
+  auto trace_sendcounts = std::make_shared<std::vector<int>>();
   if (comm->rank() == root) {
     for (int i = 0; i < comm->size(); i++) { // copy data to avoid bad free
       trace_sendcounts->push_back(sendcounts[i] * dt_size_send);
@@ -439,7 +439,7 @@ int PMPI_Ireduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype dat
     CHECK_BUFFER(5, recvbuf, count)
   CHECK_TYPE(4, datatype)
   CHECK_COUNT(3, count)
-  CHECK_OP(5)
+  CHECK_OP(5, op, datatype)
   CHECK_ROOT(7)
   CHECK_REQUEST(8)
 
@@ -466,7 +466,7 @@ int PMPI_Reduce_local(const void* inbuf, void* inoutbuf, int count, MPI_Datatype
   CHECK_BUFFER(2, inoutbuf, count)
   CHECK_TYPE(4, datatype)
   CHECK_COUNT(3, count)
-  CHECK_OP(5)
+  CHECK_OP(5, op, datatype)
 
   smpi_bench_end();
   op->apply(inbuf, inoutbuf, &count, datatype);
@@ -487,7 +487,7 @@ int PMPI_Iallreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype
   CHECK_TYPE(4, datatype)
   CHECK_COUNT(3, count)
   CHECK_REQUEST(7)
-  CHECK_OP(5)
+  CHECK_OP(5, op, datatype)
 
   smpi_bench_end();
   std::vector<unsigned char> tmp_sendbuf;
@@ -523,7 +523,7 @@ int PMPI_Iscan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datat
   CHECK_TYPE(4, datatype)
   CHECK_COUNT(3, count)
   CHECK_REQUEST(7)
-  CHECK_OP(5)
+  CHECK_OP(5, op, datatype)
 
   smpi_bench_end();
   int rank         = simgrid::s4u::this_actor::get_pid();
@@ -558,7 +558,7 @@ int PMPI_Iexscan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype dat
   CHECK_TYPE(4, datatype)
   CHECK_COUNT(3, count)
   CHECK_REQUEST(7)
-  CHECK_OP(5)
+  CHECK_OP(5, op, datatype)
 
   smpi_bench_end();
   int rank         = simgrid::s4u::this_actor::get_pid();
@@ -592,7 +592,7 @@ int PMPI_Ireduce_scatter(const void *sendbuf, void *recvbuf, const int *recvcoun
   CHECK_TYPE(4, datatype)
   CHECK_NULL(3, MPI_ERR_COUNT, recvcounts)
   CHECK_REQUEST(7)
-  CHECK_OP(5)
+  CHECK_OP(5, op, datatype)
   for (int i = 0; i < comm->size(); i++) {
     CHECK_COUNT(3, recvcounts[i])
     CHECK_BUFFER(1, sendbuf, recvcounts[i])
@@ -601,7 +601,7 @@ int PMPI_Ireduce_scatter(const void *sendbuf, void *recvbuf, const int *recvcoun
 
   smpi_bench_end();
   int rank                           = simgrid::s4u::this_actor::get_pid();
-  auto* trace_recvcounts             = new std::vector<int>();
+  auto trace_recvcounts              = std::make_shared<std::vector<int>>();
   int dt_send_size                   = datatype->is_replayable() ? 1 : datatype->size();
   int totalcount                     = 0;
 
@@ -642,14 +642,14 @@ int PMPI_Ireduce_scatter_block(const void* sendbuf, void* recvbuf, int recvcount
   CHECK_TYPE(4, datatype)
   CHECK_COUNT(3, recvcount)
   CHECK_REQUEST(7)
-  CHECK_OP(5)
+  CHECK_OP(5, op, datatype)
 
   smpi_bench_end();
   int count = comm->size();
 
   int rank                           = simgrid::s4u::this_actor::get_pid();
   int dt_send_size                   = datatype->is_replayable() ? 1 : datatype->size();
-  auto* trace_recvcounts             = new std::vector<int>(recvcount * dt_send_size); // copy data to avoid bad free
+  auto trace_recvcounts = std::make_shared<std::vector<int>>(recvcount * dt_send_size); // copy data to avoid bad free
   std::vector<unsigned char> tmp_sendbuf;
   const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, recvcount * count, datatype);
 
@@ -704,7 +704,7 @@ int PMPI_Ialltoall(const void* sendbuf, int sendcount, MPI_Datatype sendtype, vo
   }
 
   if(recvtype->size() * recvcount !=  real_sendtype->size() * real_sendcount){
-    XBT_WARN("MPI_(I)Alltoall : receive size from each process differs from sent size");
+    XBT_WARN("MPI_(I)Alltoall : receive size from each process differs from sent size : %zu vs %zu", recvtype->size() * recvcount,  real_sendtype->size() * real_sendcount);
     return MPI_ERR_TRUNCATE;
   }
 
@@ -763,8 +763,8 @@ int PMPI_Ialltoallv(const void* sendbuf, const int* sendcounts, const int* sendd
   smpi_bench_end();
   int send_size                      = 0;
   int recv_size                      = 0;
-  auto* trace_sendcounts             = new std::vector<int>();
-  auto* trace_recvcounts             = new std::vector<int>();
+  auto trace_sendcounts              = std::make_shared<std::vector<int>>();
+  auto trace_recvcounts              = std::make_shared<std::vector<int>>();
   int dt_size_recv                   = recvtype->size();
 
   const int* real_sendcounts = sendcounts;
@@ -791,7 +791,7 @@ int PMPI_Ialltoallv(const void* sendbuf, const int* sendcounts, const int* sendd
   }
 
   if(recvtype->size() * recvcounts[comm->rank()] !=  real_sendtype->size() * real_sendcounts[comm->rank()]){
-    XBT_WARN("MPI_(I)Alltoallv : receive size from me differs from sent size to me");
+    XBT_WARN("MPI_(I)Alltoallv : receive size from me differs from sent size to me : %zu vs %zu", recvtype->size() * recvcounts[comm->rank()], real_sendtype->size() * real_sendcounts[comm->rank()]);
     smpi_bench_begin();
     return MPI_ERR_TRUNCATE;
   }
@@ -858,19 +858,16 @@ int PMPI_Ialltoallw(const void* sendbuf, const int* sendcounts, const int* sendd
 
   int send_size                      = 0;
   int recv_size                      = 0;
-  auto* trace_sendcounts             = new std::vector<int>();
-  auto* trace_recvcounts             = new std::vector<int>();
+  auto trace_sendcounts              = std::make_shared<std::vector<int>>();
+  auto trace_recvcounts              = std::make_shared<std::vector<int>>();
 
   const int* real_sendcounts         = sendcounts;
   const int* real_senddispls          = senddispls;
   const MPI_Datatype* real_sendtypes = sendtypes;
   unsigned long maxsize      = 0;
   for (int i = 0; i < size; i++) { // copy data to avoid bad free
-    if (recvtypes[i] == MPI_DATATYPE_NULL) {
-      delete trace_recvcounts;
-      delete trace_sendcounts;
+    if (recvtypes[i] == MPI_DATATYPE_NULL)
       return MPI_ERR_TYPE;
-    }
     recv_size += recvcounts[i] * recvtypes[i]->size();
     trace_recvcounts->push_back(recvcounts[i] * recvtypes[i]->size());
     if ((recvdispls[i] + (recvcounts[i] * recvtypes[i]->size())) > maxsize)
@@ -893,7 +890,7 @@ int PMPI_Ialltoallw(const void* sendbuf, const int* sendcounts, const int* sendd
 
 
   if(recvtypes[comm->rank()]->size() * recvcounts[comm->rank()] !=  real_sendtypes[comm->rank()]->size() * real_sendcounts[comm->rank()]){
-    XBT_WARN("MPI_(I)Alltoallw : receive size from me differs from sent size to me");
+    XBT_WARN("MPI_(I)Alltoallw : receive size from me differs from sent size to me : %zu vs %zu", recvtypes[comm->rank()]->size() * recvcounts[comm->rank()],  real_sendtypes[comm->rank()]->size() * real_sendcounts[comm->rank()]);
     smpi_bench_begin();
     return MPI_ERR_TRUNCATE;
   }