From dee01a09191bb846eb6174125ef3fa1c450303b4 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Fri, 23 Mar 2018 16:37:33 +0100 Subject: [PATCH] this has been bugging me for a while --- src/instr/instr_paje_containers.cpp | 5 +++++ src/instr/instr_paje_containers.hpp | 2 +- src/s4u/s4u_actor.cpp | 3 +-- src/simix/ActorImpl.cpp | 7 ++----- src/smpi/internals/instr_smpi.cpp | 6 ++---- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/instr/instr_paje_containers.cpp b/src/instr/instr_paje_containers.cpp index 72afa41178..1778a4831c 100644 --- a/src/instr/instr_paje_containers.cpp +++ b/src/instr/instr_paje_containers.cpp @@ -114,6 +114,11 @@ Container::~Container() allContainers.erase(name_); } +void Container::createChild(std::string name, std::string type_name) +{ + new Container(name, type_name, this); +} + Container* Container::byNameOrNull(std::string name) { auto cont = allContainers.find(name); diff --git a/src/instr/instr_paje_containers.hpp b/src/instr/instr_paje_containers.hpp index fe1bd0063c..828024a97c 100644 --- a/src/instr/instr_paje_containers.hpp +++ b/src/instr/instr_paje_containers.hpp @@ -40,7 +40,7 @@ public: StateType* getState(std::string name); LinkType* getLink(std::string name); VariableType* getVariable(std::string name); - + void createChild(std::string name, std::string type_name); static Container* getRoot(); }; diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index 905532e269..653bf8c3aa 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -119,8 +119,7 @@ void Actor::migrate(Host* new_host) if (TRACE_actor_is_enabled()) { // create new container on the new_host location - new simgrid::instr::Container(instr_pid(this), "ACTOR", simgrid::instr::Container::byName(new_host->getName())); - + simgrid::instr::Container::byName(new_host->getName())->createChild(instr_pid(this), "ACTOR"); // end link link->endEvent(simgrid::instr::Container::byName(instr_pid(this)), "M", key); } diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index 64eb25aa69..95cec9d9f3 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -350,9 +350,7 @@ smx_actor_t SIMIX_process_create(const char* name, std::function code, v intrusive_ptr_add_ref(process); /* Tracing the process creation */ if (TRACE_actor_is_enabled()) - new simgrid::instr::Container(instr_pid(process->ciface()), "ACTOR", - simgrid::instr::Container::byName(process->host->getName())); - + simgrid::instr::Container::byName(process->host->getName())->createChild(instr_pid(process->ciface()), "ACTOR"); /* The onCreation() signal must be delayed until there, where the pid and everything is set */ simgrid::s4u::ActorPtr tmp = process->iface(); // Passing this directly to onCreation will lead to crashes simgrid::s4u::Actor::onCreation(tmp); @@ -410,8 +408,7 @@ smx_actor_t SIMIX_process_attach(const char* name, void* data, const char* hostn /* Tracing the process creation */ if (TRACE_actor_is_enabled()) - new simgrid::instr::Container(instr_pid(process->ciface()), "ACTOR", - simgrid::instr::Container::byName(process->host->getName())); + simgrid::instr::Container::byName(process->host->getName())->createChild(instr_pid(process->ciface()), "ACTOR"); auto* context = dynamic_cast(process->context); if (not context) diff --git a/src/smpi/internals/instr_smpi.cpp b/src/smpi/internals/instr_smpi.cpp index added70852..5e44075442 100644 --- a/src/smpi/internals/instr_smpi.cpp +++ b/src/smpi/internals/instr_smpi.cpp @@ -156,11 +156,9 @@ void TRACE_smpi_init(int rank) father = simgrid::instr::Container::getRoot(); } xbt_assert(father != nullptr, "Could not find a parent for mpi rank %s at function %s", str.c_str(), __FUNCTION__); + father->createChild(str, "MPI"); #if HAVE_PAPI - container_t container = -#endif - new simgrid::instr::Container(str, "MPI", father); -#if HAVE_PAPI + container_t container = simgrid::instr::Container::byName(str); papi_counter_t counters = smpi_process()->papi_counters(); for (auto const& it : counters) { -- 2.20.1