Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
f7c497eafa6b34beb6da5838eb6f63f24d375bb7
[simgrid.git] / src / instr / instr_variables.c
1 /* Copyright (c) 2010. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6
7 #include "instr/instr_private.h"
8 #include "surf/surf_private.h"
9 #include "surf/network_private.h"
10
11 #ifdef HAVE_TRACING
12
13 //extern routing_global_t global_routing;
14 extern xbt_dict_t hosts_types;
15 extern xbt_dict_t links_types;
16
17 void TRACE_user_link_variable(double time, const char *src,
18                               const char *dst, const char *variable,
19                               double value, const char *what)
20 {
21   xbt_die ("deprecated");
22 //  FIXME
23 //  if (!TRACE_is_active() || !TRACE_categorized ())
24 //    return;
25 //
26 //  char valuestr[100];
27 //  snprintf(valuestr, 100, "%g", value);
28 //
29 //  if (strcmp(what, "declare") == 0) {
30 //    pajeDefineVariableType(variable, "LINK", variable);
31 //    return;
32 //  }
33 //
34 //  if (!global_routing)
35 //    return;
36 //
37 //  xbt_dynar_t route = global_routing->get_route(src, dst);
38 //  unsigned int i;
39 //  void *link_ptr;
40 //  xbt_dynar_foreach(route, i, link_ptr) {
41 //    char resource[100];
42 //    snprintf(resource, 100, "%p", link_ptr);
43 //
44 //    if (strcmp(what, "set") == 0) {
45 //      pajeSetVariable(time, variable, resource, valuestr);
46 //    } else if (strcmp(what, "add") == 0) {
47 //      pajeAddVariable(time, variable, resource, valuestr);
48 //    } else if (strcmp(what, "sub") == 0) {
49 //      pajeSubVariable(time, variable, resource, valuestr);
50 //    }
51 //  }
52 }
53
54 void TRACE_user_host_variable(double time, const char *variable,
55                               double value, const char *what)
56 {
57   if (!TRACE_is_active())
58     return;
59
60   char valuestr[100];
61   snprintf(valuestr, 100, "%g", value);
62
63   if (strcmp(what, "declare") == 0) {
64     char new_type[INSTR_DEFAULT_STR_SIZE];
65     xbt_dict_cursor_t cursor = NULL;
66     char *type;
67     void *data;
68     xbt_dict_foreach(hosts_types, cursor, type, data) {
69       snprintf (new_type, INSTR_DEFAULT_STR_SIZE, "%s-%s", variable, type);
70       pajeDefineVariableType (new_type, type, variable);
71     }
72   } else{
73     char *host_name = MSG_host_self()->name;
74     char *host_type = instr_host_type (host_name);
75     char variable_type[INSTR_DEFAULT_STR_SIZE];
76     snprintf (variable_type, INSTR_DEFAULT_STR_SIZE, "%s-%s", variable, host_type);
77
78     if (strcmp(what, "set") == 0) {
79       pajeSetVariable(time, variable_type, host_name, valuestr);
80     } else if (strcmp(what, "add") == 0) {
81       pajeAddVariable(time, variable_type, host_name, valuestr);
82     } else if (strcmp(what, "sub") == 0) {
83       pajeSubVariable(time, variable_type, host_name, valuestr);
84     }
85   }
86 }
87
88 #endif /* HAVE_TRACING */