Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Enforce usage of std::shared_ptr for TIData.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 19 Feb 2021 11:51:58 +0000 (12:51 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 19 Feb 2021 21:05:39 +0000 (22:05 +0100)
This should finalize commit 4830e201d53af82a0d2722defd50a17363073785
([INSTR] Move vector* to shared_ptr<vector>.)

src/instr/instr_private.hpp
src/smpi/bindings/smpi_pmpi_coll.cpp
src/smpi/bindings/smpi_pmpi_request.cpp

index e5f7026..a9c3598 100644 (file)
@@ -84,11 +84,6 @@ public:
       , send_type(send_type)
       , recv_type(recv_type){};
   // VarCollTI: gatherv, scatterv, allgatherv, alltoallv (+ reducescatter out of laziness)
-  explicit TIData(const std::string& name, int root, int send_size, std::vector<int>* sendcounts, int recv_size,
-                  std::vector<int>* recvcounts, const std::string& send_type, const std::string& recv_type)
-      : TIData(name, root, send_size, std::shared_ptr<std::vector<int>>(sendcounts), recv_size,
-               std::shared_ptr<std::vector<int>>(recvcounts), send_type, recv_type){};
-
   explicit TIData(const std::string& name, int root, int send_size, std::shared_ptr<std::vector<int>> sendcounts,
                   int recv_size, std::shared_ptr<std::vector<int>> recvcounts, const std::string& send_type,
                   const std::string& recv_type)
@@ -171,10 +166,6 @@ public:
 
 class VarCollTIData : public TIData {
 public:
-  explicit VarCollTIData(const std::string& name, int root, int send_size, std::vector<int>* sendcounts, int recv_size,
-                         std::vector<int>* recvcounts, const std::string& send_type, const std::string& recv_type)
-      : TIData(name, root, send_size, sendcounts, recv_size, recvcounts, send_type, recv_type){};
-
   explicit VarCollTIData(const std::string& name, int root, int send_size, std::shared_ptr<std::vector<int>> sendcounts,
                          int recv_size, std::shared_ptr<std::vector<int>> recvcounts, const std::string& send_type,
                          const std::string& recv_type)
index 1c4b10c..478be13 100644 (file)
@@ -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);
@@ -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);
@@ -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;
 
@@ -649,7 +649,7 @@ int PMPI_Ireduce_scatter_block(const void* sendbuf, void* recvbuf, int recvcount
 
   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);
 
@@ -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;
@@ -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)
index 1ff4577..3853f99 100644 (file)
@@ -427,8 +427,8 @@ int PMPI_Sendrecv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, int
     int src_traced         = getPid(comm, src);
 
     // FIXME: Hack the way to trace this one
-    auto* dst_hack = new std::vector<int>();
-    auto* src_hack = new std::vector<int>();
+    auto dst_hack = std::make_shared<std::vector<int>>();
+    auto src_hack = std::make_shared<std::vector<int>>();
     dst_hack->push_back(dst_traced);
     src_hack->push_back(src_traced);
     TRACE_smpi_comm_in(my_proc_id, __func__,