Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
enough playing with instr for now ...
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 30 Oct 2017 20:28:39 +0000 (21:28 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 30 Oct 2017 20:28:39 +0000 (21:28 +0100)
14 files changed:
src/instr/instr_config.cpp
src/instr/instr_interface.cpp
src/instr/instr_paje_containers.cpp
src/instr/instr_paje_containers.hpp
src/instr/instr_paje_types.cpp
src/instr/instr_paje_types.hpp
src/instr/instr_resource_utilization.cpp
src/msg/instr_msg_process.cpp
src/msg/instr_msg_task.cpp
src/msg/msg_vm.cpp
src/smpi/colls/smpi_automatic_selector.cpp
src/smpi/internals/instr_smpi.cpp
src/surf/instr_routing.cpp
src/surf/instr_surf.cpp

index 0ab998e..6c837b2 100644 (file)
@@ -63,8 +63,6 @@ static int trace_precision;
 static bool trace_configured = false;
 static bool trace_active     = false;
 
-static simgrid::instr::Type* rootType = nullptr; /* the root type */
-
 instr_fmt_type_t instr_fmt_type = instr_fmt_paje;
 
 static void TRACE_getopts()
@@ -141,10 +139,10 @@ int TRACE_end()
     TRACE_last_timestamp_to_dump = surf_get_clock();
     TRACE_paje_dump_buffer(true);
 
+    container_t root = simgrid::instr::Container::getRootContainer();
     /* destroy all data structures of tracing (and free) */
-    delete simgrid::instr::Container::getRootContainer();
-    delete simgrid::instr::Type::getRootType();
-    rootType = nullptr;
+    delete root;
+    delete root->type_;
 
     /* close the trace files */
     const char* format = xbt_cfg_get_string(OPT_TRACING_FORMAT);
index e05d9c5..4c484f2 100644 (file)
@@ -148,7 +148,7 @@ void TRACE_declare_mark(const char *mark_type)
   }
 
   XBT_DEBUG("MARK,declare %s", mark_type);
-  simgrid::instr::Type::getRootType()->getOrCreateEventType(mark_type);
+  simgrid::instr::Container::getRootContainer()->type_->getOrCreateEventType(mark_type);
   declared_marks.insert(mark_type);
 }
 
@@ -179,7 +179,7 @@ void TRACE_declare_mark_value_with_color (const char *mark_type, const char *mar
     THROWF (tracing_error, 1, "mark_value is nullptr");
 
   simgrid::instr::EventType* type =
-      static_cast<simgrid::instr::EventType*>(simgrid::instr::Type::getRootType()->byName(mark_type));
+      static_cast<simgrid::instr::EventType*>(simgrid::instr::Container::getRootContainer()->type_->byName(mark_type));
   if (not type) {
     THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type);
   } else {
@@ -235,7 +235,7 @@ void TRACE_mark(const char *mark_type, const char *mark_value)
 
   //check if mark_type is already declared
   simgrid::instr::EventType* type =
-      static_cast<simgrid::instr::EventType*>(simgrid::instr::Type::getRootType()->byName(mark_type));
+      static_cast<simgrid::instr::EventType*>(simgrid::instr::Container::getRootContainer()->type_->byName(mark_type));
   if (not type) {
     THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type);
   } else {
@@ -276,20 +276,16 @@ static void instr_user_variable(double time, const char* resource, const char* v
     }
   }else{
     if (created != filter->end()) { // declared, let's work
-      char valuestr[100];
-      snprintf(valuestr, 100, "%g", value);
-      container_t container      = simgrid::instr::Container::byName(resource);
-      simgrid::instr::VariableType* variable =
-          static_cast<simgrid::instr::VariableType*>(container->type_->byName(variable_name));
+      simgrid::instr::VariableType* variable = simgrid::instr::Container::byName(resource)->getVariable(variable_name);
       switch (what){
       case INSTR_US_SET:
-        variable->setEvent(time, container, value);
+        variable->setEvent(time, value);
         break;
       case INSTR_US_ADD:
-        variable->addEvent(time, container, value);
+        variable->addEvent(time, value);
         break;
       case INSTR_US_SUB:
-        variable->subEvent(time, container, value);
+        variable->subEvent(time, value);
         break;
       default:
         THROW_IMPOSSIBLE;
index 40b6fb0..0f9b0ce 100644 (file)
@@ -44,7 +44,7 @@ NetZoneContainer::NetZoneContainer(std::string name, unsigned int level, NetZone
     father_->children_.insert({getName(), this});
     logCreation();
   } else {
-    type_ = Type::createRootType();
+    type_         = new ContainerType("0");
     rootContainer = this;
   }
 }
@@ -232,5 +232,17 @@ StateType* Container::getState(std::string name)
   ret->setCallingContainer(this);
   return ret;
 }
+
+LinkType* Container::getLink(std::string name)
+{
+  return dynamic_cast<LinkType*>(type_->byName(name));
+}
+
+VariableType* Container::getVariable(std::string name)
+{
+  VariableType* ret = dynamic_cast<VariableType*>(type_->byName(name));
+  ret->setCallingContainer(this);
+  return ret;
+}
 }
 }
