Logo AND Algorithmique Numérique Distribuée

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