Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
simplify link events and rename getRootContainer to getRoot
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 2 Nov 2017 09:53:38 +0000 (10:53 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 2 Nov 2017 09:53:38 +0000 (10:53 +0100)
12 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/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

index d8a3a82..5333849 100644 (file)
@@ -139,9 +139,9 @@ int TRACE_end()
     TRACE_last_timestamp_to_dump = surf_get_clock();
     TRACE_paje_dump_buffer(true);
 
-    simgrid::instr::Type* root_type = simgrid::instr::Container::getRootContainer()->type_;
+    simgrid::instr::Type* root_type = simgrid::instr::Container::getRoot()->type_;
     /* destroy all data structures of tracing (and free) */
-    delete simgrid::instr::Container::getRootContainer();
+    delete simgrid::instr::Container::getRoot();
     delete root_type;
 
     /* close the trace files */
index 09d4f04..432d0ef 100644 (file)
@@ -148,7 +148,7 @@ void TRACE_declare_mark(const char *mark_type)
   }
 
   XBT_DEBUG("MARK,declare %s", mark_type);
-  simgrid::instr::Container::getRootContainer()->type_->getOrCreateEventType(mark_type);
+  simgrid::instr::Container::getRoot()->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::Container::getRootContainer()->type_->byName(mark_type));
+      static_cast<simgrid::instr::EventType*>(simgrid::instr::Container::getRoot()->type_->byName(mark_type));
   if (not type) {
     THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type);
   } else {
@@ -235,12 +235,12 @@ 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::Container::getRootContainer()->type_->byName(mark_type));
+      static_cast<simgrid::instr::EventType*>(simgrid::instr::Container::getRoot()->type_->byName(mark_type));
   if (not type) {
     THROWF (tracing_error, 1, "mark_type with name (%s) is not declared", mark_type);
   } else {
     XBT_DEBUG("MARK %s %s", mark_type, mark_value);
-    new simgrid::instr::NewEvent(MSG_get_clock(), simgrid::instr::Container::getRootContainer(), type,
+    new simgrid::instr::NewEvent(MSG_get_clock(), simgrid::instr::Container::getRoot(), type,
                                  type->getEntityValue(mark_value));
   }
 }