index d18ddde..50501ff 100644 (file)
@@ -12,7 +12,9 @@
 namespace simgrid {
 namespace instr {
 class Type;
+class LinkType;
 class StateType;
+class VariableType;
 
 class Container {
   long long int id_;
@@ -36,6 +38,9 @@ public:
   void logDestruction();
 
   StateType* getState(std::string name);
+  LinkType* getLink(std::string name);
+  VariableType* getVariable(std::string name);
+
   static Container* getRootContainer();
 };
 
index 03995c7..5cd7683 100644 (file)
@@ -8,7 +8,6 @@
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_types, instr, "Paje tracing event system (types)");
 
-static simgrid::instr::ContainerType* rootType = nullptr; /* the root type */
 extern FILE* tracing_file;
 
 namespace simgrid {
@@ -93,19 +92,19 @@ VariableType::~VariableType()
   events_.clear();
 }
 
-void VariableType::setEvent(double timestamp, Container* container, double value)
+void VariableType::setEvent(double timestamp, double value)
 {
-  events_.push_back(new VariableEvent(timestamp, container, this, PAJE_SetVariable, value));
+  events_.push_back(new VariableEvent(timestamp, issuer_, this, PAJE_SetVariable, value));
 }
 
-void VariableType::addEvent(double timestamp, Container* container, double value)
+void VariableType::addEvent(double timestamp, double value)
 {
-  events_.push_back(new VariableEvent(timestamp, container, this, PAJE_AddVariable, value));
+  events_.push_back(new VariableEvent(timestamp, issuer_, this, PAJE_AddVariable, value));
 }
 
-void VariableType::subEvent(double timestamp, Container* container, double value)
+void VariableType::subEvent(double timestamp, double value)
 {
-  events_.push_back(new VariableEvent(timestamp, container, this, PAJE_SubVariable, value));
+  events_.push_back(new VariableEvent(timestamp, issuer_, this, PAJE_SubVariable, value));
 }
 
 LinkType::LinkType(std::string name, std::string alias, Type* father) : ValueType(name, alias, father)
@@ -199,17 +198,6 @@ EntityValue* ValueType::getEntityValue(std::string name)
   return ret->second;
 }
 
