Logo AND Algorithmique Numérique Distribuée

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