index e5342cf..fc6900e 100644 (file)
@@ -27,7 +27,7 @@ long long int instr_new_paje_id ()
 namespace simgrid {
 namespace instr {
 
-container_t Container::getRootContainer()
+container_t Container::getRoot()
 {
   return rootContainer;
 }
@@ -107,7 +107,7 @@ Container::~Container()
   TRACE_paje_dump_buffer(true);
 
   // trace my destruction, but not if user requests so or if the container is root
-  if (not TRACE_disable_destroy() && this != Container::getRootContainer())
+  if (not TRACE_disable_destroy() && this != Container::getRoot())
     logDestruction();
 
   // remove me from the allContainers data structure
@@ -219,7 +219,9 @@ StateType* Container::getState(std::string name)
 
 LinkType* Container::getLink(std::string name)
 {
-  return dynamic_cast<LinkType*>(type_->byName(name));
+  LinkType* ret = dynamic_cast<LinkType*>(type_->byName(name));
+  ret->setCallingContainer(this);
+  return ret;
 }
 
 VariableType* Container::getVariable(std::string name)
index 50501ff..fe1bd00 100644 (file)
@@ -41,7 +41,7 @@ public:
   LinkType* getLink(std::string name);
   VariableType* getVariable(std::string name);
 
-  static Container* getRootContainer();
+  static Container* getRoot();
 };
 
 class NetZoneContainer : public Container {
index 5cd7683..7261a6a 100644 (file)
@@ -110,19 +110,19 @@ void VariableType::subEvent(double timestamp, double value)
 LinkType::LinkType(std::string name, std::string alias, Type* father) : ValueType(name, alias, father)
 {
 }
-void LinkType::startEvent(Container* container, container_t endpoint, std::string value, std::string key)
+void LinkType::startEvent(container_t startContainer, std::string value, std::string key)
 {
-  startEvent(container, endpoint, value, key, -1);
+  startEvent(startContainer, value, key, -1);
 }
 
-void LinkType::startEvent(Container* container, container_t endpoint, std::string value, std::string key, int size)
+void LinkType::startEvent(container_t startContainer, std::string value, std::string key, int size)
 {
-  new LinkEvent(SIMIX_get_clock(), container, this, PAJE_StartLink, endpoint, value, key, size);
+  new LinkEvent(SIMIX_get_clock(), issuer_, this, PAJE_StartLink, startContainer, value, key, size);
 }
 
-void LinkType::endEvent(Container* container, container_t endpoint, std::string value, std::string key)
+void LinkType::endEvent(container_t endContainer, std::string value, std::string key)
 {
-  new LinkEvent(SIMIX_get_clock(), container, this, PAJE_EndLink, endpoint, value, key);
+  new LinkEvent(SIMIX_get_clock(), issuer_, this, PAJE_EndLink, endContainer, value, key);
 }
 
 void Type::logDefinition(e_event_type event_type)
index a937a3d..ab5b97a 100644 (file)
@@ -23,6 +23,7 @@ class Type {
 
 public:
   std::map<std::string, Type*> children_;
+  Container* issuer_ = nullptr;
 
   Type(std::string name, std::string alias, std::string color, Type* father);
   virtual ~Type();
@@ -39,6 +40,8 @@ public:
   StateType* getOrCreateStateType(std::string name);
   VariableType* getOrCreateVariableType(std::string name, std::string color);
 
+  void setCallingContainer(Container* container) { issuer_ = container; }
+
   void logDefinition(e_event_type event_type);
   void logDefinition(Type* source, Type* dest);
 };
@@ -51,12 +54,9 @@ public:
 
 class VariableType : public Type {
   std::vector<VariableEvent*> events_;
-  Container* issuer_ = nullptr;
-
 public:
   VariableType(std::string name, std::string color, Type* father);
   ~VariableType();
-  void setCallingContainer(Container* container) { issuer_ = container; }
   void setEvent(double timestamp, double value);
   void addEvent(double timestamp, double value);
   void subEvent(double timestamp, double value);
@@ -76,10 +76,9 @@ public:
 class LinkType : public ValueType {
 public:
   LinkType(std::string name, std::string alias, Type* father);
-  void startEvent(Container* source_container, Container* sourceContainer, std::string value, std::string key);
-  void startEvent(Container* source_container, Container* sourceContainer, std::string value, std::string key,
-                  int size);
-  void endEvent(Container* source_container, Container* destContainer, std::string value, std::string key);
+  void startEvent(Container* startContainer, std::string value, std::string key);
+  void startEvent(Container* startContainer, std::string value, std::string key, int size);
+  void endEvent(Container* endContainer, std::string value, std::string key);
 };
 
 class EventType : public ValueType {
@@ -89,12 +88,9 @@ public:
 
 class StateType : public ValueType {
   std::vector<StateEvent*> events_;
-  Container* issuer_ = nullptr;
-
 public:
   StateType(std::string name, Type* father);
   ~StateType();
-  void setCallingContainer(Container* container) { issuer_ = container; }
   void setEvent(std::string value_name);
   void pushEvent(std::string value_name);
   void pushEvent(std::string value_name, void* extra);
index ceaafb2..a596982 100644 (file)
@@ -25,9 +25,8 @@ void TRACE_msg_process_change_host(msg_process_t process, msg_host_t new_host)
 
     //start link
     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);
+    simgrid::instr::LinkType* link = simgrid::instr::Container::getRoot()->getLink("MSG_PROCESS_LINK");
+    link->startEvent(msg, "M", key);
 
     //destroy existing container of this process
     TRACE_msg_process_destroy (MSG_process_get_name (process), MSG_process_get_PID (process));
@@ -37,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(root, msg, "M", key);
+    link->endEvent(msg, "M", key);
   }
 }
 
index 0e80aa9..93d6fc8 100644 (file)
@@ -92,9 +92,7 @@ void TRACE_msg_task_get_end(msg_task_t task)
     process_container->getState("MSG_PROCESS_STATE")->popEvent();
 
     std::string key = std::string("p") + std::to_string(task->counter);
-    container_t root               = simgrid::instr::Container::getRootContainer();
-    simgrid::instr::LinkType* link = root->getLink("MSG_PROCESS_TASK_LINK");
-    link->endEvent(root, process_container, "SR", key);
+    simgrid::instr::Container::getRoot()->getLink("MSG_PROCESS_TASK_LINK")->endEvent(process_container, "SR", key);
   }
 }
 
