Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
4 functions and a callback for one dict... seriously?!
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 3 Aug 2017 11:39:13 +0000 (13:39 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 3 Aug 2017 11:39:13 +0000 (13:39 +0200)
src/include/instr/instr_interface.h
src/include/surf/surf.h
src/instr/instr_resource_utilization.cpp
src/msg/msg_global.cpp
src/surf/instr_surf.cpp
src/surf/surf_interface.cpp

index 4e6ff0b..a3262e0 100644 (file)
@@ -14,8 +14,6 @@ XBT_PUBLIC(int) TRACE_start ();
 XBT_PUBLIC(int) TRACE_end ();
 XBT_PUBLIC(void) TRACE_global_init();
 XBT_PUBLIC(void) TRACE_help(int detailed);
-XBT_PUBLIC(void) TRACE_surf_resource_utilization_alloc();
-XBT_PUBLIC(void) TRACE_surf_resource_utilization_release();
 
 SG_END_DECL()
 
index f1f3ce2..4115952 100644 (file)
@@ -434,8 +434,6 @@ const char *__surf_get_initial_path();
 /********** Tracing **********/
 /* from surf_instr.c */
 void TRACE_surf_action(surf_action_t surf_action, const char *category);
-void TRACE_surf_alloc();
-void TRACE_surf_release();
 
 /* instr_routing.c */
 void instr_routing_define_callbacks ();
index 3135882..562a628 100644 (file)
@@ -5,11 +5,12 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "src/instr/instr_private.h"
+#include <unordered_map>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_resource, instr, "tracing (un)-categorized resource utilization");
 
 //to check if variables were previously set to 0, otherwise paje won't simulate them
-static xbt_dict_t platform_variables;
+static std::unordered_map<std::string, std::string> platform_variables;
 
 //used by all methods
 static void __TRACE_surf_check_variable_set_to_zero(double now, const char *variable, const char *resource)
@@ -21,18 +22,15 @@ static void __TRACE_surf_check_variable_set_to_zero(double now, const char *vari
    */
 
   // create a key considering the resource and variable
-  int n = strlen(variable)+strlen(resource)+1;
-  char *key = (char*)xbt_malloc(n*sizeof(char));
-  snprintf (key, n, "%s%s", resource, variable);
+  std::string key = std::string(resource) + variable;
 
   // check if key exists: if it doesn't, set the variable to zero and mark this in the dict
-  if (not xbt_dict_get_or_null(platform_variables, key)) {
+  if (platform_variables.find(key) == platform_variables.end()) {
     container_t container = PJ_container_get (resource);
     type_t type = PJ_type_get (variable, container->type);
     new SetVariableEvent (now, container, type, 0);
-    xbt_dict_set(platform_variables, key, (char*)"", nullptr);
+    platform_variables[key] = std::string("");
   }
-  xbt_free(key);
 }
 
 static void instr_event (double now, double delta, type_t variable, container_t resource, double value)
@@ -100,13 +98,3 @@ void TRACE_surf_host_set_utilization(const char *resource, const char *category,
     instr_event (now, delta, type, container, value);
   }
 }
-
-void TRACE_surf_resource_utilization_alloc()
-{
-  platform_variables = xbt_dict_new_homogeneous(nullptr);
-}
-
-void TRACE_surf_resource_utilization_release()
-{
-  xbt_dict_free(&platform_variables);
-}
index 4a0509d..f2f926b 100644 (file)
@@ -113,7 +113,6 @@ static void MSG_exit() {
   if (msg_global==nullptr)
     return;
 
-  TRACE_surf_resource_utilization_release();
   TRACE_end();
   delete msg_global;
   msg_global = nullptr;
index df986ab..4d45aa1 100644 (file)
@@ -9,16 +9,6 @@
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_surf, instr, "Tracing Surf");
 
-void TRACE_surf_alloc()
-{
-  TRACE_surf_resource_utilization_alloc();
-}
-
-void TRACE_surf_release()
-{
-  TRACE_surf_resource_utilization_release();
-}
-
 void TRACE_surf_host_set_speed(double date, const char *resource, double speed)
 {
   if (TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) {
index 8c3c106..d5e7d02 100644 (file)
@@ -348,9 +348,6 @@ void surf_init(int *argc, char **argv)
   if (not future_evt_set)
     future_evt_set = new simgrid::trace_mgr::future_evt_set();
 
-  TRACE_surf_alloc();
-  simgrid::surf::surfExitCallbacks.connect(TRACE_surf_release);
-
   sg_config_init(argc, argv);
 
   if (MC_is_active())