Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] adding a new structure to keep the type hierarchy of the trace
[simgrid.git] / src / instr / instr_variables.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/instr_private.h"
8 #include "surf/surf_private.h"
9 #include "surf/network_private.h"
10
11 #ifdef HAVE_TRACING
12
13 void TRACE_user_link_variable(double time, const char *resource,
14                               const char *variable,
15                               double value, const char *what)
16 {
17   if (!TRACE_is_active())
18     return;
19
20   char valuestr[100];
21   snprintf(valuestr, 100, "%g", value);
22
23   if (strcmp(what, "declare") == 0) {
24     instr_new_user_link_variable_type (variable, NULL);
25   } else{
26     char *variable_id = instr_variable_type(variable, resource);
27     char *resource_id = instr_resource_type(resource);
28     if (strcmp(what, "set") == 0) {
29       pajeSetVariable(time, variable_id, resource_id, valuestr);
30     } else if (strcmp(what, "add") == 0) {
31       pajeAddVariable(time, variable_id, resource_id, valuestr);
32     } else if (strcmp(what, "sub") == 0) {
33       pajeSubVariable(time, variable_id, resource_id, valuestr);
34     }
35   }
36 }
37
38 void TRACE_user_host_variable(double time, const char *variable,
39                               double value, const char *what)
40 {
41   if (!TRACE_is_active())
42     return;
43
44   char valuestr[100];
45   snprintf(valuestr, 100, "%g", value);
46
47   if (strcmp(what, "declare") == 0) {
48     instr_new_user_host_variable_type (variable, NULL);
49   } else{
50     char *host_name = MSG_host_self()->name;
51     char *variable_id = instr_variable_type(variable, host_name);
52     char *resource_id = instr_resource_type(host_name);
53     if (strcmp(what, "set") == 0) {
54       pajeSetVariable(time, variable_id, resource_id, valuestr);
55     } else if (strcmp(what, "add") == 0) {
56       pajeAddVariable(time, variable_id, resource_id, valuestr);
57     } else if (strcmp(what, "sub") == 0) {
58       pajeSubVariable(time, variable_id, resource_id, valuestr);
59     }
60   }
61 }
62
63 #endif /* HAVE_TRACING */