Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
multiple fixes for replay
authorAugustin Degomme <adegomme@users.noreply.github.com>
Sat, 7 Aug 2021 17:28:23 +0000 (19:28 +0200)
committerAugustin Degomme <adegomme@users.noreply.github.com>
Sat, 7 Aug 2021 17:28:23 +0000 (19:28 +0200)
in case of MPI_IN_PLACE or non relevant parameters, we could output nonsense to the ti trace

src/instr/instr_private.hpp
src/smpi/bindings/smpi_pmpi_coll.cpp
src/smpi/internals/smpi_replay.cpp

index 59a9e6e..f860972 100644 (file)
@@ -154,16 +154,16 @@ public:
 // VarCollTI: gatherv, scatterv, allgatherv, alltoallv (+ reducescatter out of laziness)
 class VarCollTIData : public TIData {
   int root_;
-  size_t send_size_;
+  long int send_size_;
   std::shared_ptr<std::vector<int>> sendcounts_;
-  size_t recv_size_;
+  long int recv_size_;
   std::shared_ptr<std::vector<int>> recvcounts_;
   std::string send_type_;
   std::string recv_type_;
 
 public:
-  VarCollTIData(const std::string& name, int root, size_t send_size, std::shared_ptr<std::vector<int>> sendcounts,
-                size_t recv_size, std::shared_ptr<std::vector<int>> recvcounts, const std::string& send_type,
+  VarCollTIData(const std::string& name, int root, long int send_size, std::shared_ptr<std::vector<int>> sendcounts,
+                long int recv_size, std::shared_ptr<std::vector<int>> recvcounts, const std::string& send_type,
                 const std::string& recv_type)
       : TIData(name)
       , root_(root)
@@ -178,12 +178,12 @@ public:
   {
     std::stringstream stream;
     stream << get_name() << " ";
-    if (send_size_ > 0)
+    if (send_size_ > -1)
       stream << send_size_ << " ";
     if (sendcounts_ != nullptr)
       for (auto count : *sendcounts_)
         stream << count << " ";
-    if (recv_size_ > 0)
+    if (recv_size_ > -1)
       stream << recv_size_ << " ";
     if (recvcounts_ != nullptr)
       for (auto count : *recvcounts_)
index 6c990d4..ad484c2 100644 (file)
@@ -198,12 +198,14 @@ int PMPI_Igatherv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, voi
   auto trace_recvcounts = std::make_shared<std::vector<int>>();
   if (rank == root)
     trace_recvcounts->insert(trace_recvcounts->end(), &recvcounts[0], &recvcounts[comm->size()]);
+  else //this is not significant outside of root, put 0 as we don't know if recvcounts is initialized
+    trace_recvcounts->insert(trace_recvcounts->end(), comm->size(), 0);
 
   TRACE_smpi_comm_in(pid, request == MPI_REQUEST_IGNORED ? "PMPI_Gatherv" : "PMPI_Igatherv",
                      new simgrid::instr::VarCollTIData(
                          request == MPI_REQUEST_IGNORED ? "gatherv" : "igatherv", root,
-                         real_sendcount,
-                         nullptr, recvtype->size(), trace_recvcounts, simgrid::smpi::Datatype::encode(real_sendtype),
+                         sendcount,
+                         nullptr, -1, trace_recvcounts, simgrid::smpi::Datatype::encode(real_sendtype),
                          simgrid::smpi::Datatype::encode(recvtype)));
   if (request == MPI_REQUEST_IGNORED)
     simgrid::smpi::colls::gatherv(real_sendbuf, real_sendcount, real_sendtype, recvbuf, recvcounts, displs, recvtype,
@@ -311,7 +313,7 @@ int PMPI_Iallgatherv(const void* sendbuf, int sendcount, MPI_Datatype sendtype,
       pid, request == MPI_REQUEST_IGNORED ? "PMPI_Allgatherv" : "PMPI_Iallgatherv",
       new simgrid::instr::VarCollTIData(request == MPI_REQUEST_IGNORED ? "allgatherv" : "iallgatherv", -1,
                                         sendcount, nullptr,
-                                        recvtype->size(), trace_recvcounts, simgrid::smpi::Datatype::encode(sendtype),
+                                        -1, trace_recvcounts, simgrid::smpi::Datatype::encode(sendtype),
                                         simgrid::smpi::Datatype::encode(recvtype)));
   if (request == MPI_REQUEST_IGNORED)
     simgrid::smpi::colls::allgatherv(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, comm);
@@ -422,10 +424,13 @@ int PMPI_Iscatterv(const void* sendbuf, const int* sendcounts, const int* displs
   auto trace_sendcounts = std::make_shared<std::vector<int>>();
   if (rank == root)
     trace_sendcounts->insert(trace_sendcounts->end(), &sendcounts[0], &sendcounts[comm->size()]);
+  else //this is not significant outside of root, put 0 as we don't know if sendcounts is initialized
+    trace_sendcounts->insert(trace_sendcounts->end(), comm->size(), 0);
+
 
   TRACE_smpi_comm_in(pid, request == MPI_REQUEST_IGNORED ? "PMPI_Scatterv" : "PMPI_Iscatterv",
                      new simgrid::instr::VarCollTIData(
-                         request == MPI_REQUEST_IGNORED ? "scatterv" : "iscatterv", root, sendtype->size(),
+                         request == MPI_REQUEST_IGNORED ? "scatterv" : "iscatterv", root, -1,
                          trace_sendcounts, recvcount,
                          nullptr, simgrid::smpi::Datatype::encode(sendtype),
                          simgrid::smpi::Datatype::encode(recvtype)));
@@ -554,8 +559,8 @@ int PMPI_Iscan(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datat
   const void* real_sendbuf = smpi_get_in_place_buf(sendbuf, recvbuf, tmp_sendbuf, count, datatype);
 
   TRACE_smpi_comm_in(pid, request == MPI_REQUEST_IGNORED ? "PMPI_Scan" : "PMPI_Iscan",
-                     new simgrid::instr::Pt2PtTIData(request == MPI_REQUEST_IGNORED ? "scan" : "iscan", -1,
-                                                     count, simgrid::smpi::Datatype::encode(datatype)));
+                     new simgrid::instr::CollTIData(request == MPI_REQUEST_IGNORED ? "scan" : "iscan", -1, -1.0,
+                                                    count, 0, simgrid::smpi::Datatype::encode(datatype), ""));
 
   int retval;
   if (request == MPI_REQUEST_IGNORED)
@@ -639,7 +644,7 @@ int PMPI_Ireduce_scatter(const void *sendbuf, void *recvbuf, const int *recvcoun
 
   TRACE_smpi_comm_in(pid, request == MPI_REQUEST_IGNORED ? "PMPI_Reduce_scatter" : "PMPI_Ireduce_scatter",
                      new simgrid::instr::VarCollTIData(
-                         request == MPI_REQUEST_IGNORED ? "reducescatter" : "ireducescatter", -1, datatype->size(), nullptr,
+                         request == MPI_REQUEST_IGNORED ? "reducescatter" : "ireducescatter", -1, -1, nullptr,
                          0, trace_recvcounts, simgrid::smpi::Datatype::encode(datatype), ""));
 
   if (request == MPI_REQUEST_IGNORED)
@@ -681,8 +686,8 @@ int PMPI_Ireduce_scatter_block(const void* sendbuf, void* recvbuf, int recvcount
 
   TRACE_smpi_comm_in(
       pid, request == MPI_REQUEST_IGNORED ? "PMPI_Reduce_scatter_block" : "PMPI_Ireduce_scatter_block",
-      new simgrid::instr::VarCollTIData(request == MPI_REQUEST_IGNORED ? "reducescatter" : "ireducescatter", -1, 0,
-                                        nullptr, 0, trace_recvcounts, simgrid::smpi::Datatype::encode(datatype), ""));
+      new simgrid::instr::VarCollTIData(request == MPI_REQUEST_IGNORED ? "reducescatter" : "ireducescatter", -1, -1,
+                                        nullptr, -1, trace_recvcounts, simgrid::smpi::Datatype::encode(datatype), ""));
 
   std::vector<int> recvcounts(count);
   for (int i      = 0; i < count; i++)
index 8726208..d23817d 100644 (file)
@@ -371,11 +371,18 @@ void ReduceScatterArgParser::parse(simgrid::xbt::ReplayAction& action, const std
   datatype1  = parse_datatype(action, 3 + comm_size);
 
   for (unsigned int i = 0; i < comm_size; i++) {
-    recvcounts->push_back(std::stoi(action[i + 2]));
+    (*recvcounts)[i]= std::stoi(action[i + 2]);
   }
   recv_size_sum = std::accumulate(recvcounts->begin(), recvcounts->end(), 0);
 }
 
+void ScanArgParser::parse(simgrid::xbt::ReplayAction& action, const std::string&)
+{
+  CHECK_ACTION_PARAMS(action, 1, 1)
+  size      = parse_integer<size_t>(action[2]);
+  datatype1 = parse_datatype(action, 3);
+}
+
 void AllToAllVArgParser::parse(simgrid::xbt::ReplayAction& action, const std::string&)
 {
   /* The structure of the alltoallv action for the rank 0 (total 4 processes) is the following:
@@ -673,7 +680,7 @@ void GatherVAction::kernel(simgrid::xbt::ReplayAction&)
   const GatherVArgParser& args = get_args();
   TRACE_smpi_comm_in(get_pid(), get_name().c_str(),
                      new simgrid::instr::VarCollTIData(
-                         get_name(), (get_name() == "gatherv") ? args.root : -1, args.send_size, nullptr, 0,
+                         get_name(), (get_name() == "gatherv") ? args.root : -1, args.send_size, nullptr, -1,
                          args.recvcounts, Datatype::encode(args.datatype1), Datatype::encode(args.datatype2)));
 
   if (get_name() == "gatherv") {
@@ -710,7 +717,7 @@ void ScatterVAction::kernel(simgrid::xbt::ReplayAction&)
   int rank = MPI_COMM_WORLD->rank();
   const ScatterVArgParser& args = get_args();
   TRACE_smpi_comm_in(get_pid(), "action_scatterv",
-                     new simgrid::instr::VarCollTIData(get_name(), args.root, 0, args.sendcounts, args.recv_size,
+                     new simgrid::instr::VarCollTIData(get_name(), args.root, -1, args.sendcounts, args.recv_size,
                                                        nullptr, Datatype::encode(args.datatype1),
                                                        Datatype::encode(args.datatype2)));
 
@@ -727,7 +734,7 @@ void ReduceScatterAction::kernel(simgrid::xbt::ReplayAction&)
   const ReduceScatterArgParser& args = get_args();
   TRACE_smpi_comm_in(
       get_pid(), "action_reducescatter",
-      new simgrid::instr::VarCollTIData("reducescatter", -1, 0, nullptr, 0, args.recvcounts,
+      new simgrid::instr::VarCollTIData(get_name(), -1, -1, nullptr, -1, args.recvcounts,
                                         std::to_string(args.comp_size), /* ugly hack to print comp_size */
                                         Datatype::encode(args.datatype1)));