From: schnorr Date: Mon, 13 Dec 2010 16:44:56 +0000 (+0000) Subject: [trace] new field id to make the final trace file smaller X-Git-Tag: v3.6_beta2~735 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/8043ee1afeda012d6eccef4cfe31faa3f784aa41 [trace] new field id to make the final trace file smaller details: - instr_id (resource_name) gives the right alias git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9188 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index 47920312f5..d3e7355f0f 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -183,6 +183,7 @@ void instr_routing_define_callbacks (void); int instr_link_is_traced (const char *name); char *instr_link_type (const char *name); char *instr_host_type (const char *name); +char *instr_id (const char *name); void instr_destroy_platform (void); #endif /* HAVE_TRACING */ diff --git a/src/instr/instr_resource_utilization.c b/src/instr/instr_resource_utilization.c index 96d21b2af3..38a7a7aa3c 100644 --- a/src/instr/instr_resource_utilization.c +++ b/src/instr/instr_resource_utilization.c @@ -370,7 +370,7 @@ void TRACE_surf_resource_utilization_event(smx_action_t action, double now, if (!TRACE_is_active()) return; DEBUG6("EVENT %p [%f - %f] %s %s %f", action, now, now+delta, resource, variable, value); - TRACE_method_event(action, now, delta, variable, resource, value); + TRACE_method_event(action, now, delta, variable, instr_id(resource), value); } void TRACE_surf_resource_utilization_end(smx_action_t action) diff --git a/src/instr/instr_routing.c b/src/instr/instr_routing.c index 8678d4399c..037c934816 100644 --- a/src/instr/instr_routing.c +++ b/src/instr/instr_routing.c @@ -23,7 +23,8 @@ typedef enum { typedef struct s_container *container_t; typedef struct s_container { - char *name; /* Unique id of this container */ + char *name; /* Unique name of this container */ + char *id; /* Unique id of this container */ char *type; /* Type of this container */ char *typename; /* Type name of this container */ int level; /* Level in the hierarchy, root level is 0 */ @@ -107,11 +108,21 @@ void instr_routing_define_callbacks () surfxml_add_callback(ETag_surfxml_platform_cb_list, &instr_routing_parse_end_platform); } +static long long int newContainedId () +{ + static long long counter = 0; + return counter++; +} static container_t newContainer (const char *name, const char *type, e_container_types kind) { + long long int counter = newContainedId(); + char id_str[INSTR_DEFAULT_STR_SIZE]; + snprintf (id_str, INSTR_DEFAULT_STR_SIZE, "%lld", counter); + container_t newContainer = xbt_new0(s_container_t, 1); newContainer->name = xbt_strdup (name); + newContainer->id = xbt_strdup (id_str); newContainer->father = xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1); newContainer->level = newContainer->father->level+1; newContainer->type = xbt_strdup (type); @@ -127,7 +138,7 @@ static container_t newContainer (const char *name, const char *type, e_container xbt_dict_set(newContainer->father->children, newContainer->name, newContainer, NULL); newContainerType (newContainer->type, newContainer->father->type, newContainer->typename); - pajeCreateContainer (0, newContainer->name, newContainer->type, newContainer->father->name, newContainer->name); + pajeCreateContainer (0, newContainer->id, newContainer->type, newContainer->father->id, newContainer->name); return newContainer; } @@ -141,9 +152,10 @@ static void recursiveDestroyContainer (container_t container) recursiveDestroyContainer (child); } - pajeDestroyContainer(SIMIX_get_clock(), container->type, container->name); + pajeDestroyContainer(SIMIX_get_clock(), container->type, container->id); xbt_free (container->name); + xbt_free (container->id); xbt_free (container->type); xbt_free (container->children); xbt_free (container); @@ -156,9 +168,11 @@ static void linkContainers (container_t container, const char *a1, const char *a if (strcmp (a1, "__loopback__") == 0 || strcmp (a2, "__loopback__") == 0) return; + char *a1_id = ((container_t)xbt_dict_get (allContainers, a1))->id; char *a1_type = ((container_t)xbt_dict_get (allContainers, a1))->type; char *a1_typename = ((container_t)xbt_dict_get (allContainers, a1))->typename; + char *a2_id = ((container_t)xbt_dict_get (allContainers, a2))->id; char *a2_type = ((container_t)xbt_dict_get (allContainers, a2))->type; char *a2_typename = ((container_t)xbt_dict_get (allContainers, a2))->typename; @@ -171,9 +185,9 @@ static void linkContainers (container_t container, const char *a1, const char *a //create the link static long long counter = 0; char key[INSTR_DEFAULT_STR_SIZE]; - snprintf (key, INSTR_DEFAULT_STR_SIZE, "G%lld", counter++); - pajeStartLink(SIMIX_get_clock(), new_link_type, container->name, "graph", a1, key); - pajeEndLink(SIMIX_get_clock(), new_link_type, container->name, "graph", a2, key); + snprintf (key, INSTR_DEFAULT_STR_SIZE, "%lld", counter++); + pajeStartLink(SIMIX_get_clock(), new_link_type, container->id, "G", a1_id, key); + pajeEndLink(SIMIX_get_clock(), new_link_type, container->id, "G", a2_id, key); } static void recursiveGraphExtraction (container_t container) @@ -254,6 +268,7 @@ static void instr_routing_parse_start_AS () if (rootContainer == NULL){ rootContainer = xbt_new0(s_container_t, 1); rootContainer->name = xbt_strdup ("0"); + rootContainer->id = xbt_strdup (rootContainer->name); rootContainer->type = xbt_strdup ("0"); rootContainer->typename = xbt_strdup ("0"); rootContainer->level = 0; @@ -269,8 +284,13 @@ static void instr_routing_parse_start_AS () links_types = xbt_dict_new (); } + long long int counter = newContainedId(); + char id_str[INSTR_DEFAULT_STR_SIZE]; + snprintf (id_str, INSTR_DEFAULT_STR_SIZE, "%lld", counter); + container_t newContainer = xbt_new0(s_container_t, 1); newContainer->name = xbt_strdup (A_surfxml_AS_id); + newContainer->id = xbt_strdup (id_str); newContainer->father = xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1); newContainer->level = newContainer->father->level+1; newContainer->type = instr_AS_type (newContainer->level); @@ -281,7 +301,7 @@ static void instr_routing_parse_start_AS () //trace newContainerType (newContainer->type, newContainer->father->type, newContainer->type); - pajeCreateContainer (0, newContainer->name, newContainer->type, newContainer->father->name, newContainer->name); + pajeCreateContainer (0, newContainer->id, newContainer->type, newContainer->father->id, newContainer->name); //push xbt_dynar_push (currentContainer, newContainer); @@ -305,8 +325,8 @@ static void instr_routing_parse_start_link () snprintf (latency_type, INSTR_DEFAULT_STR_SIZE, "latency-%s", type); newVariableType (bandwidth_type, type, "bandwidth", NULL); newVariableType (latency_type, type, "latency", NULL); - pajeSetVariable(0, bandwidth_type, new->name, A_surfxml_link_bandwidth); - pajeSetVariable(0, latency_type, new->name, A_surfxml_link_latency); + pajeSetVariable(0, bandwidth_type, new->id, A_surfxml_link_bandwidth); + pajeSetVariable(0, latency_type, new->id, A_surfxml_link_latency); if (TRACE_uncategorized()){ //bandwidth_used @@ -337,7 +357,7 @@ static void instr_routing_parse_start_host () char power_type[INSTR_DEFAULT_STR_SIZE]; snprintf (power_type, INSTR_DEFAULT_STR_SIZE, "power-%s", type); newVariableType (power_type, type, "power", NULL); - pajeSetVariable(0, power_type, new->name, A_surfxml_host_power); + pajeSetVariable(0, power_type, new->id, A_surfxml_host_power); if (TRACE_uncategorized()){ //power_used @@ -400,6 +420,11 @@ char *instr_host_type (const char *name) return ((container_t)xbt_dict_get (allContainers, name))->type; } +char *instr_id (const char *name) +{ + return ((container_t)xbt_dict_get (allContainers, name))->id; +} + void instr_destroy_platform () { if (rootContainer) recursiveDestroyContainer (rootContainer); diff --git a/src/instr/instr_surf.c b/src/instr/instr_surf.c index 87e0911e34..bc68f28544 100644 --- a/src/instr/instr_surf.c +++ b/src/instr/instr_surf.c @@ -29,7 +29,7 @@ static void TRACE_surf_set_resource_variable(double date, { char value_str[INSTR_DEFAULT_STR_SIZE]; snprintf(value_str, 100, "%f", value); - pajeSetVariable(date, variable, resource, value_str); + pajeSetVariable(date, variable, instr_id(resource), value_str); } void TRACE_surf_host_set_power(double date, const char *resource, double power) diff --git a/src/instr/instr_variables.c b/src/instr/instr_variables.c index 5ffd22ffbd..5c3d1fe728 100644 --- a/src/instr/instr_variables.c +++ b/src/instr/instr_variables.c @@ -47,11 +47,11 @@ void TRACE_user_link_variable(double time, const char *resource, snprintf (variable_type, INSTR_DEFAULT_STR_SIZE, "%s-%s", variable, link_type); if (strcmp(what, "set") == 0) { - pajeSetVariable(time, variable_type, resource, valuestr); + pajeSetVariable(time, variable_type, instr_id(resource), valuestr); } else if (strcmp(what, "add") == 0) { - pajeAddVariable(time, variable_type, resource, valuestr); + pajeAddVariable(time, variable_type, instr_id(resource), valuestr); } else if (strcmp(what, "sub") == 0) { - pajeSubVariable(time, variable_type, resource, valuestr); + pajeSubVariable(time, variable_type, instr_id(resource), valuestr); } } } @@ -87,11 +87,11 @@ void TRACE_user_host_variable(double time, const char *variable, snprintf (variable_type, INSTR_DEFAULT_STR_SIZE, "%s-%s", variable, host_type); if (strcmp(what, "set") == 0) { - pajeSetVariable(time, variable_type, host_name, valuestr); + pajeSetVariable(time, variable_type, instr_id(host_name), valuestr); } else if (strcmp(what, "add") == 0) { - pajeAddVariable(time, variable_type, host_name, valuestr); + pajeAddVariable(time, variable_type, instr_id(host_name), valuestr); } else if (strcmp(what, "sub") == 0) { - pajeSubVariable(time, variable_type, host_name, valuestr); + pajeSubVariable(time, variable_type, instr_id(host_name), valuestr); } } }