X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e30398c22a922e2238c303852d782e00f1296115..ae5ff5ef44f3f731078a8fd8de489d7581ff8c12:/src/instr/instr_variables.c diff --git a/src/instr/instr_variables.c b/src/instr/instr_variables.c index f7c497eafa..5ffd22ffbd 100644 --- a/src/instr/instr_variables.c +++ b/src/instr/instr_variables.c @@ -14,41 +14,46 @@ extern xbt_dict_t hosts_types; extern xbt_dict_t links_types; -void TRACE_user_link_variable(double time, const char *src, - const char *dst, const char *variable, +void TRACE_user_link_variable(double time, const char *resource, + const char *variable, double value, const char *what) { - xbt_die ("deprecated"); -// FIXME -// if (!TRACE_is_active() || !TRACE_categorized ()) -// return; -// -// char valuestr[100]; -// snprintf(valuestr, 100, "%g", value); -// -// if (strcmp(what, "declare") == 0) { -// pajeDefineVariableType(variable, "LINK", variable); -// return; -// } -// -// if (!global_routing) -// return; -// -// xbt_dynar_t route = global_routing->get_route(src, dst); -// unsigned int i; -// void *link_ptr; -// xbt_dynar_foreach(route, i, link_ptr) { -// char resource[100]; -// snprintf(resource, 100, "%p", link_ptr); -// -// if (strcmp(what, "set") == 0) { -// pajeSetVariable(time, variable, resource, valuestr); -// } else if (strcmp(what, "add") == 0) { -// pajeAddVariable(time, variable, resource, valuestr); -// } else if (strcmp(what, "sub") == 0) { -// pajeSubVariable(time, variable, resource, valuestr); -// } -// } + if (!TRACE_is_active()) + return; + + char valuestr[100]; + snprintf(valuestr, 100, "%g", value); + + if (strcmp(what, "declare") == 0) { + { + //check if links have been created + xbt_assert1 (links_types != NULL && xbt_dict_length(links_types) != 0, + "%s must be called after environment creation", __FUNCTION__); + } + + char new_type[INSTR_DEFAULT_STR_SIZE]; + xbt_dict_cursor_t cursor = NULL; + char *type; + void *data; + xbt_dict_foreach(links_types, cursor, type, data) { + snprintf (new_type, INSTR_DEFAULT_STR_SIZE, "%s-%s", variable, type); + pajeDefineVariableType (new_type, type, variable); + } + } else{ + char *link_type = instr_link_type (resource); + xbt_assert2 (link_type != NULL, + "link %s provided to %s is not known by the tracing mechanism", resource, __FUNCTION__); + char variable_type[INSTR_DEFAULT_STR_SIZE]; + snprintf (variable_type, INSTR_DEFAULT_STR_SIZE, "%s-%s", variable, link_type); + + if (strcmp(what, "set") == 0) { + pajeSetVariable(time, variable_type, resource, valuestr); + } else if (strcmp(what, "add") == 0) { + pajeAddVariable(time, variable_type, resource, valuestr); + } else if (strcmp(what, "sub") == 0) { + pajeSubVariable(time, variable_type, resource, valuestr); + } + } } void TRACE_user_host_variable(double time, const char *variable, @@ -61,6 +66,12 @@ void TRACE_user_host_variable(double time, const char *variable, snprintf(valuestr, 100, "%g", value); if (strcmp(what, "declare") == 0) { + { + //check if hosts have been created + xbt_assert1 (hosts_types != NULL && xbt_dict_length(hosts_types) != 0, + "%s must be called after environment creation", __FUNCTION__); + } + char new_type[INSTR_DEFAULT_STR_SIZE]; xbt_dict_cursor_t cursor = NULL; char *type;