@@ -108,9 +106,7 @@ 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);
-    container_t root               = simgrid::instr::Container::getRootContainer();
-    simgrid::instr::LinkType* link = root->getLink("MSG_PROCESS_TASK_LINK");
-    link->startEvent(root, process_container, "SR", key);
+    simgrid::instr::Container::getRoot()->getLink("MSG_PROCESS_TASK_LINK")->startEvent(process_container, "SR", key);
   }
 
   return 1;
index 479da6d..ba6cbec 100644 (file)
@@ -292,9 +292,8 @@ static int migration_rx_fun(int argc, char *argv[])
     counter++;
 
     // start link
-    container_t msg            = simgrid::instr::Container::byName(vm->getName());
-    simgrid::instr::LinkType* link = simgrid::instr::Container::getRootContainer()->getLink("MSG_VM_LINK");
-    link->startEvent(simgrid::instr::Container::getRootContainer(), msg, "M", key);
+    container_t msg = simgrid::instr::Container::byName(vm->getName());
+    simgrid::instr::Container::getRoot()->getLink("MSG_VM_LINK")->startEvent(msg, "M", key);
 
     // destroy existing container of this vm
     container_t existing_container = simgrid::instr::Container::byName(vm->getName());
@@ -306,7 +305,7 @@ static int migration_rx_fun(int argc, char *argv[])
 
     // end link
     msg  = simgrid::instr::Container::byName(vm->getName());
-    link->endEvent(simgrid::instr::Container::getRootContainer(), msg, "M", key);
+    simgrid::instr::Container::getRoot()->getLink("MSG_VM_LINK")->endEvent(msg, "M", key);
   }
 
   // Inform the SRC that the migration has been correctly performed
index 89e552e..9710f2e 100644 (file)
@@ -5,22 +5,17 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include <cfloat>
-
 #include <exception>
 
 #include "colls_private.hpp"
 #include "smpi_process.hpp"
 
-
 //attempt to do a quick autotuning version of the collective,