-ContainerType* Type::createRootType()
-{
-  rootType = new ContainerType("0");
-  return rootType;
-}
-
-ContainerType* Type::getRootType()
-{
-  return rootType;
-}
-
 ContainerType* Type::getOrCreateContainerType(std::string name)
 {
   auto cont = children_.find(name);
index 6d9a9bf..8ce51ad 100644 (file)
@@ -43,17 +43,11 @@ public:
   ContainerType* getOrCreateContainerType(std::string name);
   EventType* getOrCreateEventType(std::string name);
   LinkType* getOrCreateLinkType(std::string name, Type* source, Type* dest);
-
   StateType* getOrCreateStateType(std::string name);
-  StateType* getState(std::string name);
-
   VariableType* getOrCreateVariableType(std::string name, std::string color);
 
   void logDefinition(e_event_type event_type);
   void logDefinition(Type* source, Type* dest);
-
-  static ContainerType* createRootType();
-  static ContainerType* getRootType();
 };
 
 class ContainerType : public Type {
@@ -64,13 +58,15 @@ public:
 
 class VariableType : public Type {
   std::vector<VariableEvent*> events_;
+  Container* issuer_ = nullptr;
 
 public:
   VariableType(std::string name, std::string color, Type* father);
   ~VariableType();
-  void setEvent(double timestamp, Container* container, double value);
-  void addEvent(double timestamp, Container* container, double value);
-  void subEvent(double timestamp, Container* container, double value);
+  void setCallingContainer(Container* container) { issuer_ = container; }
+  void setEvent(double timestamp, double value);
+  void addEvent(double timestamp, double value);
+  void subEvent(double timestamp, double value);
 };
 
 class ValueType : public Type {
index 7de5c32..77dc1e9 100644 (file)
@@ -26,12 +26,12 @@ static void instr_event(double now, double delta, simgrid::instr::VariableType*
 
   // check if key exists: if it doesn't, set the variable to zero and mark this in the global map.
   if (platform_variables.find(key) == platform_variables.end()) {
-    variable->setEvent(now, resource, 0);
+    variable->setEvent(now, 0);
     platform_variables.insert(key);
   }
 
-  variable->addEvent(now, resource, value);
-  variable->subEvent(now + delta, resource, value);
+  variable->addEvent(now, value);
+  variable->subEvent(now + delta, value);
 }
 
 /* TRACE_surf_link_set_utilization: entry point from SimGrid */
@@ -45,8 +45,7 @@ void TRACE_surf_link_set_utilization(const char *resource, const char *category,
   //trace uncategorized link utilization
   if (TRACE_uncategorized()){
     XBT_DEBUG("UNCAT LINK [%f - %f] %s bandwidth_used %f", now, now + delta, resource, value);
-    simgrid::instr::VariableType* variable =
-        static_cast<simgrid::instr::VariableType*>(container->type_->byName("bandwidth_used"));
+    simgrid::instr::VariableType* variable = container->getVariable("bandwidth_used");
     instr_event(now, delta, variable, container, value);
   }
 
@@ -57,8 +56,7 @@ void TRACE_surf_link_set_utilization(const char *resource, const char *category,
     //variable of this category starts by 'b', because we have a link here
     std::string category_type = std::string("b") + category;
     XBT_DEBUG("CAT LINK [%f - %f] %s %s %f", now, now + delta, resource, category_type.c_str(), value);
-    simgrid::instr::VariableType* variable =
-        static_cast<simgrid::instr::VariableType*>(container->type_->byName(category_type));
+    simgrid::instr::VariableType* variable = container->getVariable(category_type);
     instr_event(now, delta, variable, container, value);
   }
 }
@@ -74,8 +72,7 @@ void TRACE_surf_host_set_utilization(const char *resource, const char *category,
   //trace uncategorized host utilization
   if (TRACE_uncategorized()){
     XBT_DEBUG("UNCAT HOST [%f - %f] %s power_used %f", now, now+delta, resource, value);
-    simgrid::instr::VariableType* variable =
-        static_cast<simgrid::instr::VariableType*>(container->type_->byName("power_used"));
+    simgrid::instr::VariableType* variable = container->getVariable("power_used");
     instr_event(now, delta, variable, container, value);
   }
 
@@ -86,8 +83,7 @@ void TRACE_surf_host_set_utilization(const char *resource, const char *category,
     //variable of this category starts by 'p', because we have a host here
     std::string category_type = std::string("p") + category;
     XBT_DEBUG("CAT HOST [%f - %f] %s %s %f", now, now + delta, resource, category_type.c_str(), value);
-    simgrid::instr::VariableType* variable =
-        static_cast<simgrid::instr::VariableType*>(container->type_->byName(category_type));
+    simgrid::instr::VariableType* variable = container->getVariable(category_type);
     instr_event(now, delta, variable, container, value);
   }
 }
index 1d4201b..7f252d0 100644 (file)
@@ -23,10 +23,10 @@ void TRACE_msg_process_change_host(msg_process_t process, msg_host_t new_host)
     std::string key = std::to_string(counter++);
 
     //start link
-    container_t msg = simgrid::instr::Container::byName(instr_pid(process));
-    simgrid::instr::LinkType* link =
-        static_cast<simgrid::instr::LinkType*>(simgrid::instr::Type::getRootType()->byName("MSG_PROCESS_LINK"));
-    link->startEvent(simgrid::instr::Container::getRootContainer(), msg, "M", key);
+    container_t msg                = simgrid::instr::Container::byName(instr_pid(process));
+    container_t root               = simgrid::instr::Container::getRootContainer();
+    simgrid::instr::LinkType* link = root->getLink("MSG_PROCESS_LINK");
+    link->startEvent(root, msg, "M", key);
 
     //destroy existing container of this process
     TRACE_msg_process_destroy (MSG_process_get_name (process), MSG_process_get_PID (process));
@@ -36,7 +36,7 @@ void TRACE_msg_process_change_host(msg_process_t process, msg_host_t new_host)
 
     //end link
     msg = simgrid::instr::Container::byName(instr_pid(process));
-    link->endEvent(simgrid::instr::Container::getRootContainer(), msg, "M", key);
+    link->endEvent(root, msg, "M", key);
   }
 }
 
