1 /* Copyright (c) 2010. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "instr/instr_private.h"
8 #include "surf/surf_private.h"
9 #include "surf/network_private.h"
13 //extern routing_global_t global_routing;
14 extern xbt_dict_t hosts_types;
15 extern xbt_dict_t links_types;
17 void TRACE_user_link_variable(double time, const char *resource,
19 double value, const char *what)
21 if (!TRACE_is_active())
25 snprintf(valuestr, 100, "%g", value);
27 if (strcmp(what, "declare") == 0) {
29 //check if links have been created
30 xbt_assert1 (links_types != NULL && xbt_dict_length(links_types) != 0,
31 "%s must be called after environment creation", __FUNCTION__);
34 char new_type[INSTR_DEFAULT_STR_SIZE];
35 xbt_dict_cursor_t cursor = NULL;
38 xbt_dict_foreach(links_types, cursor, type, data) {
39 snprintf (new_type, INSTR_DEFAULT_STR_SIZE, "%s-%s", variable, type);
40 pajeDefineVariableType (new_type, type, variable);
43 char *link_type = instr_link_type (resource);
44 xbt_assert2 (link_type != NULL,
45 "link %s provided to %s is not known by the tracing mechanism", resource, __FUNCTION__);
46 char variable_type[INSTR_DEFAULT_STR_SIZE];
47 snprintf (variable_type, INSTR_DEFAULT_STR_SIZE, "%s-%s", variable, link_type);
49 if (strcmp(what, "set") == 0) {
50 pajeSetVariable(time, variable_type, resource, valuestr);
51 } else if (strcmp(what, "add") == 0) {
52 pajeAddVariable(time, variable_type, resource, valuestr);
53 } else if (strcmp(what, "sub") == 0) {
54 pajeSubVariable(time, variable_type, resource, valuestr);
59 void TRACE_user_host_variable(double time, const char *variable,
60 double value, const char *what)
62 if (!TRACE_is_active())
66 snprintf(valuestr, 100, "%g", value);
68 if (strcmp(what, "declare") == 0) {
70 //check if hosts have been created
71 xbt_assert1 (hosts_types != NULL && xbt_dict_length(hosts_types) != 0,
72 "%s must be called after environment creation", __FUNCTION__);
75 char new_type[INSTR_DEFAULT_STR_SIZE];
76 xbt_dict_cursor_t cursor = NULL;
79 xbt_dict_foreach(hosts_types, cursor, type, data) {
80 snprintf (new_type, INSTR_DEFAULT_STR_SIZE, "%s-%s", variable, type);
81 pajeDefineVariableType (new_type, type, variable);
84 char *host_name = MSG_host_self()->name;
85 char *host_type = instr_host_type (host_name);
86 char variable_type[INSTR_DEFAULT_STR_SIZE];
87 snprintf (variable_type, INSTR_DEFAULT_STR_SIZE, "%s-%s", variable, host_type);
89 if (strcmp(what, "set") == 0) {
90 pajeSetVariable(time, variable_type, host_name, valuestr);
91 } else if (strcmp(what, "add") == 0) {
92 pajeAddVariable(time, variable_type, host_name, valuestr);
93 } else if (strcmp(what, "sub") == 0) {
94 pajeSubVariable(time, variable_type, host_name, valuestr);
99 #endif /* HAVE_TRACING */