Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] adding comments to #endif's
[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
15 void TRACE_user_link_variable(double time, const char *src,
16                               const char *dst, const char *variable,
17                               double value, const char *what)
18 {
19   if (!IS_TRACING || !IS_TRACING_PLATFORM)
20     return;
21
22   char valuestr[100];
23   snprintf(valuestr, 100, "%g", value);
24
25   if (strcmp(what, "declare") == 0) {
26     pajeDefineVariableType(variable, "LINK", variable);
27     return;
28   }
29
30   if (!global_routing)
31     return;
32
33   xbt_dynar_t route = global_routing->get_route(src, dst);
34   unsigned int i;
35   void *link_ptr;
36   xbt_dynar_foreach(route, i, link_ptr) {
37     char resource[100];
38     snprintf(resource, 100, "%p", link_ptr);
39
40     if (strcmp(what, "set") == 0) {
41       pajeSetVariable(time, variable, resource, valuestr);
42     } else if (strcmp(what, "add") == 0) {
43       pajeAddVariable(time, variable, resource, valuestr);
44     } else if (strcmp(what, "sub") == 0) {
45       pajeSubVariable(time, variable, resource, valuestr);
46     }
47   }
48 }
49
50 void TRACE_user_host_variable(double time, const char *variable,
51                               double value, const char *what)
52 {
53   char valuestr[100];
54   if (!IS_TRACING || !IS_TRACING_PLATFORM)
55     return;
56
57   snprintf(valuestr, 100, "%g", value);
58
59   if (strcmp(what, "declare") == 0) {
60     pajeDefineVariableType(variable, "HOST", variable);
61   } else if (strcmp(what, "set") == 0) {
62     pajeSetVariable(time, variable, MSG_host_self()->name, valuestr);
63   } else if (strcmp(what, "add") == 0) {
64     pajeAddVariable(time, variable, MSG_host_self()->name, valuestr);
65   } else if (strcmp(what, "sub") == 0) {
66     pajeSubVariable(time, variable, MSG_host_self()->name, valuestr);
67   }
68 }
69
70 #endif /* HAVE_TRACING */