index eabb375..873025f 100644 (file)
@@ -92,9 +92,9 @@ void TRACE_msg_task_get_end(double start_time, msg_task_t task)
     process_container->getState("MSG_PROCESS_STATE")->popEvent();
 
     std::string key = std::string("p") + std::to_string(task->counter);
-    simgrid::instr::LinkType* link =
-        static_cast<simgrid::instr::LinkType*>(simgrid::instr::Type::getRootType()->byName("MSG_PROCESS_TASK_LINK"));
-    link->endEvent(simgrid::instr::Container::getRootContainer(), process_container, "SR", key);
+    container_t root               = simgrid::instr::Container::getRootContainer();
+    simgrid::instr::LinkType* link = root->getLink("MSG_PROCESS_TASK_LINK");
+    link->endEvent(root, process_container, "SR", key);
   }
 }
 
@@ -108,9 +108,9 @@ int TRACE_msg_task_put_start(msg_task_t task)
     process_container->getState("MSG_PROCESS_STATE")->pushEvent("send");
 
     std::string key = std::string("p") + std::to_string(task->counter);
-    simgrid::instr::LinkType* link =
-        static_cast<simgrid::instr::LinkType*>(simgrid::instr::Type::getRootType()->byName("MSG_PROCESS_TASK_LINK"));
-    link->startEvent(simgrid::instr::Container::getRootContainer(), process_container, "SR", key);
+    container_t root               = simgrid::instr::Container::getRootContainer();
+    simgrid::instr::LinkType* link = root->getLink("MSG_PROCESS_TASK_LINK");
+    link->startEvent(root, process_container, "SR", key);
   }
 
   return 1;
index ef8219c..479da6d 100644 (file)
@@ -293,8 +293,7 @@ static int migration_rx_fun(int argc, char *argv[])
 
     // start link
     container_t msg            = simgrid::instr::Container::byName(vm->getName());
-    simgrid::instr::LinkType* link =
-        static_cast<simgrid::instr::LinkType*>(simgrid::instr::Type::getRootType()->byName("MSG_VM_LINK"));
+    simgrid::instr::LinkType* link = simgrid::instr::Container::getRootContainer()->getLink("MSG_VM_LINK");
     link->startEvent(simgrid::instr::Container::getRootContainer(), msg, "M", key);
 
     // destroy existing container of this vm
