1 /* Copyright (c) 2010-2015. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #include "src/instr/instr_private.h"
11 XBT_LOG_NEW_CATEGORY(instr, "Logging the behavior of the tracing system (used for Visualization/Analysis of simulations)");
12 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_config, instr, "Configuration");
14 #define OPT_TRACING_BASIC "tracing/basic"
15 #define OPT_TRACING_BUFFER "tracing/buffer"
16 #define OPT_TRACING_CATEGORIZED "tracing/categorized"
17 #define OPT_TRACING_COMMENT_FILE "tracing/comment-file"
18 #define OPT_TRACING_COMMENT "tracing/comment"
19 #define OPT_TRACING_DISABLE_DESTROY "tracing/disable-destroy"
20 #define OPT_TRACING_DISABLE_LINK "tracing/disable-link"
21 #define OPT_TRACING_DISABLE_POWER "tracing/disable-power"
22 #define OPT_TRACING_DISPLAY_SIZES "tracing/smpi/display-sizes"
23 #define OPT_TRACING_FILENAME "tracing/filename"
24 #define OPT_TRACING_FORMAT_TI_ONEFILE "tracing/smpi/format/ti-one-file"
25 #define OPT_TRACING_FORMAT "tracing/smpi/format"
26 #define OPT_TRACING_MSG_PROCESS "tracing/msg/process"
27 #define OPT_TRACING_MSG_VM "tracing/msg/vm"
28 #define OPT_TRACING_ONELINK_ONLY "tracing/onelink-only"
29 #define OPT_TRACING_PLATFORM "tracing/platform"
30 #define OPT_TRACING_PRECISION "tracing/precision"
31 #define OPT_TRACING_SMPI_COMPUTING "tracing/smpi/computing"
32 #define OPT_TRACING_SMPI_GROUP "tracing/smpi/group"
33 #define OPT_TRACING_SMPI_INTERNALS "tracing/smpi/internals"
34 #define OPT_TRACING_SMPI_SLEEPING "tracing/smpi/sleeping"
35 #define OPT_TRACING_SMPI "tracing/smpi"
36 #define OPT_TRACING_TOPOLOGY "tracing/platform/topology"
37 #define OPT_TRACING "tracing"
38 #define OPT_TRACING_UNCATEGORIZED "tracing/uncategorized"
39 #define OPT_VIVA_CAT_CONF "viva/categorized"
40 #define OPT_VIVA_UNCAT_CONF "viva/uncategorized"
42 static bool trace_enabled = false;
43 static bool trace_platform;
44 static bool trace_platform_topology;
45 static bool trace_smpi_enabled;
46 static bool trace_smpi_grouped;
47 static bool trace_smpi_computing;
48 static bool trace_smpi_sleeping;
49 static bool trace_view_internals;
50 static bool trace_categorized;
51 static bool trace_uncategorized;
52 static bool trace_msg_process_enabled;
53 static bool trace_msg_vm_enabled;
54 static bool trace_buffer;
55 static bool trace_onelink_only;
56 static bool trace_disable_destroy;
57 static bool trace_basic;
58 static bool trace_display_sizes = false;
59 static bool trace_disable_link;
60 static bool trace_disable_power;
61 static int trace_precision;
63 static bool trace_configured = false;
64 static bool trace_active = false;
66 static void TRACE_getopts()
68 trace_enabled = xbt_cfg_get_boolean(OPT_TRACING);
69 trace_platform = xbt_cfg_get_boolean(OPT_TRACING_PLATFORM);
70 trace_platform_topology = xbt_cfg_get_boolean(OPT_TRACING_TOPOLOGY);
71 trace_smpi_enabled = xbt_cfg_get_boolean(OPT_TRACING_SMPI);
72 trace_smpi_grouped = xbt_cfg_get_boolean(OPT_TRACING_SMPI_GROUP);
73 trace_smpi_computing = xbt_cfg_get_boolean(OPT_TRACING_SMPI_COMPUTING);
74 trace_smpi_sleeping = xbt_cfg_get_boolean(OPT_TRACING_SMPI_SLEEPING);
75 trace_view_internals = xbt_cfg_get_boolean(OPT_TRACING_SMPI_INTERNALS);
76 trace_categorized = xbt_cfg_get_boolean(OPT_TRACING_CATEGORIZED);
77 trace_uncategorized = xbt_cfg_get_boolean(OPT_TRACING_UNCATEGORIZED);
78 trace_msg_process_enabled = xbt_cfg_get_boolean(OPT_TRACING_MSG_PROCESS);
79 trace_msg_vm_enabled = xbt_cfg_get_boolean(OPT_TRACING_MSG_VM);
80 trace_buffer = xbt_cfg_get_boolean(OPT_TRACING_BUFFER);
81 trace_onelink_only = xbt_cfg_get_boolean(OPT_TRACING_ONELINK_ONLY);
82 trace_disable_destroy = xbt_cfg_get_boolean(OPT_TRACING_DISABLE_DESTROY);
83 trace_basic = xbt_cfg_get_boolean(OPT_TRACING_BASIC);
84 trace_display_sizes = xbt_cfg_get_boolean(OPT_TRACING_DISPLAY_SIZES);
85 trace_disable_link = xbt_cfg_get_boolean(OPT_TRACING_DISABLE_LINK);
86 trace_disable_power = xbt_cfg_get_boolean(OPT_TRACING_DISABLE_POWER);
87 trace_precision = xbt_cfg_get_int(OPT_TRACING_PRECISION);
92 if (TRACE_is_configured())
95 // tracing system must be:
96 // - enabled (with --cfg=tracing:yes)
97 // - already configured (TRACE_global_init already called)
98 if (TRACE_is_enabled()) {
100 XBT_DEBUG("Tracing starts");
101 /* init the tracing module to generate the right output */
103 /* open the trace file(s) */
104 const char* format = xbt_cfg_get_string(OPT_TRACING_FORMAT);
105 XBT_DEBUG("Tracing format %s\n", format);
106 if(!strcmp(format, "Paje")){
108 }else if (!strcmp(format, "TI")){
112 xbt_die("Unknown trace format :%s ", format);
116 if (trace_active == 1) {
117 THROWF(tracing_error, 0, "Tracing is already active");
120 XBT_DEBUG("Tracing is on");
122 /* other trace initialization */
123 created_categories = xbt_dict_new_homogeneous(xbt_free_f);
124 declared_marks = xbt_dict_new_homogeneous(xbt_free_f);
125 user_host_variables = xbt_dict_new_homogeneous(xbt_free_f);
126 user_vm_variables = xbt_dict_new_homogeneous(xbt_free_f);
127 user_link_variables = xbt_dict_new_homogeneous(xbt_free_f);
140 TRACE_generate_viva_uncat_conf();
141 TRACE_generate_viva_cat_conf();
143 /* dump trace buffer */
144 TRACE_last_timestamp_to_dump = surf_get_clock();
145 TRACE_paje_dump_buffer(1);
147 /* destroy all data structures of tracing (and free) */
148 PJ_container_free_all();
150 PJ_container_release();
153 xbt_dict_free(&user_link_variables);
154 xbt_dict_free(&user_host_variables);
155 xbt_dict_free(&user_vm_variables);
156 xbt_dict_free(&declared_marks);
157 xbt_dict_free(&created_categories);
159 /* close the trace files */
160 const char* format = xbt_cfg_get_string(OPT_TRACING_FORMAT);
161 XBT_DEBUG("Tracing format %s\n", format);
162 if(!strcmp(format, "Paje")){
164 }else if (!strcmp(format, "TI")){
167 xbt_die("Unknown trace format :%s ", format);
170 /* de-activate trace */
172 XBT_DEBUG("Tracing is off");
173 XBT_DEBUG("Tracing system is shutdown");
178 bool TRACE_needs_platform ()
180 return TRACE_msg_process_is_enabled() || TRACE_msg_vm_is_enabled() || TRACE_categorized() ||
181 TRACE_uncategorized() || TRACE_platform () || (TRACE_smpi_is_enabled() && TRACE_smpi_is_grouped());
184 bool TRACE_is_enabled()
186 return trace_enabled;
189 bool TRACE_platform()
191 return trace_platform;
194 bool TRACE_platform_topology()
196 return trace_platform_topology;
199 bool TRACE_is_configured()
201 return trace_configured;
204 bool TRACE_smpi_is_enabled()
206 return (trace_smpi_enabled || TRACE_smpi_is_grouped()) && TRACE_is_enabled();
209 bool TRACE_smpi_is_grouped()
211 return trace_smpi_grouped;
214 bool TRACE_smpi_is_computing()
216 return trace_smpi_computing;
219 bool TRACE_smpi_is_sleeping()
221 return trace_smpi_sleeping;
224 bool TRACE_smpi_view_internals()
226 return trace_view_internals;
229 bool TRACE_categorized ()
231 return trace_categorized;
234 bool TRACE_uncategorized ()
236 return trace_uncategorized;
239 bool TRACE_msg_process_is_enabled()
241 return trace_msg_process_enabled && TRACE_is_enabled();
244 bool TRACE_msg_vm_is_enabled()
246 return trace_msg_vm_enabled && TRACE_is_enabled();
249 bool TRACE_disable_link()
251 return trace_disable_link && TRACE_is_enabled();
254 bool TRACE_disable_speed()
256 return trace_disable_power && TRACE_is_enabled();
261 return trace_buffer && TRACE_is_enabled();
264 bool TRACE_onelink_only ()
266 return trace_onelink_only && TRACE_is_enabled();
269 bool TRACE_disable_destroy ()
271 return trace_disable_destroy && TRACE_is_enabled();
276 return trace_basic && TRACE_is_enabled();
279 bool TRACE_display_sizes ()
281 return trace_display_sizes && trace_smpi_enabled && TRACE_is_enabled();
284 char *TRACE_get_comment ()
286 return xbt_cfg_get_string(OPT_TRACING_COMMENT);
289 char *TRACE_get_comment_file ()
291 return xbt_cfg_get_string(OPT_TRACING_COMMENT_FILE);
294 int TRACE_precision ()
296 return xbt_cfg_get_int(OPT_TRACING_PRECISION);
299 char *TRACE_get_filename()
301 return xbt_cfg_get_string(OPT_TRACING_FILENAME);
304 char *TRACE_get_viva_uncat_conf ()
306 return xbt_cfg_get_string(OPT_VIVA_UNCAT_CONF);
309 char *TRACE_get_viva_cat_conf ()
311 return xbt_cfg_get_string(OPT_VIVA_CAT_CONF);
314 void TRACE_global_init(int *argc, char **argv)
316 static int is_initialised = 0;
321 /* name of the tracefile */
322 xbt_cfg_register_string (OPT_TRACING_FILENAME, "simgrid.trace", nullptr, "Trace file created by the instrumented SimGrid.");
323 xbt_cfg_register_boolean(OPT_TRACING, "no", nullptr, "Enable Tracing.");
324 xbt_cfg_register_boolean(OPT_TRACING_PLATFORM, "no", nullptr, "Register the platform in the trace as a hierarchy.");
325 xbt_cfg_register_boolean(OPT_TRACING_TOPOLOGY, "yes", nullptr, "Register the platform topology in the trace as a graph.");
326 xbt_cfg_register_boolean(OPT_TRACING_SMPI, "no", nullptr, "Tracing of the SMPI interface.");
327 xbt_cfg_register_boolean(OPT_TRACING_SMPI_GROUP,"no", nullptr, "Group MPI processes by host.");
328 xbt_cfg_register_boolean(OPT_TRACING_SMPI_COMPUTING, "no", nullptr, "Generate states for timing out of SMPI parts of the application");
329 xbt_cfg_register_boolean(OPT_TRACING_SMPI_SLEEPING, "no", nullptr, "Generate states for timing out of SMPI parts of the application");
330 xbt_cfg_register_boolean(OPT_TRACING_SMPI_INTERNALS, "no", nullptr, "View internal messages sent by Collective communications in SMPI");
331 xbt_cfg_register_boolean(OPT_TRACING_CATEGORIZED, "no", nullptr, "Tracing categorized resource utilization of hosts and links.");
332 xbt_cfg_register_boolean(OPT_TRACING_UNCATEGORIZED, "no", nullptr, "Tracing uncategorized resource utilization of hosts and links.");
334 xbt_cfg_register_boolean(OPT_TRACING_MSG_PROCESS, "no", nullptr, "Tracing of MSG process behavior.");
335 xbt_cfg_register_boolean(OPT_TRACING_MSG_VM, "no", nullptr, "Tracing of MSG process behavior.");
336 xbt_cfg_register_boolean(OPT_TRACING_DISABLE_LINK, "no", nullptr, "Do not trace link bandwidth and latency.");
337 xbt_cfg_register_boolean(OPT_TRACING_DISABLE_POWER, "no", nullptr, "Do not trace host power.");
338 xbt_cfg_register_boolean(OPT_TRACING_BUFFER, "yes", nullptr, "Buffer trace events to put them in temporal order.");
340 xbt_cfg_register_boolean(OPT_TRACING_ONELINK_ONLY, "no", nullptr, "Use only routes with one link to trace platform.");
341 xbt_cfg_register_boolean(OPT_TRACING_DISABLE_DESTROY, "no", nullptr, "Disable platform containers destruction.");
342 xbt_cfg_register_boolean(OPT_TRACING_BASIC, "no", nullptr, "Avoid extended events (impoverished trace file).");
343 xbt_cfg_register_boolean(OPT_TRACING_DISPLAY_SIZES, "no", nullptr, "(smpi only) Extended events with message size information");
344 xbt_cfg_register_string(OPT_TRACING_FORMAT, "Paje", nullptr, "(smpi only) Switch the output format of Tracing");
345 xbt_cfg_register_boolean(OPT_TRACING_FORMAT_TI_ONEFILE, "no", nullptr, "(smpi only) For replay format only : output to one file only");
346 xbt_cfg_register_string(OPT_TRACING_COMMENT, "", nullptr, "Comment to be added on the top of the trace file.");
347 xbt_cfg_register_string(OPT_TRACING_COMMENT_FILE, "", nullptr,
348 "The contents of the file are added to the top of the trace file as comment.");
349 xbt_cfg_register_int(OPT_TRACING_PRECISION, 6, nullptr, "Numerical precision used when timestamping events "
350 "(expressed in number of digits after decimal point)");
351 /* Viva graph configuration for uncategorized tracing */
352 xbt_cfg_register_string(OPT_VIVA_UNCAT_CONF, "", nullptr, "Viva Graph configuration file for uncategorized resource utilization traces.");
353 xbt_cfg_register_string(OPT_VIVA_CAT_CONF, "", nullptr, "Viva Graph configuration file for categorized resource utilization traces.");
355 xbt_cfg_register_alias(OPT_TRACING_COMMENT_FILE,"tracing/comment_file");
356 xbt_cfg_register_alias(OPT_TRACING_DISABLE_DESTROY, "tracing/disable_destroy");
357 xbt_cfg_register_alias(OPT_TRACING_DISABLE_LINK, "tracing/disable_link");
358 xbt_cfg_register_alias(OPT_TRACING_DISABLE_POWER, "tracing/disable_power");
359 xbt_cfg_register_alias(OPT_TRACING_DISPLAY_SIZES, "tracing/smpi/display_sizes");
360 xbt_cfg_register_alias(OPT_TRACING_FORMAT_TI_ONEFILE, "tracing/smpi/format/ti_one_file");
361 xbt_cfg_register_alias(OPT_TRACING_ONELINK_ONLY, "tracing/onelink_only");
363 /* instrumentation can be considered configured now */
364 trace_configured = 1;
367 static void print_line (const char *option, const char *desc, const char *longdesc, int detailed)
369 char str[INSTR_DEFAULT_STR_SIZE];
370 snprintf (str, INSTR_DEFAULT_STR_SIZE, "--cfg=%s ", option);
372 int len = strlen (str);
373 printf ("%s%*.*s %s\n", str, 30-len, 30-len, "", desc);
374 if (longdesc != nullptr && detailed){
375 printf ("%s\n\n", longdesc);
379 void TRACE_help (int detailed)
381 printf("Description of the tracing options accepted by this simulator:\n\n");
382 print_line (OPT_TRACING, "Enable the tracing system",
383 " It activates the tracing system and register the simulation platform\n"
384 " in the trace file. You have to enable this option to others take effect.", detailed);
385 print_line (OPT_TRACING_CATEGORIZED, "Trace categorized resource utilization",
386 " It activates the categorized resource utilization tracing. It should\n"
387 " be enabled if tracing categories are used by this simulator.", detailed);
388 print_line (OPT_TRACING_UNCATEGORIZED, "Trace uncategorized resource utilization",
389 " It activates the uncategorized resource utilization tracing. Use it if\n"
390 " this simulator do not use tracing categories and resource use have to be\n"
391 " traced.", detailed);
392 print_line (OPT_TRACING_FILENAME, "Filename to register traces",
393 " A file with this name will be created to register the simulation. The file\n"
394 " is in the Paje format and can be analyzed using Viva, Paje, and PajeNG visualization\n"
395 " tools. More information can be found in these webpages:\n"
396 " http://github.com/schnorr/viva/\n"
397 " http://github.com/schnorr/pajeng/\n"
398 " http://paje.sourceforge.net/", detailed);
399 print_line (OPT_TRACING_SMPI, "Trace the MPI Interface (SMPI)",
400 " This option only has effect if this simulator is SMPI-based. Traces the MPI\n"
401 " interface and generates a trace that can be analyzed using Gantt-like\n"
402 " visualizations. Every MPI function (implemented by SMPI) is transformed in a\n"
403 " state, and point-to-point communications can be analyzed with arrows.", detailed);
404 print_line (OPT_TRACING_SMPI_GROUP, "Group MPI processes by host (SMPI)",
405 " This option only has effect if this simulator is SMPI-based. The processes\n"
406 " are grouped by the hosts where they were executed.", detailed);
407 print_line (OPT_TRACING_SMPI_COMPUTING, "Generates a \" Computing \" State",
408 " This option aims at tracing computations in the application, outside SMPI\n"
409 " to allow further study of simulated or real computation time", detailed);
410 print_line (OPT_TRACING_SMPI_SLEEPING, "Generates a \" Sleeping \" State",
411 " This option aims at tracing sleeps in the application, outside SMPI\n"
412 " to allow further study of simulated or real sleep time", detailed);
413 print_line (OPT_TRACING_SMPI_INTERNALS, "Generates tracing events corresponding",
414 " to point-to-point messages sent by collective communications", detailed);
415 print_line (OPT_TRACING_MSG_PROCESS, "Trace processes behavior (MSG)",
416 " This option only has effect if this simulator is MSG-based. It traces the\n"
417 " behavior of all categorized MSG processes, grouping them by hosts. This option\n"
418 " can be used to track process location if this simulator has process migration.", detailed);
419 print_line (OPT_TRACING_BUFFER, "Buffer events to put them in temporal order",
420 " This option put some events in a time-ordered buffer using the insertion\n"
421 " sort algorithm. The process of acquiring and releasing locks to access this\n"
422 " buffer and the cost of the sorting algorithm make this process slow. The\n"
423 " simulator performance can be severely impacted if this option is activated,\n"
424 " but you are sure to get a trace file with events sorted.", detailed);
425 print_line (OPT_TRACING_ONELINK_ONLY, "Consider only one link routes to trace platform",
426 " This option changes the way SimGrid register its platform on the trace file.\n"
427 " Normally, the tracing considers all routes (no matter their size) on the\n"
428 " platform file to re-create the resource topology. If this option is activated,\n"
429 " only the routes with one link are used to register the topology within an AS.\n"
430 " Routes among AS continue to be traced as usual.", detailed);
431 print_line (OPT_TRACING_DISABLE_DESTROY, "Disable platform containers destruction",
432 " Disable the destruction of containers at the end of simulation. This can be\n"
433 " used with simulators that have a different notion of time (different from\n"
434 " the simulated time).", detailed);
435 print_line (OPT_TRACING_BASIC, "Avoid extended events (impoverished trace file).",
436 " Some visualization tools are not able to parse correctly the Paje file format.\n"
437 " Use this option if you are using one of these tools to visualize the simulation\n"
438 " trace. Keep in mind that the trace might be incomplete, without all the\n"
439 " information that would be registered otherwise.", detailed);
440 print_line (OPT_TRACING_DISPLAY_SIZES, "Only works for SMPI now. Add message size information",
441 " Message size (in bytes) is added to links, and to states. For collectives,\n"
442 " the displayed value is the more relevant to the collective (total sent by\n"
443 " the process, usually)", detailed);
444 print_line (OPT_TRACING_FORMAT, "Only works for SMPI now. Switch output format",
445 " Default format is Paje. Time independent traces are also supported,\n"
446 " to output traces that can later be used by the trace replay tool", detailed);
447 print_line (OPT_TRACING_FORMAT_TI_ONEFILE, "Only works for SMPI now, and TI output format",
448 " By default, each process outputs to a separate file, inside a filename_files folder\n"
449 " By setting this option to yes, all processes will output to only one file\n"
450 " This is meant to avoid opening thousands of files with large simulations", detailed);
451 print_line (OPT_TRACING_COMMENT, "Comment to be added on the top of the trace file.",
452 " Use this to add a comment line to the top of the trace file.", detailed);
453 print_line (OPT_TRACING_COMMENT_FILE, "File contents added to trace file as comment.",
454 " Use this to add the contents of a file to the top of the trace file as comment.", detailed);
455 print_line (OPT_VIVA_UNCAT_CONF, "Generate a graph configuration for Viva",
456 " This option can be used in all types of simulators build with SimGrid\n"
457 " to generate a uncategorized resource utilization graph to be used as\n"
458 " configuration for the Viva visualization tool. This option\n"
459 " can be used with tracing/categorized:1 and tracing:1 options to\n"
460 " analyze an unmodified simulator before changing it to contain\n"
461 " categories.", detailed);
462 print_line (OPT_VIVA_CAT_CONF, "Generate an uncategorized graph configuration for Viva",
463 " This option can be used if this simulator uses tracing categories\n"
464 " in its code. The file specified by this option holds a graph configuration\n"
465 " file for the Viva visualization tool that can be used to analyze a categorized\n"
466 " resource utilization.", detailed);
467 print_line (OPT_TRACING_TOPOLOGY, "Register the platform topology as a graph",
468 " This option (enabled by default) can be used to disable the tracing of\n"
469 " the platform topology in the trace file. Sometimes, such task is really\n"
470 " time consuming, since it must get the route from each host to other hosts\n"
471 " within the same Autonomous System (AS).", detailed);
474 static void output_types (const char *name, xbt_dynar_t types, FILE *file)
477 fprintf (file, " %s = (", name);
478 for (i = xbt_dynar_length(types); i > 0; i--) {
479 char *type = *(static_cast<char**>(xbt_dynar_get_ptr(types, i - 1)));
480 fprintf (file, "\"%s\"", type);
484 fprintf (file, ");\n");
487 xbt_dynar_free (&types);
490 static void output_categories (const char *name, xbt_dynar_t cats, FILE *file)
493 fprintf (file, " values = (");
494 for (i = xbt_dynar_length(cats); i > 0; i--) {
495 char *cat = *(static_cast<char**>(xbt_dynar_get_ptr(cats, i - 1)));
496 fprintf (file, "\"%s%s\"", name, cat);
500 fprintf (file, ");\n");
503 xbt_dynar_free (&cats);
506 static void uncat_configuration (FILE *file)
508 //register NODE and EDGE types
509 output_types ("node", TRACE_get_node_types(), file);
510 output_types ("edge", TRACE_get_edge_types(), file);
511 fprintf (file, "\n");
513 //configuration for all nodes
516 " type = \"square\";\n"
517 " size = \"power\";\n"
518 " values = (\"power_used\");\n"
521 " type = \"rhombus\";\n"
522 " size = \"bandwidth\";\n"
523 " values = (\"bandwidth_used\");\n"
528 static void cat_configuration (FILE *file)
530 //register NODE and EDGE types
531 output_types ("node", TRACE_get_node_types(), file);
532 output_types ("edge", TRACE_get_edge_types(), file);
533 fprintf (file, "\n");
535 //configuration for all nodes
538 " type = \"square\";\n"
539 " size = \"power\";\n");
540 output_categories ("p", TRACE_get_categories(), file);
544 " type = \"rhombus\";\n"
545 " size = \"bandwidth\";\n");
546 output_categories ("b", TRACE_get_categories(), file);
547 fprintf (file, " };\n");
551 static void generate_uncat_configuration (const char *output, const char *name, int brackets)
553 if (output && strlen(output) > 0){
554 FILE *file = fopen (output, "w");
555 if (file == nullptr){
556 THROWF (system_error, 1, "Unable to open file (%s) for writing %s graph configuration (uncategorized).",
561 fprintf (file, "{\n");
562 uncat_configuration (file);
564 fprintf (file, "}\n");
569 static void generate_cat_configuration (const char *output, const char *name, int brackets)
571 if (output && strlen(output) > 0){
572 //check if we do have categories declared
573 if (xbt_dict_is_empty(created_categories)){
574 XBT_INFO("No categories declared, ignoring generation of %s graph configuration", name);
578 FILE *file = fopen (output, "w");
579 if (file == nullptr){
580 THROWF (system_error, 1, "Unable to open file (%s) for writing %s graph "
581 "configuration (categorized).", output, name);
584 if (brackets) fprintf (file, "{\n");
585 cat_configuration (file);
586 if (brackets) fprintf (file, "}\n");
591 void TRACE_generate_viva_uncat_conf ()
593 generate_uncat_configuration (TRACE_get_viva_uncat_conf (), "viva", 0);
596 void TRACE_generate_viva_cat_conf ()
598 generate_cat_configuration (TRACE_get_viva_cat_conf(), "viva", 0);
601 static int previous_trace_state = -1;
603 void instr_pause_tracing ()
605 previous_trace_state = trace_enabled;
606 if (!TRACE_is_enabled()){
607 XBT_DEBUG ("Tracing is already paused, therefore do nothing.");
609 XBT_DEBUG ("Tracing is being paused.");
612 XBT_DEBUG ("Tracing is paused.");
615 void instr_resume_tracing ()
617 if (TRACE_is_enabled()){
618 XBT_DEBUG ("Tracing is already running while trying to resume, therefore do nothing.");
620 XBT_DEBUG ("Tracing is being resumed.");
623 if (previous_trace_state != -1){
624 trace_enabled = previous_trace_state;
628 XBT_DEBUG ("Tracing is resumed.");
629 previous_trace_state = -1;
633 #undef OPT_TRACING_PLATFORM
634 #undef OPT_TRACING_TOPOLOGY
635 #undef OPT_TRACING_SMPI
636 #undef OPT_TRACING_SMPI_GROUP
637 #undef OPT_TRACING_CATEGORIZED
638 #undef OPT_TRACING_UNCATEGORIZED
639 #undef OPT_TRACING_MSG_PROCESS
640 #undef OPT_TRACING_FILENAME
641 #undef OPT_TRACING_BUFFER
642 #undef OPT_TRACING_ONELINK_ONLY
643 #undef OPT_TRACING_DISABLE_DESTROY
644 #undef OPT_TRACING_BASIC
645 #undef OPT_TRACING_COMMENT
646 #undef OPT_TRACING_COMMENT_FILE
647 #undef OPT_VIVA_UNCAT_CONF
648 #undef OPT_VIVA_CAT_CONF