Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] uncategorized resource tracing option is independent from categorized, and...
[simgrid.git] / src / instr / instr_config.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
8 #include "instr/instr_private.h"
9
10 #ifdef HAVE_TRACING
11
12 #define OPT_TRACING               "tracing"
13 #define OPT_TRACING_SMPI          "tracing/smpi"
14 #define OPT_TRACING_SMPI_GROUP    "tracing/smpi/group"
15 #define OPT_TRACING_PLATFORM      "tracing/platform"
16 #define OPT_TRACING_UNCATEGORIZED "tracing/uncategorized"
17 #define OPT_TRACING_MSG_TASK      "tracing/msg/task"
18 #define OPT_TRACING_MSG_PROCESS   "tracing/msg/process"
19 #define OPT_TRACING_MSG_VOLUME    "tracing/msg/volume"
20 #define OPT_TRACING_FILENAME      "tracing/filename"
21 #define OPT_TRACING_PLATFORM_METHOD "tracing/platform/method"
22
23 static int trace_configured = 0;
24 static int trace_active = 0;
25
26 void TRACE_activate (void)
27 {
28   if (trace_active){
29     THROW0(tracing_error, TRACE_ERROR_ALREADY_ACTIVE,
30            "Tracing is already active.");
31   }
32   trace_active = 1;
33 }
34
35 void TRACE_desactivate (void)
36 {
37   trace_active = 0;
38 }
39
40 int TRACE_is_active (void)
41 {
42   return trace_active;
43 }
44
45 int TRACE_is_enabled(void)
46 {
47   return xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING);
48 }
49
50 int TRACE_is_configured(void)
51 {
52   return trace_configured;
53 }
54
55 int TRACE_smpi_is_enabled(void)
56 {
57   return xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_SMPI);
58 }
59
60 int TRACE_smpi_is_grouped(void)
61 {
62   return xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_SMPI_GROUP);
63 }
64
65 int TRACE_platform_is_enabled(void)
66 {
67   return xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_PLATFORM);
68 }
69
70 int TRACE_uncategorized (void)
71 {
72   return xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_UNCATEGORIZED);
73 }
74
75 int TRACE_msg_task_is_enabled(void)
76 {
77   return xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_MSG_TASK);
78 }
79
80 int TRACE_msg_process_is_enabled(void)
81 {
82   return xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_MSG_PROCESS);
83 }
84
85 int TRACE_msg_volume_is_enabled(void)
86 {
87   return xbt_cfg_get_int(_surf_cfg_set, OPT_TRACING_MSG_VOLUME);
88 }
89
90 char *TRACE_get_filename(void)
91 {
92   return xbt_cfg_get_string(_surf_cfg_set, OPT_TRACING_FILENAME);
93 }
94
95 char *TRACE_get_platform_method(void)
96 {
97   return xbt_cfg_get_string(_surf_cfg_set, OPT_TRACING_PLATFORM_METHOD);
98 }
99
100 void TRACE_global_init(int *argc, char **argv)
101 {
102   /* name of the tracefile */
103   char *default_tracing_filename = xbt_strdup("simgrid.trace");
104   xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_FILENAME,
105                    "Trace file created by the instrumented SimGrid.",
106                    xbt_cfgelm_string, &default_tracing_filename, 1, 1,
107                    NULL, NULL);
108
109   /* tracing */
110   int default_tracing = 0;
111   xbt_cfg_register(&_surf_cfg_set, OPT_TRACING,
112                    "Enable Tracing.",
113                    xbt_cfgelm_int, &default_tracing, 0, 1,
114                    NULL, NULL);
115
116   /* smpi */
117   int default_tracing_smpi = 0;
118   xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_SMPI,
119                    "Tracing of the SMPI interface.",
120                    xbt_cfgelm_int, &default_tracing_smpi, 0, 1,
121                    NULL, NULL);
122
123   /* smpi grouped */
124   int default_tracing_smpi_grouped = 0;
125   xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_SMPI_GROUP,
126                    "Group MPI processes by host.",
127                    xbt_cfgelm_int, &default_tracing_smpi_grouped, 0, 1,
128                    NULL, NULL);
129
130
131   /* platform */
132   int default_tracing_platform = 0;
133   xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_PLATFORM,
134                    "Tracing of categorized platform (host and link) utilization.",
135                    xbt_cfgelm_int, &default_tracing_platform, 0, 1,
136                    NULL, NULL);
137
138   /* tracing uncategorized resource utilization */
139   int default_tracing_uncategorized = 0;
140   xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_UNCATEGORIZED,
141                    "Tracing of uncategorized resource (host and link) utilization.",
142                    xbt_cfgelm_int, &default_tracing_uncategorized, 0, 1,
143                    NULL, NULL);
144
145   /* platform method */
146   char *default_tracing_platform_method = xbt_strdup("a");
147   xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_PLATFORM_METHOD,
148                    "Tracing method used to register categorized resource behavior.",
149                    xbt_cfgelm_string, &default_tracing_platform_method, 1,
150                    1, NULL, NULL);
151
152   /* msg task */
153   int default_tracing_msg_task = 0;
154   xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_MSG_TASK,
155                    "Tracing of MSG task behavior.",
156                    xbt_cfgelm_int, &default_tracing_msg_task, 0, 1,
157                    NULL, NULL);
158
159   /* msg process */
160   int default_tracing_msg_process = 0;
161   xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_MSG_PROCESS,
162                    "Tracing of MSG process behavior.",
163                    xbt_cfgelm_int, &default_tracing_msg_process, 0, 1,
164                    NULL, NULL);
165
166   /* msg volume (experimental) */
167   int default_tracing_msg_volume = 0;
168   xbt_cfg_register(&_surf_cfg_set, OPT_TRACING_MSG_VOLUME,
169                    "Tracing of MSG communication volume (experimental).",
170                    xbt_cfgelm_int, &default_tracing_msg_volume, 0, 1,
171                    NULL, NULL);
172
173   /* instrumentation can be considered configured now */
174   trace_configured = 1;
175 }
176
177 static void print_line (const char *option, const char *desc, const char *longdesc, int detailed)
178 {
179   char str[INSTR_DEFAULT_STR_SIZE];
180   snprintf (str, INSTR_DEFAULT_STR_SIZE, "--cfg=%s ", option);
181
182   int len = strlen (str);
183   printf ("%s%*.*s %s\n", str, 30-len, 30-len, "", desc);
184   if (!!longdesc && detailed){
185     printf ("%s\n\n", longdesc);
186   }
187 }
188
189 void TRACE_help (int detailed)
190 {
191   printf(
192       "Description of the tracing options accepted by this simulator:\n\n");
193   print_line (OPT_TRACING, "Enable the tracing system",
194       "  It activates the tracing system and register the simulation platform\n"
195       "  in the trace file. You have to enable this option to others take effect.",
196       detailed);
197   print_line (OPT_TRACING_PLATFORM, "Trace categorized resource utilization",
198       "  It activates the categorized resource utilization tracing. It should\n"
199       "  be enabled if tracing categories are used by this simulator.",
200       detailed);
201   print_line (OPT_TRACING_UNCATEGORIZED, "Trace uncategorized resource utilization",
202       "  It activates the uncategorized resource utilization tracing. Use it if\n"
203       "  this simulator do not use tracing categories and resource use have to be\n"
204       "  traced.",
205       detailed);
206   print_line (OPT_TRACING_PLATFORM_METHOD, "Change the resource utilization tracing method",
207       "  It changes the way resource utilization (categorized or not) is traced\n"
208       "  inside the simulation core. Method 'a' (default) traces all updates defined\n"
209       "  by the CPU/network model of a given resource. Depending on the interface used\n"
210       "  by this simulator (MSG, SMPI, SimDAG), the default method can generate large\n"
211       "  trace files. Method 'b' tries to make smaller tracefiles using clever updates,\n"
212       "  without losing details of resource utilization. Method 'c' generates even\n"
213       "  smaller files by doing time integration during the simulation, but it loses\n"
214       "  precision. If this last method is used, the smallest timeslice used in the\n"
215       "  tracefile analysis must be bigger than the smaller resource utilization. If\n"
216       "  unsure, do not change this option.",
217       detailed);
218   print_line (OPT_TRACING_FILENAME, "Filename to register traces",
219       "  A file with this name will be created to register the simulation. The file\n"
220       "  is in the Paje format and can be analyzed using Triva or Paje visualization\n"
221       "  tools. More information can be found in these webpages:\n"
222       "     http://triva.gforge.inria.fr/\n"
223       "     http://paje.sourceforge.net/",
224       detailed);
225   print_line (OPT_TRACING_SMPI, "Trace the MPI Interface (SMPI)",
226       "  This option only has effect if this simulator is SMPI-based. Traces the MPI\n"
227       "  interface and generates a trace that can be analyzed using Gantt-like\n"
228       "  visualizations. Every MPI function (implemented by SMPI) is transformed in a\n"
229       "  state, and point-to-point communications can be analyzed with arrows.",
230       detailed);
231   print_line (OPT_TRACING_SMPI_GROUP, "Group MPI processes by host (SMPI)",
232       "  This option only has effect if this simulator is SMPI-based. The processes\n"
233       "  are grouped by the hosts where they were executed.",
234       detailed);
235   print_line (OPT_TRACING_MSG_TASK, "Trace task behavior (MSG)",
236       "  This option only has effect if this simulator is MSG-based. It traces the\n"
237       "  behavior of all categorized MSG tasks, grouping them by hosts.",
238       detailed);
239   print_line (OPT_TRACING_MSG_PROCESS, "Trace processes behavior (MSG)",
240       "  This option only has effect if this simulator is MSG-based. It traces the\n"
241       "  behavior of all categorized MSG processes, grouping them by hosts. This option\n"
242       "  can be used to track process location if this simulator has process migration.",
243       detailed);
244   print_line (OPT_TRACING_MSG_VOLUME, "Tracing of communication volume (MSG)",
245       "  This experimental option only has effect if this simulator is MSG-based.\n"
246       "  It traces the communication volume of MSG send/receive.",
247       detailed);
248 }
249
250 #undef OPT_TRACING
251 #undef OPT_TRACING_SMPI
252 #undef OPT_TRACING_SMPI_GROUP
253 #undef OPT_TRACING_PLATFORM
254 #undef OPT_TRACING_UNCATEGORIZED
255 #undef OPT_TRACING_MSG_TASK
256 #undef OPT_TRACING_MSG_PROCESS
257 #undef OPT_TRACING_MSG_VOLUME
258 #undef OPT_TRACING_FILENAME
259 #undef OPT_TRACING_PLATFORM_METHOD
260
261 #endif /* HAVE_TRACING */