Logo AND Algorithmique Numérique Distribuée

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