index 3447878..89e552e 100644 (file)
@@ -17,7 +17,7 @@
 #define TRACE_AUTO_COLL(cat)                                                                                           \
   if (TRACE_is_enabled()) {                                                                                            \
     simgrid::instr::EventType* type =                                                                                  \
-        static_cast<simgrid::instr::EventType*>(simgrid::instr::Type::getRootType()->getOrCreateEventType(#cat));      \
+        simgrid::instr::Container::getRootContainer()->type_->getOrCreateEventType(#cat);                              \
                                                                                                                        \
     char cont_name[25];                                                                                                \
     snprintf(cont_name, 25, "rank-%d", smpi_process()->index());                                                       \
index d934f1a..7589afa 100644 (file)
@@ -318,8 +318,7 @@ void TRACE_smpi_send(int rank, int src, int dst, int tag, int size)
   std::string key = TRACE_smpi_get_key(src, dst, tag, 1);
 
   container_t container      = simgrid::instr::Container::byName(smpi_container(rank));
-  simgrid::instr::LinkType* link =
-      static_cast<simgrid::instr::LinkType*>(simgrid::instr::Type::getRootType()->byName("MPI_LINK"));
+  simgrid::instr::LinkType* link = simgrid::instr::Container::getRootContainer()->getLink("MPI_LINK");
   XBT_DEBUG("Send tracing from %d to %d, tag %d, with key %s", src, dst, tag, key.c_str());
   link->startEvent(simgrid::instr::Container::getRootContainer(), container, "PTP", key, size);
 }
@@ -332,8 +331,7 @@ void TRACE_smpi_recv(int src, int dst, int tag)
   std::string key = TRACE_smpi_get_key(src, dst, tag, 0);
 
   container_t container      = simgrid::instr::Container::byName(smpi_container(dst));
-  simgrid::instr::LinkType* link =
-      static_cast<simgrid::instr::LinkType*>(simgrid::instr::Type::getRootType()->byName("MPI_LINK"));
+  simgrid::instr::LinkType* link = simgrid::instr::Container::getRootContainer()->getLink("MPI_LINK");
   XBT_DEBUG("Recv tracing from %d to %d, tag %d, with key %s", src, dst, tag, key.c_str());
   link->endEvent(simgrid::instr::Container::getRootContainer(), container, "PTP", key);
 }
index f2c5ecf..f59898f 100644 (file)
@@ -161,7 +161,7 @@ static void sg_instr_AS_begin(simgrid::s4u::NetZone& netzone)
       simgrid::instr::Type* mpi = root->type_->getOrCreateContainerType("MPI");
       if (not TRACE_smpi_is_grouped())
         mpi->getOrCreateStateType("MPI_STATE");
-      simgrid::instr::Type::getRootType()->getOrCreateLinkType("MPI_LINK", mpi, mpi);
+      root->type_->getOrCreateLinkType("MPI_LINK", mpi, mpi);
     }
 
     if (TRACE_needs_platform()){
@@ -193,8 +193,12 @@ static void instr_routing_parse_start_link(simgrid::s4u::Link& link)
   container_t container = new simgrid::instr::Container(link.getName(), "LINK", father);
 
   if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_link())) {
-    container->type_->getOrCreateVariableType("bandwidth", "")->setEvent(0, container, link.bandwidth());
-    container->type_->getOrCreateVariableType("latency", "")->setEvent(0, container, link.latency());
+    simgrid::instr::VariableType* bandwidth = container->type_->getOrCreateVariableType("bandwidth", "");
+    bandwidth->setCallingContainer(container);
+    bandwidth->setEvent(0, link.bandwidth());
+    simgrid::instr::VariableType* latency = container->type_->getOrCreateVariableType("latency", "");
+    latency->setCallingContainer(container);
+    latency->setEvent(0, link.latency());
   }
   if (TRACE_uncategorized()) {
     container->type_->getOrCreateVariableType("bandwidth_used", "0.5 0.5 0.5");
@@ -204,9 +208,12 @@ static void instr_routing_parse_start_link(simgrid::s4u::Link& link)
 static void sg_instr_new_host(simgrid::s4u::Host& host)
 {
   container_t container = new simgrid::instr::HostContainer(host, currentContainer.back());
+  container_t root      = simgrid::instr::Container::getRootContainer();
 
   if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_speed())) {
-    container->type_->getOrCreateVariableType("power", "")->setEvent(0, container, host.getSpeed());
+    simgrid::instr::VariableType* power = container->type_->getOrCreateVariableType("power", "");
+    power->setCallingContainer(container);
+    power->setEvent(0, host.getSpeed());
   }
 
   if (TRACE_uncategorized())
@@ -223,8 +230,8 @@ static void sg_instr_new_host(simgrid::s4u::Host& host)
     state->addEntityValue("receive", "1 0 0");
     state->addEntityValue("send", "0 0 1");
     state->addEntityValue("task_execute", "0 1 1");
