Logo AND Algorithmique Numérique Distribuée

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