From 5c33ef14a6c1c95ec3ebeeea0966bd28fdedf02e Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 18 Jul 2018 11:45:44 +0200 Subject: [PATCH] Simplify memory handling. --- src/instr/instr_smpi.hpp | 1 - src/smpi/internals/instr_smpi.cpp | 32 +++++++----------------------- src/smpi/internals/smpi_global.cpp | 1 - 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/src/instr/instr_smpi.hpp b/src/instr/instr_smpi.hpp index e6a72b348d..5ad0e944c7 100644 --- a/src/instr/instr_smpi.hpp +++ b/src/instr/instr_smpi.hpp @@ -22,7 +22,6 @@ XBT_PRIVATE void TRACE_smpi_computing_in(int rank, double amount); XBT_PRIVATE void TRACE_smpi_sleeping_init(int rank); XBT_PRIVATE void TRACE_smpi_sleeping_out(int rank); XBT_PRIVATE void TRACE_smpi_sleeping_in(int rank, double duration); -XBT_PRIVATE void TRACE_smpi_release(); XBT_PRIVATE void TRACE_smpi_comm_in(int rank, const char* operation, simgrid::instr::TIData* extra); XBT_PRIVATE void TRACE_smpi_comm_out(int rank); XBT_PRIVATE void TRACE_smpi_send(int rank, int src, int dst, int tag, int size); diff --git a/src/smpi/internals/instr_smpi.cpp b/src/smpi/internals/instr_smpi.cpp index 9c43bde030..c5a65d81c8 100644 --- a/src/smpi/internals/instr_smpi.cpp +++ b/src/smpi/internals/instr_smpi.cpp @@ -19,7 +19,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_smpi, instr, "Tracing SMPI"); -static std::unordered_map*> keys; +static std::unordered_map> keys; static std::map smpi_colors = {{"recv", "1 0 0"}, {"irecv", "1 0.52 0.52"}, @@ -102,18 +102,6 @@ XBT_PRIVATE container_t smpi_container(int rank) static std::string TRACE_smpi_put_key(int src, int dst, int tag, int send) { - // get the deque for src#dst - std::string aux = - std::to_string(src) + "#" + std::to_string(dst) + "#" + std::to_string(tag) + "#" + std::to_string(send); - auto it = keys.find(aux); - std::deque* d; - - if (it == keys.end()) { - d = new std::deque; - keys[aux] = d; - } else - d = it->second; - //generate the key static unsigned long long counter = 0; counter++; @@ -121,7 +109,9 @@ static std::string TRACE_smpi_put_key(int src, int dst, int tag, int send) std::to_string(src) + "_" + std::to_string(dst) + "_" + std::to_string(tag) + "_" + std::to_string(counter); //push it - d->push_back(key); + std::string aux = + std::to_string(src) + "#" + std::to_string(dst) + "#" + std::to_string(tag) + "#" + std::to_string(send); + keys[aux].push_back(key); return key; } @@ -136,12 +126,10 @@ static std::string TRACE_smpi_get_key(int src, int dst, int tag, int send) // first posted key = TRACE_smpi_put_key(src, dst, tag, send); } else { - key = it->second->front(); - it->second->pop_front(); - if (it->second->empty()) { - delete it->second; + key = it->second.front(); + it->second.pop_front(); + if (it->second.empty()) keys.erase(it); - } } return key; } @@ -169,12 +157,6 @@ const char *TRACE_internal_smpi_get_category () return (it == process_category.end()) ? nullptr : it->second.c_str(); } -void TRACE_smpi_release() -{ - for (auto const& elm : keys) - delete elm.second; -} - void TRACE_smpi_setup_container(int rank, sg_host_t host) { container_t father = simgrid::instr::Container::get_root(); diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index c28af0c90c..a8f461be9a 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -701,7 +701,6 @@ void SMPI_init(){ smpi_init_options(); smpi_global_init(); smpi_check_options(); - simgrid::s4u::on_simulation_end.connect(TRACE_smpi_release); } void SMPI_finalize(){ -- 2.20.1