Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
missing HAVE_TRACING ifdef/endif in smx_action.c
[simgrid.git] / src / instr / variables_instr.c
1 /*
2  * variables_instr.c
3  *
4  *  Created on: Feb 23, 2010
5  *      Author: Lucas Schnorr
6  *     License: This program is free software; you can redistribute
7  *              it and/or modify it under the terms of the license
8  *              (GNU LGPL) which comes with this package.
9  *
10  *     Copyright (c) 2009 The SimGrid team.
11  */
12
13 #include "instr/private.h"
14 #include "instr/config.h"
15 #include "surf/surf_private.h"
16 #include "surf/network_private.h"
17
18 #ifdef HAVE_TRACING
19
20 extern routing_t used_routing;
21
22 void __TRACE_link_variable (double time, const char *src, const char *dst, const char *variable, double value, const char *what)
23 {
24   if (!IS_TRACING || !IS_TRACING_PLATFORM) 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 (!used_routing) return;
35
36   int src_id, dst_id;
37   src_id = *(int*)xbt_dict_get(used_routing->host_id,src);
38   dst_id = *(int*)xbt_dict_get(used_routing->host_id,dst);
39   xbt_dynar_t route = used_routing->get_route(src_id, dst_id);
40
41   unsigned int i;
42   void *link_ptr;
43   xbt_dynar_foreach(route, i, link_ptr) {
44         char *link = (*(link_CM02_t)link_ptr).lmm_resource.generic_resource.name;
45
46         if (strcmp (what, "set") == 0){
47           pajeSetVariable (time, variable, link, valuestr);
48         }else if (strcmp (what, "add") == 0){
49           pajeAddVariable (time, variable, link, valuestr);
50         }else if (strcmp (what, "sub") == 0){
51           pajeSubVariable (time, variable, link, valuestr);
52         }
53   }
54 }
55
56 void __TRACE_host_variable (double time, const char *variable, double value, const char *what)
57 {
58   if (!IS_TRACING || !IS_TRACING_PLATFORM) return;
59
60   char valuestr[100];
61   snprintf (valuestr, 100, "%g", value);
62
63   if (strcmp (what, "declare") == 0){
64         pajeDefineVariableType (variable, "HOST", variable);
65   }else if (strcmp (what, "set") == 0){
66         pajeSetVariable (time, variable, MSG_host_self()->name, valuestr);
67   }else if (strcmp (what, "add") == 0){
68         pajeAddVariable (time, variable, MSG_host_self()->name, valuestr);
69   }else if (strcmp (what, "sub") == 0){
70         pajeSubVariable (time, variable, MSG_host_self()->name, valuestr);
71   }
72 }
73
74
75 #endif /* HAVE_TRACING */