-
 #define TRACE_AUTO_COLL(cat)                                                                                           \
   if (TRACE_is_enabled()) {                                                                                            \
-    simgrid::instr::EventType* type =                                                                                  \
-        simgrid::instr::Container::getRootContainer()->type_->getOrCreateEventType(#cat);                              \
+    simgrid::instr::EventType* type = simgrid::instr::Container::getRoot()->type_->getOrCreateEventType(#cat);         \
                                                                                                                        \
-    char cont_name[25];                                                                                                \
-    snprintf(cont_name, 25, "rank-%d", smpi_process()->index());                                                       \
+    std::string cont_name = std::string("rank-" + std::to_string(smpi_process()->index()));                            \
     type->addEntityValue(Colls::mpi_coll_##cat##_description[i].name, "1.0 1.0 1.0");                                  \
     new simgrid::instr::NewEvent(SIMIX_get_clock(), simgrid::instr::Container::byName(cont_name), type,                \
                                  type->getEntityValue(Colls::mpi_coll_##cat##_description[i].name));                   \
index 7589afa..f0b8b40 100644 (file)
@@ -158,7 +158,7 @@ void TRACE_smpi_init(int rank)
   if (TRACE_smpi_is_grouped()){
     father = simgrid::instr::Container::byNameOrNull(sg_host_self_get_name());
   }else{
-    father = simgrid::instr::Container::getRootContainer();
+    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__);
 #if HAVE_PAPI
@@ -317,10 +317,9 @@ 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 = 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);
+  container_t startContainer = simgrid::instr::Container::byName(smpi_container(rank));
+  simgrid::instr::Container::getRoot()->getLink("MPI_LINK")->startEvent(startContainer, "PTP", key, size);
 }
 
 void TRACE_smpi_recv(int src, int dst, int tag)
@@ -330,8 +329,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 = 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);
+  container_t endContainer = simgrid::instr::Container::byName(smpi_container(dst));
+  simgrid::instr::Container::getRoot()->getLink("MPI_LINK")->endEvent(endContainer, "PTP", key);
 }
index f59898f..b5d1eb8 100644 (file)
@@ -100,6 +100,7 @@ static void linkContainers(container_t src, container_t dst, std::set<std::strin
                               std::to_string(src->type_->getId()) + "-" + dst->type_->getName() +
                               std::to_string(dst->type_->getId());
   simgrid::instr::LinkType* link = father->type_->getOrCreateLinkType(link_typename, src->type_, dst->type_);
+  link->setCallingContainer(father);
 
   //register EDGE types for triva configuration
   trivaEdgeTypes.insert(link->getName());
@@ -110,8 +111,8 @@ static void linkContainers(container_t src, container_t dst, std::set<std::strin
   std::string key = std::to_string(counter);
   counter++;
 
-  link->startEvent(father, src, "topology", key);
-  link->endEvent(father, dst, "topology", key);
+  link->startEvent(src, "topology", key);
+  link->endEvent(dst, "topology", key);
 
   XBT_DEBUG("  linkContainers %s <-> %s", src->getCname(), dst->getCname());
 }
@@ -154,7 +155,7 @@ static void sg_instr_AS_begin(simgrid::s4u::NetZone& netzone)
 {
   std::string id = netzone.getName();
 
-  if (simgrid::instr::Container::getRootContainer() == nullptr) {
+  if (simgrid::instr::Container::getRoot() == nullptr) {
     simgrid::instr::NetZoneContainer* root = new simgrid::instr::NetZoneContainer(id, 0, nullptr);
 
     if (TRACE_smpi_is_enabled()) {
@@ -208,7 +209,7 @@ 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();
+  container_t root      = simgrid::instr::Container::getRoot();
 
   if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_speed())) {
     simgrid::instr::VariableType* power = container->type_->getOrCreateVariableType("power", "");
@@ -258,8 +259,8 @@ static void instr_routing_parse_end_platform ()
   currentContainer.clear();
   std::set<std::string>* filter = new std::set<std::string>;
   XBT_DEBUG ("Starting graph extraction.");
-  recursiveGraphExtraction(simgrid::s4u::Engine::getInstance()->getNetRoot(),
-                           simgrid::instr::Container::getRootContainer(), filter);
+  recursiveGraphExtraction(simgrid::s4u::Engine::getInstance()->getNetRoot(), simgrid::instr::Container::getRoot(),
+                           filter);
   XBT_DEBUG ("Graph extraction finished.");
   delete filter;
   platform_created = 1;
@@ -298,7 +299,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::Container::getRootContainer()->type_);
+  recursiveNewVariableType(new_typename, color, simgrid::instr::Container::getRoot()->type_);
 }
 
 static void recursiveNewUserVariableType(std::string father_type, std::string new_typename, std::string color,
@@ -313,7 +314,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::Container::getRootContainer()->type_);
+  recursiveNewUserVariableType(father_type, new_typename, color, simgrid::instr::Container::getRoot()->type_);
 }
 
 static void recursiveNewUserStateType(std::string father_type, std::string new_typename, simgrid::instr::Type* root)
@@ -327,7 +328,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::Container::getRootContainer()->type_);
+  recursiveNewUserStateType(father_type, new_typename, simgrid::instr::Container::getRoot()->type_);
 }
 
 static void recursiveNewValueForUserStateType(std::string type_name, const char* val, std::string color,
@@ -342,7 +343,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::Container::getRootContainer()->type_);
+  recursiveNewValueForUserStateType(type_name, value, color, simgrid::instr::Container::getRoot()->type_);
 }
 
 int instr_platform_traced ()
@@ -373,7 +374,7 @@ xbt_graph_t instr_routing_platform_graph ()
   std::map<std::string, xbt_node_t>* nodes = new std::map<std::string, xbt_node_t>;
   std::map<std::string, xbt_edge_t>* edges = new std::map<std::string, xbt_edge_t>;
   recursiveXBTGraphExtraction(ret, nodes, edges, simgrid::s4u::Engine::getInstance()->getNetRoot(),
-                              simgrid::instr::Container::getRootContainer());
+                              simgrid::instr::Container::getRoot());
   delete nodes;
   delete edges;
   return ret;