X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3d565eeaa3e81cd3b49592cfe6899962527c06a5..58ff959662ba6ebb02d3099d43de773b955eb698:/src/smpi/internals/instr_smpi.cpp diff --git a/src/smpi/internals/instr_smpi.cpp b/src/smpi/internals/instr_smpi.cpp index 57ac211726..def0effed4 100644 --- a/src/smpi/internals/instr_smpi.cpp +++ b/src/smpi/internals/instr_smpi.cpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2010-2018. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2010-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -16,9 +15,11 @@ #include #include +#include "src/smpi/include/smpi_actor.hpp" + 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"}, @@ -101,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++; @@ -120,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; } @@ -135,8 +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(); + key = it->second.front(); + it->second.pop_front(); + if (it->second.empty()) + keys.erase(it); } return key; } @@ -158,16 +151,10 @@ void TRACE_internal_smpi_set_category (const char *category) const char *TRACE_internal_smpi_get_category () { if (not TRACE_smpi_is_enabled()) - return nullptr; + return ""; auto it = process_category.find(SIMIX_process_self()); - return (it == process_category.end()) ? nullptr : it->second.c_str(); -} - -void TRACE_smpi_release() -{ - for (auto const& elm : keys) - delete elm.second; + return (it == process_category.end()) ? "" : it->second.c_str(); } void TRACE_smpi_setup_container(int rank, sg_host_t host) @@ -187,7 +174,7 @@ void TRACE_smpi_init(int rank) TRACE_smpi_setup_container(rank, sg_host_self()); #if HAVE_PAPI - container_t container = simgrid::instr::Container::by_name(str); + container_t container = smpi_container(rank); papi_counter_t counters = smpi_process()->papi_counters(); for (auto const& it : counters) { @@ -195,9 +182,7 @@ void TRACE_smpi_init(int rank) * Check whether this variable already exists or not. Otherwise, it will be created * multiple times but only the last one would be used... */ - if (s_type::getOrNull(it.first.c_str(), container->type_) == nullptr) { - Type::variableNew(it.first.c_str(), "", container->type_); - } + container->type_->by_name_or_create(it.first, ""); } #endif }