From: Frederic Suter Date: Thu, 3 Aug 2017 11:39:13 +0000 (+0200) Subject: 4 functions and a callback for one dict... seriously?! X-Git-Tag: v3_17~272 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f8a7ee5550baeac116375b64ea445aaed605f743 4 functions and a callback for one dict... seriously?! --- diff --git a/src/include/instr/instr_interface.h b/src/include/instr/instr_interface.h index 4e6ff0b414..a3262e054a 100644 --- a/src/include/instr/instr_interface.h +++ b/src/include/instr/instr_interface.h @@ -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() diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index f1f3ce2eb2..411595279c 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -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 (); diff --git a/src/instr/instr_resource_utilization.cpp b/src/instr/instr_resource_utilization.cpp index 3135882228..562a628b0e 100644 --- a/src/instr/instr_resource_utilization.cpp +++ b/src/instr/instr_resource_utilization.cpp @@ -5,11 +5,12 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "src/instr/instr_private.h" +#include 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 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); -} diff --git a/src/msg/msg_global.cpp b/src/msg/msg_global.cpp index 4a0509d674..f2f926b0bc 100644 --- a/src/msg/msg_global.cpp +++ b/src/msg/msg_global.cpp @@ -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; diff --git a/src/surf/instr_surf.cpp b/src/surf/instr_surf.cpp index df986ab2ad..4d45aa1169 100644 --- a/src/surf/instr_surf.cpp +++ b/src/surf/instr_surf.cpp @@ -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()) { diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 8c3c1069cf..d5e7d0230a 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -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())