Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
pre version hierarchical routing, fix memory leak
[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_t used_routing; // COMMENTED BY DAVID
14 extern routing_global_t global_routing;
15
16 void __TRACE_link_variable (double time, const char *src, const char *dst, const char *variable, double value, const char *what)
17 {
18         char valuestr[100];
19         int src_id, dst_id;
20         xbt_dynar_t route = NULL;
21         unsigned int i;
22     void *link_ptr;
23     char *link = NULL;
24   if (!IS_TRACING || !IS_TRACING_PLATFORM) return;
25
26   snprintf (valuestr, 100, "%g", value);
27
28   if (strcmp (what, "declare") == 0){
29         pajeDefineVariableType (variable, "LINK", variable);
30         return;
31   }
32
33 //   if (!used_routing) return;
34 // 
35 //   src_id = *(int*)xbt_dict_get(used_routing->host_id,src);
36 //   dst_id = *(int*)xbt_dict_get(used_routing->host_id,dst);
37 //   route = used_routing->get_route(src_id, dst_id);
38
39   if (!global_routing) return;
40   route = global_routing->get_route(src, dst);
41   
42   xbt_dynar_foreach(route, i, link_ptr) {
43         link = (*(link_CM02_t)link_ptr).lmm_resource.generic_resource.name;
44
45         if (strcmp (what, "set") == 0){
46           pajeSetVariable (time, variable, link, valuestr);
47         }else if (strcmp (what, "add") == 0){
48           pajeAddVariable (time, variable, link, valuestr);
49         }else if (strcmp (what, "sub") == 0){
50           pajeSubVariable (time, variable, link, valuestr);
51         }
52   }
53 }
54
55 void __TRACE_host_variable (double time, const char *variable, double value, const char *what)
56 {
57         char valuestr[100];
58   if (!IS_TRACING || !IS_TRACING_PLATFORM) return;
59
60   snprintf (valuestr, 100, "%g", value);
61
62   if (strcmp (what, "declare") == 0){
63         pajeDefineVariableType (variable, "HOST", variable);
64   }else if (strcmp (what, "set") == 0){
65         pajeSetVariable (time, variable, MSG_host_self()->name, valuestr);
66   }else if (strcmp (what, "add") == 0){
67         pajeAddVariable (time, variable, MSG_host_self()->name, valuestr);
68   }else if (strcmp (what, "sub") == 0){
69         pajeSubVariable (time, variable, MSG_host_self()->name, valuestr);
70   }
71 }
72
73
74 #endif /* HAVE_TRACING */