Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
608186ba7f46e23bba734a79dc84ad07ee0e2a3d
[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   xbt_assert1 (instr_platform_traced(),
21       "%s must be called after environment creation", __FUNCTION__);
22
23   char valuestr[100];
24   snprintf(valuestr, 100, "%g", value);
25
26   if (strcmp(what, "declare") == 0) {
27     instr_new_user_link_variable_type (variable, NULL);
28   } else{
29     char *variable_id = instr_variable_type(variable, resource);
30     char *resource_id = instr_resource_type(resource);
31     if (strcmp(what, "set") == 0) {
32       pajeSetVariable(time, variable_id, resource_id, valuestr);
33     } else if (strcmp(what, "add") == 0) {
34       pajeAddVariable(time, variable_id, resource_id, valuestr);
35     } else if (strcmp(what, "sub") == 0) {
36       pajeSubVariable(time, variable_id, resource_id, valuestr);
37     }
38   }
39 }
40
41 void TRACE_user_host_variable(double time, const char *variable,
42                               double value, const char *what)
43 {
44   if (!TRACE_is_active())
45     return;
46
47   xbt_assert1 (instr_platform_traced(),
48       "%s must be called after environment creation", __FUNCTION__);
49
50   char valuestr[100];
51   snprintf(valuestr, 100, "%g", value);
52
53   if (strcmp(what, "declare") == 0) {
54     instr_new_user_host_variable_type (variable, NULL);
55   } else{
56     char *host_name = MSG_host_self()->name;
57     char *variable_id = instr_variable_type(variable, host_name);
58     char *resource_id = instr_resource_type(host_name);
59     if (strcmp(what, "set") == 0) {
60       pajeSetVariable(time, variable_id, resource_id, valuestr);
61     } else if (strcmp(what, "add") == 0) {
62       pajeAddVariable(time, variable_id, resource_id, valuestr);
63     } else if (strcmp(what, "sub") == 0) {
64       pajeSubVariable(time, variable_id, resource_id, valuestr);
65     }
66   }
67 }
68
69 #endif /* HAVE_TRACING */