From 7945dd060a9ae14801914ef3be75f4abf083039b Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Mon, 11 Mar 2019 16:31:17 +0100 Subject: [PATCH] Simplifications Do not use an ugly global map when each smpi process can store its own tracing category. --- src/instr/instr_smpi.hpp | 2 -- src/smpi/bindings/smpi_pmpi.cpp | 8 ++++++-- src/smpi/include/smpi_actor.hpp | 4 ++++ src/smpi/internals/instr_smpi.cpp | 23 ----------------------- src/smpi/internals/smpi_bench.cpp | 2 +- src/smpi/mpi/smpi_request.cpp | 2 +- 6 files changed, 12 insertions(+), 29 deletions(-) diff --git a/src/instr/instr_smpi.hpp b/src/instr/instr_smpi.hpp index afe5c571f3..4ac56a92f9 100644 --- a/src/instr/instr_smpi.hpp +++ b/src/instr/instr_smpi.hpp @@ -14,8 +14,6 @@ XBT_PRIVATE container_t smpi_container(int rank); XBT_PRIVATE void TRACE_smpi_setup_container(int rank, sg_host_t host); -XBT_PRIVATE void TRACE_internal_smpi_set_category(const std::string& category); -XBT_PRIVATE std::string TRACE_internal_smpi_get_category(); XBT_PRIVATE void TRACE_smpi_computing_init(int rank); XBT_PRIVATE void TRACE_smpi_computing_out(int rank); XBT_PRIVATE void TRACE_smpi_computing_in(int rank, double amount); diff --git a/src/smpi/bindings/smpi_pmpi.cpp b/src/smpi/bindings/smpi_pmpi.cpp index 8d8886f123..49b2b370ee 100644 --- a/src/smpi/bindings/smpi_pmpi.cpp +++ b/src/smpi/bindings/smpi_pmpi.cpp @@ -4,6 +4,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "private.hpp" +#include "simgrid/instr.h" #include "simgrid/s4u/Engine.hpp" #include "simgrid/s4u/Host.hpp" #include "smpi_comm.hpp" @@ -19,8 +20,11 @@ void TRACE_smpi_set_category(const char *category) { //need to end bench otherwise categories for execution tasks are wrong smpi_bench_end(); - if (category != nullptr) - TRACE_internal_smpi_set_category(category); + if (category != nullptr) { + // declare category + TRACE_category(category); + smpi_process()->set_tracing_category(category); + } //begin bench after changing process's category smpi_bench_begin(); } diff --git a/src/smpi/include/smpi_actor.hpp b/src/smpi/include/smpi_actor.hpp index 067fe283fb..1314d4b430 100644 --- a/src/smpi/include/smpi_actor.hpp +++ b/src/smpi/include/smpi_actor.hpp @@ -33,6 +33,8 @@ private: s4u::ActorPtr actor_ = nullptr; smpi_privatization_region_t privatized_region_ = nullptr; int optind = 0; /*for getopt replacement */ + std::string tracing_category_ = ""; + #if HAVE_PAPI /** Contains hardware data as read by PAPI **/ int papi_event_set_; @@ -51,6 +53,8 @@ public: void mark_as_initialized(); void set_replaying(bool value); bool replaying(); + void set_tracing_category(const std::string& category) { tracing_category_ = category; } + const std::string& get_tracing_category() { return tracing_category_; } smpi_trace_call_location_t* call_location(); void set_privatized_region(smpi_privatization_region_t region); smpi_privatization_region_t privatized_region(); diff --git a/src/smpi/internals/instr_smpi.cpp b/src/smpi/internals/instr_smpi.cpp index bcb4782ca2..4d3ab5a2b4 100644 --- a/src/smpi/internals/instr_smpi.cpp +++ b/src/smpi/internals/instr_smpi.cpp @@ -134,29 +134,6 @@ static std::string TRACE_smpi_get_key(int src, int dst, int tag, int send) return key; } -static std::unordered_map process_category; - -void TRACE_internal_smpi_set_category(const std::string& category) -{ - if (not TRACE_smpi_is_enabled()) - return; - - //declare category - TRACE_category(category.c_str()); - - if (not category.empty()) - process_category[SIMIX_process_self()] = category; -} - -std::string TRACE_internal_smpi_get_category() -{ - if (not TRACE_smpi_is_enabled()) - return ""; - - auto it = process_category.find(SIMIX_process_self()); - return (it == process_category.end()) ? "" : it->second.c_str(); -} - 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_bench.cpp b/src/smpi/internals/smpi_bench.cpp index b987d8544c..c6af1236e0 100644 --- a/src/smpi/internals/smpi_bench.cpp +++ b/src/smpi/internals/smpi_bench.cpp @@ -57,7 +57,7 @@ void smpi_execute_flops(double flops) { XBT_DEBUG("Handle real computation time: %f flops", flops); simgrid::s4u::this_actor::exec_init(flops) ->set_name("computation") - ->set_tracing_category(TRACE_internal_smpi_get_category()) + ->set_tracing_category(smpi_process()->get_tracing_category()) ->start() ->wait(); smpi_switch_data_segment(simgrid::s4u::Actor::self()); diff --git a/src/smpi/mpi/smpi_request.cpp b/src/smpi/mpi/smpi_request.cpp index 3a01a1631a..5bbd84ea23 100644 --- a/src/smpi/mpi/smpi_request.cpp +++ b/src/smpi/mpi/smpi_request.cpp @@ -516,7 +516,7 @@ void Request::start() /* FIXME: detached sends are not traceable (action_ == nullptr) */ if (action_ != nullptr) { - std::string category = TRACE_internal_smpi_get_category(); + std::string category = smpi_process()->get_tracing_category(); simgrid::simix::simcall([this, category] { this->action_->set_category(category); }); } -- 2.20.1