-    simgrid::instr::Type::getRootType()->getOrCreateLinkType("MSG_PROCESS_LINK", msg_process, msg_process);
-    simgrid::instr::Type::getRootType()->getOrCreateLinkType("MSG_PROCESS_TASK_LINK", msg_process, msg_process);
+    root->type_->getOrCreateLinkType("MSG_PROCESS_LINK", msg_process, msg_process);
+    root->type_->getOrCreateLinkType("MSG_PROCESS_TASK_LINK", msg_process, msg_process);
   }
 
   if (TRACE_msg_vm_is_enabled()) {
@@ -235,8 +242,8 @@ static void sg_instr_new_host(simgrid::s4u::Host& host)
     state->addEntityValue("receive", "1 0 0");
     state->addEntityValue("send", "0 0 1");
     state->addEntityValue("task_execute", "0 1 1");
-    simgrid::instr::Type::getRootType()->getOrCreateLinkType("MSG_VM_LINK", msg_vm, msg_vm);
-    simgrid::instr::Type::getRootType()->getOrCreateLinkType("MSG_VM_PROCESS_LINK", msg_vm, msg_vm);
+    root->type_->getOrCreateLinkType("MSG_VM_LINK", msg_vm, msg_vm);
+    root->type_->getOrCreateLinkType("MSG_VM_PROCESS_LINK", msg_vm, msg_vm);
   }
 }
 
@@ -291,7 +298,7 @@ static void recursiveNewVariableType(std::string new_typename, std::string color
 
 void instr_new_variable_type(std::string new_typename, std::string color)
 {
-  recursiveNewVariableType(new_typename, color, simgrid::instr::Type::getRootType());
+  recursiveNewVariableType(new_typename, color, simgrid::instr::Container::getRootContainer()->type_);
 }
 
 static void recursiveNewUserVariableType(std::string father_type, std::string new_typename, std::string color,
@@ -306,7 +313,7 @@ static void recursiveNewUserVariableType(std::string father_type, std::string ne
 
 void instr_new_user_variable_type(std::string father_type, std::string new_typename, std::string color)
 {
-  recursiveNewUserVariableType(father_type, new_typename, color, simgrid::instr::Type::getRootType());
+  recursiveNewUserVariableType(father_type, new_typename, color, simgrid::instr::Container::getRootContainer()->type_);
 }
 
 static void recursiveNewUserStateType(std::string father_type, std::string new_typename, simgrid::instr::Type* root)
@@ -320,7 +327,7 @@ static void recursiveNewUserStateType(std::string father_type, std::string new_t
 
 void instr_new_user_state_type(std::string father_type, std::string new_typename)
 {
-  recursiveNewUserStateType(father_type, new_typename, simgrid::instr::Type::getRootType());
+  recursiveNewUserStateType(father_type, new_typename, simgrid::instr::Container::getRootContainer()->type_);
 }
 
 static void recursiveNewValueForUserStateType(std::string type_name, const char* val, std::string color,
@@ -335,7 +342,7 @@ static void recursiveNewValueForUserStateType(std::string type_name, const char*
 
 void instr_new_value_for_user_state_type(std::string type_name, const char* value, std::string color)
 {
-  recursiveNewValueForUserStateType(type_name, value, color, simgrid::instr::Type::getRootType());
+  recursiveNewValueForUserStateType(type_name, value, color, simgrid::instr::Container::getRootContainer()->type_);
 }
 
 int instr_platform_traced ()
index b53c55f..2746a66 100644 (file)
@@ -12,30 +12,20 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_surf, instr, "Tracing Surf");
 void TRACE_surf_host_set_speed(double date, const char *resource, double speed)
 {
   if (TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) {
-    container_t container      = simgrid::instr::Container::byName(resource);
-    simgrid::instr::VariableType* variable =
-        static_cast<simgrid::instr::VariableType*>(container->type_->byName("power"));
-    variable->setEvent(date, container, speed);
+    simgrid::instr::Container::byName(resource)->getVariable("power")->setEvent(date, speed);
   }
 }
 
 void TRACE_surf_link_set_bandwidth(double date, const char *resource, double bandwidth)
 {
   if (TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) {
-    container_t container      = simgrid::instr::Container::byName(resource);
-    simgrid::instr::VariableType* variable =
-        static_cast<simgrid::instr::VariableType*>(container->type_->byName("bandwidth"));
-    variable->setEvent(date, container, bandwidth);
+    simgrid::instr::Container::byName(resource)->getVariable("bandwidth")->setEvent(date, bandwidth);
   }
 }
 
 void TRACE_surf_action(surf_action_t surf_action, const char *category)
 {
-  if (not TRACE_is_enabled())
-    return;
-  if (not TRACE_categorized())
-    return;
-  if (not category)
+  if (not TRACE_is_enabled() || not TRACE_categorized() || not category)
     return;
 
   surf_action->setCategory(category);