From 54b53a2df8af5c0502e342a8455cb75d03518d73 Mon Sep 17 00:00:00 2001 From: Lucas Schnorr Date: Mon, 11 Apr 2011 22:48:40 +0200 Subject: [PATCH] cleaning deprecated ways of tracing resource utilization details: - aka, let's generate big trace files --- src/instr/instr_config.c | 25 --- src/instr/instr_private.h | 1 - src/instr/instr_resource_utilization.c | 285 ++----------------------- src/instr/instr_smx.c | 3 - 4 files changed, 12 insertions(+), 302 deletions(-) diff --git a/src/instr/instr_config.c b/src/instr/instr_config.c index 8aad85e6bc..df4b40262a 100644 --- a/src/instr/instr_config.c +++ b/src/instr/instr_config.c @@ -21,7 +21,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_config, instr, "Configuration"); #define OPT_TRACING_MSG_PROCESS "tracing/msg/process" #define OPT_TRACING_MSG_VOLUME "tracing/msg/volume" #define OPT_TRACING_FILENAME "tracing/filename" -#define OPT_TRACING_PLATFORM_METHOD "tracing/platform/method" #define OPT_TRIVA_UNCAT_CONF "triva/uncategorized" #define OPT_TRIVA_CAT_CONF "triva/categorized" @@ -157,11 +156,6 @@ char *TRACE_get_filename(void) return xbt_cfg_get_string(_surf_cfg_set, OPT_TRACING_FILENAME); } -char *TRACE_get_platform_method(void) -{ - return xbt_cfg_get_string(_surf_cfg_set, OPT_TRACING_PLATFORM_METHOD); -} - char *TRACE_get_triva_uncat_conf (void) { return xbt_cfg_get_string(_surf_cfg_set, OPT_TRIVA_UNCAT_CONF); @@ -217,13 +211,6 @@ void TRACE_global_init(int *argc, char **argv) xbt_cfgelm_int, &default_tracing_uncategorized, 0, 1, NULL, NULL); - /* platform method */ - char *default_tracing_platform_method = xbt_strdup("a"); - xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_PLATFORM_METHOD, - "Tracing method used to register categorized resource behavior.", - xbt_cfgelm_string, &default_tracing_platform_method, 1, - 1, NULL, NULL); - /* msg task */ int default_tracing_msg_task = 0; xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_MSG_TASK, @@ -292,18 +279,6 @@ void TRACE_help (int detailed) " this simulator do not use tracing categories and resource use have to be\n" " traced.", detailed); - print_line (OPT_TRACING_PLATFORM_METHOD, "Change the resource utilization tracing method", - " It changes the way resource utilization (categorized or not) is traced\n" - " inside the simulation core. Method 'a' (default) traces all updates defined\n" - " by the CPU/network model of a given resource. Depending on the interface used\n" - " by this simulator (MSG, SMPI, SimDAG), the default method can generate large\n" - " trace files. Method 'b' tries to make smaller tracefiles using clever updates,\n" - " without losing details of resource utilization. Method 'c' generates even\n" - " smaller files by doing time integration during the simulation, but it loses\n" - " precision. If this last method is used, the smallest timeslice used in the\n" - " tracefile analysis must be bigger than the smaller resource utilization. If\n" - " unsure, do not change this option.", - detailed); print_line (OPT_TRACING_FILENAME, "Filename to register traces", " A file with this name will be created to register the simulation. The file\n" " is in the Paje format and can be analyzed using Triva or Paje visualization\n" diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index 6290b45509..4cb96590ad 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -171,7 +171,6 @@ int TRACE_msg_task_is_enabled(void); int TRACE_msg_process_is_enabled(void); int TRACE_msg_volume_is_enabled(void); char *TRACE_get_filename(void); -char *TRACE_get_platform_method(void); char *TRACE_get_triva_uncat_conf (void); char *TRACE_get_triva_cat_conf (void); void TRACE_global_init(int *argc, char **argv); diff --git a/src/instr/instr_resource_utilization.c b/src/instr/instr_resource_utilization.c index e8273e3502..a6b588502b 100644 --- a/src/instr/instr_resource_utilization.c +++ b/src/instr/instr_resource_utilization.c @@ -13,22 +13,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_resource, instr, "tracing (un)-categorize //to check if variables were previously set to 0, otherwise paje won't simulate them static xbt_dict_t platform_variables; /* host or link name -> array of categories */ -//B -static xbt_dict_t method_b_dict; - -//C -static xbt_dict_t method_c_dict; - -//resource utilization tracing method -static void (*TRACE_method_alloc) (void) = NULL; -static void (*TRACE_method_release) (void) = NULL; -static void (*TRACE_method_start) (smx_action_t action) = NULL; -static void (*TRACE_method_event) (smx_action_t action, double now, - double delta, const char *variable, - const char *resource, double value) = - NULL; -static void (*TRACE_method_end) (smx_action_t action) = NULL; - //used by all methods static void __TRACE_surf_check_variable_set_to_zero(double now, const char *variable, @@ -67,20 +51,9 @@ static void __TRACE_surf_check_variable_set_to_zero(double now, /* end of check */ } -#define A_METHOD -//A -static void __TRACE_A_alloc(void) -{ -} -static void __TRACE_A_release(void) -{ -} - -static void __TRACE_A_start(smx_action_t action) -{ -} +/* static void __TRACE_A_event(smx_action_t action, double now, double delta, const char *variable, const char *resource, double value) @@ -94,190 +67,15 @@ static void __TRACE_A_event(smx_action_t action, double now, double delta, new_pajeAddVariable(now, container, type, value); new_pajeSubVariable(now + delta, container, type, value); } +*/ -static void __TRACE_A_end(smx_action_t action) +static void instr_event (double now, double delta, type_t variable, container_t resource, double value) { + __TRACE_surf_check_variable_set_to_zero(now, variable->name, resource->name); + new_pajeAddVariable(now, resource, variable, value); + new_pajeSubVariable(now + delta, resource, variable, value); } -#define B_METHOD -//B - -static void __TRACE_B_alloc(void) -{ - method_b_dict = xbt_dict_new(); -} - -static void __TRACE_B_release(void) -{ - char *key, *time; - xbt_dict_cursor_t cursor = NULL; - xbt_dict_foreach(method_b_dict, cursor, key, time) { - char resource[INSTR_DEFAULT_STR_SIZE]; - char variable[INSTR_DEFAULT_STR_SIZE]; - char what[INSTR_DEFAULT_STR_SIZE]; - sscanf (key, "%s %s %s", resource, variable, what); - if (strcmp(what, "time")==0){ - char key_value[INSTR_DEFAULT_STR_SIZE]; - snprintf (key_value, INSTR_DEFAULT_STR_SIZE, "%s %s value", resource, variable); - char *value = xbt_dict_get_or_null (method_b_dict, key_value); - container_t container = getContainerByName (resource); - type_t type = getVariableType (variable, NULL, container->type); - new_pajeSubVariable(atof(time), container, type, atof(value)); - } - } - xbt_dict_free(&method_b_dict); -} - -static void __TRACE_B_start(smx_action_t action) -{ -} - -static void __TRACE_B_event(smx_action_t action, double now, double delta, - const char *variable, const char *resource, - double value) -{ - char key_time[INSTR_DEFAULT_STR_SIZE]; - char key_value[INSTR_DEFAULT_STR_SIZE]; - char nowstr[INSTR_DEFAULT_STR_SIZE]; - char valuestr[INSTR_DEFAULT_STR_SIZE]; - char nowdeltastr[INSTR_DEFAULT_STR_SIZE]; - - snprintf (key_time, INSTR_DEFAULT_STR_SIZE, "%s %s time", resource, variable); - snprintf (key_value, INSTR_DEFAULT_STR_SIZE, "%s %s value", resource, variable); - snprintf (nowstr, INSTR_DEFAULT_STR_SIZE, "%f", now); - snprintf (valuestr, INSTR_DEFAULT_STR_SIZE, "%f", value); - snprintf (nowdeltastr, INSTR_DEFAULT_STR_SIZE, "%f", now+delta); - - char *lasttimestr = xbt_dict_get_or_null(method_b_dict, key_time); - char *lastvaluestr = xbt_dict_get_or_null(method_b_dict, key_value); - if (lasttimestr == NULL){ - __TRACE_surf_check_variable_set_to_zero(now, variable, resource); - container_t container = getContainerByName (resource); - type_t type = getVariableType (variable, NULL, container->type); - new_pajeAddVariable(now, container, type, value); - xbt_dict_set(method_b_dict, key_time, xbt_strdup(nowdeltastr), xbt_free); - xbt_dict_set(method_b_dict, key_value, xbt_strdup(valuestr), xbt_free); - }else{ - double lasttime = atof (lasttimestr); - double lastvalue = atof (lastvaluestr); - - if (lastvalue == value){ - double dif = fabs(now - lasttime); - if (dif < 0.000001){ - //perfect, just go on - }else{ - //time changed, have to update - container_t container = getContainerByName (resource); - type_t type = getVariableType (variable, NULL, container->type); - new_pajeSubVariable(lasttime, container, type, lastvalue); - new_pajeAddVariable(now, container, type, value); - } - }else{ - //value changed, have to update - container_t container = getContainerByName (resource); - type_t type = getVariableType (variable, NULL, container->type); - new_pajeSubVariable(lasttime, container, type, lastvalue); - new_pajeAddVariable(now, container, type, value); - } - xbt_dict_set(method_b_dict, key_time, xbt_strdup(nowdeltastr), xbt_free); - xbt_dict_set(method_b_dict, key_value, xbt_strdup(valuestr), xbt_free); - } - return; -} - -static void __TRACE_B_end(smx_action_t action) -{ -} - -#define C_METHOD -//C -static void __TRACE_C_alloc(void) -{ - method_c_dict = xbt_dict_new(); -} - -static void __TRACE_C_release(void) -{ - xbt_dict_free(&method_c_dict); -} - -static void __TRACE_C_start(smx_action_t action) -{ - char key[100]; - snprintf(key, 100, "%p", action); - - //check if exists - if (xbt_dict_get_or_null(method_c_dict, key)) { - xbt_dict_remove(method_c_dict, key); //should never execute here, but it does - } - xbt_dict_set(method_c_dict, key, xbt_dict_new(), xbt_free); -} - -static void __TRACE_C_event(smx_action_t action, double now, double delta, - const char *variable, const char *resource, - double value) -{ - char key[100]; - snprintf(key, 100, "%p", action); - - xbt_dict_t action_dict = xbt_dict_get(method_c_dict, key); - //setting start time - if (!xbt_dict_get_or_null(action_dict, "start")) { - char start_time[100]; - snprintf(start_time, 100, "%f", now); - xbt_dict_set(action_dict, "start", xbt_strdup(start_time), xbt_free); - } - //updating end time - char end_time[100]; - snprintf(end_time, 100, "%f", now + delta); - xbt_dict_set(action_dict, "end", xbt_strdup(end_time), xbt_free); - - //accumulate the value resource-variable - char res_var[300]; - snprintf(res_var, 300, "%s %s", resource, variable); - double current_value_f; - char *current_value = xbt_dict_get_or_null(action_dict, res_var); - if (current_value) { - current_value_f = atof(current_value); - current_value_f += value * delta; - } else { - current_value_f = value * delta; - } - char new_current_value[100]; - snprintf(new_current_value, 100, "%f", current_value_f); - xbt_dict_set(action_dict, res_var, xbt_strdup(new_current_value), - xbt_free); -} - -static void __TRACE_C_end(smx_action_t action) -{ - char key[100]; - snprintf(key, 100, "%p", action); - - xbt_dict_t action_dict = xbt_dict_get(method_c_dict, key); - double start_time = atof(xbt_dict_get(action_dict, "start")); - double end_time = atof(xbt_dict_get(action_dict, "end")); - - xbt_dict_cursor_t cursor = NULL; - char *action_dict_key, *action_dict_value; - xbt_dict_foreach(action_dict, cursor, action_dict_key, action_dict_value) { - char resource[100], variable[100]; - if (sscanf(action_dict_key, "%s %s", resource, variable) != 2) - continue; - __TRACE_surf_check_variable_set_to_zero(start_time, variable, - resource); - if (end_time - start_time != 0) { - container_t container = getContainerByName (resource); - type_t type = getVariableType (variable, NULL, container->type); - double val = atof(action_dict_value) / (end_time - start_time); - new_pajeSubVariable(start_time, container, type, val); - new_pajeAddVariable(end_time, container, type, val); - } - } - xbt_dict_remove(method_c_dict, key); -} - -#define RESOURCE_UTILIZATION_INTERFACE /* * TRACE_surf_link_set_utilization: entry point from SimGrid */ @@ -301,7 +99,7 @@ void TRACE_surf_link_set_utilization(const char *resource, smx_action_t smx_acti XBT_DEBUG("UNCAT LINK [%f - %f] %s bandwidth_used %f", now, now+delta, resource, value); container_t container = getContainerByName (resource); type_t type = getVariableType("bandwidth_used", NULL, container->type); - TRACE_surf_resource_utilization_event(smx_action, now, delta, type->name, container->name, value); + instr_event (now, delta, type, container, value); } //trace categorized utilization @@ -314,7 +112,7 @@ void TRACE_surf_link_set_utilization(const char *resource, smx_action_t smx_acti XBT_DEBUG("CAT LINK [%f - %f] %s %s %f", now, now+delta, resource, category_type, value); container_t container = getContainerByName (resource); type_t type = getVariableType(category_type, NULL, container->type); - TRACE_surf_resource_utilization_event(smx_action, now, delta, type->name, container->name, value); + instr_event (now, delta, type, container, value); } return; } @@ -341,7 +139,7 @@ void TRACE_surf_host_set_utilization(const char *resource, XBT_DEBUG("UNCAT HOST [%f - %f] %s power_used %f", now, now+delta, resource, value); container_t container = getContainerByName (resource); type_t type = getVariableType("power_used", NULL, container->type); - TRACE_surf_resource_utilization_event(smx_action, now, delta, type->name, container->name, value); + instr_event (now, delta, type, container, value); } //trace categorized utilization @@ -354,76 +152,17 @@ void TRACE_surf_host_set_utilization(const char *resource, XBT_DEBUG("CAT HOST [%f - %f] %s %s %f", now, now+delta, resource, category_type, value); container_t container = getContainerByName (resource); type_t type = getVariableType(category_type, NULL, container->type); - TRACE_surf_resource_utilization_event(smx_action, now, delta, type->name, container->name, value); + instr_event (now, delta, type, container, value); } return; } -/* - * __TRACE_surf_resource_utilization_*: entry points from tracing functions - */ -void TRACE_surf_resource_utilization_start(smx_action_t action) -{ - if (!TRACE_is_active()) - return; - XBT_DEBUG("START %p", action); - TRACE_method_start(action); -} - -void TRACE_surf_resource_utilization_event(smx_action_t action, double now, - double delta, - const char *variable, - const char *resource, - double value) -{ - if (!TRACE_is_active()) - return; - XBT_DEBUG("EVENT %p [%f - %f] %s %s %f", action, now, now+delta, resource, variable, value); - TRACE_method_event(action, now, delta, variable, resource, value); -} - -void TRACE_surf_resource_utilization_end(smx_action_t action) +void TRACE_surf_resource_utilization_alloc() { - if (!TRACE_is_active()) - return; - TRACE_method_end(action); - XBT_DEBUG("END %p", action); + platform_variables = xbt_dict_new(); } void TRACE_surf_resource_utilization_release() { - if (!TRACE_is_active()) - return; - TRACE_method_release(); -} - -static void __TRACE_define_method(char *method) -{ - if (!strcmp(method, "a")) { - TRACE_method_alloc = __TRACE_A_alloc; - TRACE_method_release = __TRACE_A_release; - TRACE_method_start = __TRACE_A_start; - TRACE_method_event = __TRACE_A_event; - TRACE_method_end = __TRACE_A_end; - } else if (!strcmp(method, "c")) { - TRACE_method_alloc = __TRACE_C_alloc; - TRACE_method_release = __TRACE_C_release; - TRACE_method_start = __TRACE_C_start; - TRACE_method_event = __TRACE_C_event; - TRACE_method_end = __TRACE_C_end; - } else { //default is B - TRACE_method_alloc = __TRACE_B_alloc; - TRACE_method_release = __TRACE_B_release; - TRACE_method_start = __TRACE_B_start; - TRACE_method_event = __TRACE_B_event; - TRACE_method_end = __TRACE_B_end; - } -} - -void TRACE_surf_resource_utilization_alloc() -{ - platform_variables = xbt_dict_new(); - __TRACE_define_method(TRACE_get_platform_method()); - TRACE_method_alloc(); } #endif /* HAVE_TRACING */ diff --git a/src/instr/instr_smx.c b/src/instr/instr_smx.c index 9ead4a28bb..c9c0bb9b0b 100644 --- a/src/instr/instr_smx.c +++ b/src/instr/instr_smx.c @@ -13,21 +13,18 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_simix, instr, "Tracing Simix"); void TRACE_smx_host_execute(smx_action_t act) { if (!TRACE_is_active()) return; - TRACE_surf_resource_utilization_start(act); return; } void TRACE_smx_action_communicate(smx_action_t act, smx_process_t proc) { if (!TRACE_is_active()) return; - TRACE_surf_resource_utilization_start(act); return; } void TRACE_smx_action_destroy(smx_action_t act) { if (!TRACE_is_active()) return; - TRACE_surf_resource_utilization_end(act); return; } -- 2.20.1