From: Arnaud Giersch Date: Fri, 19 Feb 2021 11:51:58 +0000 (+0100) Subject: Enforce usage of std::shared_ptr for TIData. X-Git-Tag: v3.27~329 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/3965b45784421b5cdf6069e048dad3e184ae7d72 Enforce usage of std::shared_ptr for TIData. This should finalize commit 4830e201d53af82a0d2722defd50a17363073785 ([INSTR] Move vector* to shared_ptr.) --- diff --git a/src/instr/instr_private.hpp b/src/instr/instr_private.hpp index e5f702627f..a9c3598c65 100644 --- a/src/instr/instr_private.hpp +++ b/src/instr/instr_private.hpp @@ -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* sendcounts, int recv_size, - std::vector* recvcounts, const std::string& send_type, const std::string& recv_type) - : TIData(name, root, send_size, std::shared_ptr>(sendcounts), recv_size, - std::shared_ptr>(recvcounts), send_type, recv_type){}; - explicit TIData(const std::string& name, int root, int send_size, std::shared_ptr> sendcounts, int recv_size, std::shared_ptr> 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* sendcounts, int recv_size, - std::vector* 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> sendcounts, int recv_size, std::shared_ptr> recvcounts, const std::string& send_type, const std::string& recv_type) diff --git a/src/smpi/bindings/smpi_pmpi_coll.cpp b/src/smpi/bindings/smpi_pmpi_coll.cpp index 1c4b10ccfc..478be13e52 100644 --- a/src/smpi/bindings/smpi_pmpi_coll.cpp +++ b/src/smpi/bindings/smpi_pmpi_coll.cpp @@ -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(); + auto trace_recvcounts = std::make_shared>(); 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(); + auto trace_recvcounts = std::make_shared>(); 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(); + auto trace_sendcounts = std::make_shared>(); 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(); + auto trace_recvcounts = std::make_shared>(); 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(recvcount * dt_send_size); // copy data to avoid bad free + auto trace_recvcounts = std::make_shared>(recvcount * dt_send_size); // copy data to avoid bad free std::vector 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(); - auto* trace_recvcounts = new std::vector(); + auto trace_sendcounts = std::make_shared>(); + auto trace_recvcounts = std::make_shared>(); 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(); - auto* trace_recvcounts = new std::vector(); + auto trace_sendcounts = std::make_shared>(); + auto trace_recvcounts = std::make_shared>(); 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) diff --git a/src/smpi/bindings/smpi_pmpi_request.cpp b/src/smpi/bindings/smpi_pmpi_request.cpp index 1ff4577eb4..3853f99fbf 100644 --- a/src/smpi/bindings/smpi_pmpi_request.cpp +++ b/src/smpi/bindings/smpi_pmpi_request.cpp @@ -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(); - auto* src_hack = new std::vector(); + auto dst_hack = std::make_shared>(); + auto src_hack = std::make_shared>(); dst_hack->push_back(dst_traced); src_hack->push_back(src_traced); TRACE_smpi_comm_in(my_proc_id, __func__,