Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
renaming value of presence state to "presence" (to get a good time-slice value later on)
[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 "surf/surf_private.h"
15 #include "surf/network_private.h"
16
17 #ifdef HAVE_TRACING
18
19 extern routing_t used_routing;
20
21 void __TRACE_link_variable (double time, const char *src, const char *dst, const char *variable, double value, const char *what)
22 {
23   if (!IS_TRACING || !IS_TRACING_PLATFORM) return;
24
25   char valuestr[100];
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   int src_id, dst_id;
36   src_id = *(int*)xbt_dict_get(used_routing->host_id,src);
37   dst_id = *(int*)xbt_dict_get(used_routing->host_id,dst);
38   xbt_dynar_t route = used_routing->get_route(src_id, dst_id);
39
40   unsigned int i;
41   void *link_ptr;
42   xbt_dynar_foreach(route, i, link_ptr) {
43         char *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   if (!IS_TRACING || !IS_TRACING_PLATFORM) return;
58
59   char valuestr[100];
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 */