Logo AND Algorithmique Numérique Distribuée

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