Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
f3fe65887cec3c15e4385a11016412f3f75e6d29
[simgrid.git] / src / instr / instr_surf.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
10 #ifdef HAVE_TRACING
11
12 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_surf, instr, "Tracing Surf");
13
14 static xbt_dict_t resource_variables;   /* (host|link)#variable -> value */
15
16 void TRACE_surf_alloc(void)
17 {
18   resource_variables = xbt_dict_new();
19
20   TRACE_surf_resource_utilization_alloc();
21 }
22
23 void TRACE_surf_release(void)
24 {
25   TRACE_surf_resource_utilization_release();
26   instr_destroy_platform();
27 }
28
29 static void TRACE_surf_set_resource_variable(double date,
30                                              const char *variable,
31                                              const char *resource,
32                                              double value)
33 {
34   char value_str[INSTR_DEFAULT_STR_SIZE];
35   snprintf(value_str, 100, "%f", value);
36   pajeSetVariable(date, variable, resource, value_str);
37 }
38
39 void TRACE_surf_host_set_power(double date, const char *resource,
40                                double power)
41 {
42   if (!TRACE_is_active())
43     return;
44
45   char *host_type = instr_host_type (resource);
46   char variable_type[INSTR_DEFAULT_STR_SIZE];
47   snprintf (variable_type, INSTR_DEFAULT_STR_SIZE, "power-%s", host_type);
48
49   TRACE_surf_set_resource_variable(date, variable_type, resource, power);
50 }
51
52 void TRACE_surf_link_set_bandwidth(double date, const char *resource, double bandwidth)
53 {
54   if (!TRACE_is_active())
55     return;
56
57   char *link_type = instr_link_type (resource);
58   char variable_type[INSTR_DEFAULT_STR_SIZE];
59   snprintf (variable_type, INSTR_DEFAULT_STR_SIZE, "bandwidth-%s", link_type);
60
61   TRACE_surf_set_resource_variable(date, variable_type, resource, bandwidth);
62 }
63
64 //FIXME: this function is not used (latency availability traces support exists in surf network models?)
65 void TRACE_surf_link_set_latency(double date, const char *resource, double latency)
66 {
67   if (!TRACE_is_active())
68     return;
69
70   char *link_type = instr_link_type (resource);
71   char variable_type[INSTR_DEFAULT_STR_SIZE];
72   snprintf (variable_type, INSTR_DEFAULT_STR_SIZE, "latency-%s", link_type);
73
74   TRACE_surf_set_resource_variable(date, variable_type, resource, latency);
75 }
76
77 /* to trace gtnets */
78 void TRACE_surf_gtnets_communicate(void *action, int src, int dst)
79 {
80   xbt_die ("gtnets tracing is to be udpated");
81 }
82
83 int TRACE_surf_gtnets_get_src(void *action)
84 {
85   xbt_die ("gtnets tracing is to be udpated");
86 }
87
88 int TRACE_surf_gtnets_get_dst(void *action)
89 {
90   xbt_die ("gtnets tracing is to be udpated");
91 }
92
93 void TRACE_surf_gtnets_destroy(void *action)
94 {
95   xbt_die ("gtnets tracing is to be udpated");
96 }
97
98 void TRACE_surf_action(surf_action_t surf_action, const char *category)
99 {
100   if (!TRACE_is_active())
101     return;
102   if (!TRACE_categorized ())
103     return;
104   if (!category)
105     return;
106
107   surf_action->category = xbt_strdup(category);
108 }
109 #endif /* HAVE_TRACING */