1 /* Copyright (c) 2010. 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 "instr/instr_private.h"
8 #include "simgrid/sg_config.h"
13 XBT_LOG_NEW_CATEGORY(instr, "Logging the behavior of the tracing system (used for Visualization/Analysis of simulations)");
14 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_config, instr, "Configuration");
16 #define OPT_TRACING "tracing"
17 #define OPT_TRACING_PLATFORM "tracing/platform"
18 #define OPT_TRACING_TOPOLOGY "tracing/platform/topology"
19 #define OPT_TRACING_SMPI "tracing/smpi"
20 #define OPT_TRACING_SMPI_GROUP "tracing/smpi/group"
21 #define OPT_TRACING_SMPI_COMPUTING "tracing/smpi/computing"
22 #define OPT_TRACING_SMPI_INTERNALS "tracing/smpi/internals"
23 #define OPT_TRACING_CATEGORIZED "tracing/categorized"
24 #define OPT_TRACING_UNCATEGORIZED "tracing/uncategorized"
25 #define OPT_TRACING_MSG_PROCESS "tracing/msg/process"
26 #define OPT_TRACING_MSG_VM "tracing/msg/vm"
27 #define OPT_TRACING_FILENAME "tracing/filename"
28 #define OPT_TRACING_BUFFER "tracing/buffer"
29 #define OPT_TRACING_ONELINK_ONLY "tracing/onelink_only"
30 #define OPT_TRACING_DISABLE_DESTROY "tracing/disable_destroy"
31 #define OPT_TRACING_BASIC "tracing/basic"
32 #define OPT_TRACING_COMMENT "tracing/comment"
33 #define OPT_TRACING_COMMENT_FILE "tracing/comment_file"
34 #define OPT_VIVA_UNCAT_CONF "viva/uncategorized"
35 #define OPT_VIVA_CAT_CONF "viva/categorized"
36 #define OPT_TRACING_DISABLE_LINK "tracing/disable_link"
37 #define OPT_TRACING_DISABLE_POWER "tracing/disable_power"
39 static int trace_enabled;
40 static int trace_platform;
41 static int trace_platform_topology;
42 static int trace_smpi_enabled;
43 static int trace_smpi_grouped;
44 static int trace_smpi_computing;
45 static int trace_view_internals;
46 static int trace_categorized;
47 static int trace_uncategorized;
48 static int trace_msg_process_enabled;
49 static int trace_msg_vm_enabled;
50 static int trace_buffer;
51 static int trace_onelink_only;
52 static int trace_disable_destroy;
53 static int trace_basic;
54 static int trace_disable_link;
55 static int trace_disable_power;
57 static int trace_configured = 0;
58 static int trace_active = 0;
62 static void TRACE_getopts(void)
64 trace_enabled = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING);
65 trace_platform = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_PLATFORM);
66 trace_platform_topology = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_TOPOLOGY);
67 trace_smpi_enabled = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_SMPI);
68 trace_smpi_grouped = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_SMPI_GROUP);
69 trace_smpi_computing = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_SMPI_COMPUTING);
70 trace_view_internals = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_SMPI_INTERNALS);
71 trace_categorized = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_CATEGORIZED);
72 trace_uncategorized = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_UNCATEGORIZED);
73 trace_msg_process_enabled = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_MSG_PROCESS);
74 trace_msg_vm_enabled = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_MSG_VM);
75 trace_buffer = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_BUFFER);
76 trace_onelink_only = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_ONELINK_ONLY);
77 trace_disable_destroy = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_DISABLE_DESTROY);
78 trace_basic = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_BASIC);
79 trace_disable_link = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_DISABLE_LINK);
80 trace_disable_power = xbt_cfg_get_int(_sg_cfg_set, OPT_TRACING_DISABLE_POWER);
83 static xbt_dynar_t TRACE_start_functions = NULL;
84 void TRACE_add_start_function(void (*func) ())
86 if (TRACE_start_functions == NULL)
87 TRACE_start_functions = xbt_dynar_new(sizeof(void (*)()), NULL);
88 xbt_dynar_push(TRACE_start_functions, &func);
95 // tracing system must be:
96 // - enabled (with --cfg=tracing:1)
97 // - already configured (TRACE_global_init already called)
98 if (TRACE_is_enabled() && TRACE_is_configured()) {
99 XBT_DEBUG("Tracing starts");
101 /* open the trace file */
105 if (trace_active == 1) {
106 THROWF(tracing_error, 0, "Tracing is already active");
109 XBT_DEBUG("Tracing is on");
111 /* other trace initialization */
112 created_categories = xbt_dict_new_homogeneous(xbt_free);
113 declared_marks = xbt_dict_new_homogeneous(xbt_free);
114 user_host_variables = xbt_dict_new_homogeneous(xbt_free);
115 user_vm_variables = xbt_dict_new_homogeneous (xbt_free);
116 user_link_variables = xbt_dict_new_homogeneous(xbt_free);
118 if (TRACE_start_functions != NULL) {
120 unsigned int iter = xbt_dynar_length(TRACE_start_functions);
121 xbt_dynar_foreach(TRACE_start_functions, iter, func) {
126 xbt_dynar_free(&TRACE_start_functions);
130 static xbt_dynar_t TRACE_end_functions = NULL;
131 void TRACE_add_end_function(void (*func) (void))
133 if (TRACE_end_functions == NULL)
134 TRACE_end_functions = xbt_dynar_new(sizeof(void (*)(void)), NULL);
135 xbt_dynar_push(TRACE_end_functions, &func);
146 TRACE_generate_viva_uncat_conf();
147 TRACE_generate_viva_cat_conf();
149 /* dump trace buffer */
150 TRACE_last_timestamp_to_dump = surf_get_clock();
151 TRACE_paje_dump_buffer(1);
153 /* destroy all data structures of tracing (and free) */
154 PJ_container_free_all();
156 PJ_container_release();
159 if (TRACE_end_functions != NULL) {
162 xbt_dynar_foreach(TRACE_end_functions, iter, func) {
167 xbt_dict_free(&user_link_variables);
168 xbt_dict_free(&user_host_variables);
169 xbt_dict_free(&user_vm_variables);
170 xbt_dict_free(&declared_marks);
171 xbt_dict_free(&created_categories);
173 /* close the trace file */
176 /* de-activate trace */
178 XBT_DEBUG("Tracing is off");
179 XBT_DEBUG("Tracing system is shutdown");
181 xbt_dynar_free(&TRACE_end_functions);
185 int TRACE_needs_platform (void)
187 return TRACE_msg_process_is_enabled() ||
188 TRACE_msg_vm_is_enabled() ||
189 TRACE_categorized() ||
190 TRACE_uncategorized() ||
192 (TRACE_smpi_is_enabled() && TRACE_smpi_is_grouped());
195 int TRACE_is_enabled(void)
197 return trace_enabled;
200 int TRACE_platform(void)
202 return trace_platform;
205 int TRACE_platform_topology(void)
207 return trace_platform_topology;
210 int TRACE_is_configured(void)
212 return trace_configured;
215 int TRACE_smpi_is_enabled(void)
217 return (trace_smpi_enabled || TRACE_smpi_is_grouped())
218 && TRACE_is_enabled();
221 int TRACE_smpi_is_grouped(void)
223 return trace_smpi_grouped;
226 int TRACE_smpi_is_computing(void)
228 return trace_smpi_computing;
231 int TRACE_smpi_view_internals(void)
233 return trace_view_internals;
236 int TRACE_categorized (void)
238 return trace_categorized;
241 int TRACE_uncategorized (void)
243 return trace_uncategorized;
246 int TRACE_msg_process_is_enabled(void)
248 return trace_msg_process_enabled && TRACE_is_enabled();
251 int TRACE_msg_vm_is_enabled(void)
253 return trace_msg_vm_enabled && TRACE_is_enabled();
256 int TRACE_disable_link(void)
258 return trace_disable_link && TRACE_is_enabled();
261 int TRACE_disable_power(void)
263 return trace_disable_power && TRACE_is_enabled();
266 int TRACE_buffer (void)
268 return trace_buffer && TRACE_is_enabled();
271 int TRACE_onelink_only (void)
273 return trace_onelink_only && TRACE_is_enabled();
276 int TRACE_disable_destroy (void)
278 return trace_disable_destroy && TRACE_is_enabled();
281 int TRACE_basic (void)
283 return trace_basic && TRACE_is_enabled();
286 char *TRACE_get_comment (void)
288 return xbt_cfg_get_string(_sg_cfg_set, OPT_TRACING_COMMENT);
291 char *TRACE_get_comment_file (void)
293 return xbt_cfg_get_string(_sg_cfg_set, OPT_TRACING_COMMENT_FILE);
296 char *TRACE_get_filename(void)
298 return xbt_cfg_get_string(_sg_cfg_set, OPT_TRACING_FILENAME);
301 char *TRACE_get_viva_uncat_conf (void)
303 return xbt_cfg_get_string(_sg_cfg_set, OPT_VIVA_UNCAT_CONF);
306 char *TRACE_get_viva_cat_conf (void)
308 return xbt_cfg_get_string(_sg_cfg_set, OPT_VIVA_CAT_CONF);
311 void TRACE_global_init(int *argc, char **argv)
313 /* name of the tracefile */
314 char *default_tracing_filename = xbt_strdup("simgrid.trace");
315 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_FILENAME,
316 "Trace file created by the instrumented SimGrid.",
317 xbt_cfgelm_string, &default_tracing_filename, 1, 1,
321 int default_tracing = 0;
322 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING,
324 xbt_cfgelm_int, &default_tracing, 0, 1,
327 /* register platform in the trace */
328 int default_tracing_platform = 0;
329 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_PLATFORM,
330 "Register the platform in the trace as a hierarchy.",
331 xbt_cfgelm_int, &default_tracing_platform, 0, 1,
334 /* register platform in the trace */
335 int default_tracing_platform_topology = 1;
336 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_TOPOLOGY,
337 "Register the platform topology in the trace as a graph.",
338 xbt_cfgelm_int, &default_tracing_platform_topology, 0, 1,
342 int default_tracing_smpi = 0;
343 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_SMPI,
344 "Tracing of the SMPI interface.",
345 xbt_cfgelm_int, &default_tracing_smpi, 0, 1,
349 int default_tracing_smpi_grouped = 0;
350 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_SMPI_GROUP,
351 "Group MPI processes by host.",
352 xbt_cfgelm_int, &default_tracing_smpi_grouped, 0, 1,
356 int default_tracing_smpi_computing = 0;
357 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_SMPI_COMPUTING,
358 "Generate states for timing out of SMPI parts of the application",
359 xbt_cfgelm_int, &default_tracing_smpi_computing, 0, 1,
363 int default_tracing_smpi_internals = 0;
364 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_SMPI_INTERNALS,
365 "View internal messages sent by Collective communications in SMPI",
366 xbt_cfgelm_int, &default_tracing_smpi_internals, 0, 1,
369 /* tracing categorized resource utilization traces */
370 int default_tracing_categorized = 0;
371 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_CATEGORIZED,
372 "Tracing categorized resource utilization of hosts and links.",
373 xbt_cfgelm_int, &default_tracing_categorized, 0, 1,
376 /* tracing uncategorized resource utilization */
377 int default_tracing_uncategorized = 0;
378 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_UNCATEGORIZED,
379 "Tracing uncategorized resource utilization of hosts and links.",
380 xbt_cfgelm_int, &default_tracing_uncategorized, 0, 1,
384 int default_tracing_msg_process = 0;
385 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_MSG_PROCESS,
386 "Tracing of MSG process behavior.",
387 xbt_cfgelm_int, &default_tracing_msg_process, 0, 1,
391 int default_tracing_msg_vm = 0;
392 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_MSG_VM,
393 "Tracing of MSG process behavior.",
394 xbt_cfgelm_int, &default_tracing_msg_vm, 0, 1,
397 /* disable tracing link */
398 int default_tracing_disable_link = 0;
399 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_DISABLE_LINK,
400 "Do not trace link bandwidth and latency.",
401 xbt_cfgelm_int, &default_tracing_disable_link, 0, 1,
404 /* disable tracing link */
405 int default_tracing_disable_power = 0;
406 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_DISABLE_POWER,
407 "Do not trace host power.",
408 xbt_cfgelm_int, &default_tracing_disable_power, 0, 1,
413 int default_buffer = 1;
414 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_BUFFER,
415 "Buffer trace events to put them in temporal order.",
416 xbt_cfgelm_int, &default_buffer, 0, 1,
419 /* tracing one link only */
420 int default_onelink_only = 0;
421 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_ONELINK_ONLY,
422 "Use only routes with one link to trace platform.",
423 xbt_cfgelm_int, &default_onelink_only, 0, 1,
426 /* disable destroy */
427 int default_disable_destroy = 0;
428 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_DISABLE_DESTROY,
429 "Disable platform containers destruction.",
430 xbt_cfgelm_int, &default_disable_destroy, 0, 1,
433 /* basic -- Avoid extended events (impoverished trace file) */
434 int default_basic = 0;
435 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_BASIC,
436 "Avoid extended events (impoverished trace file).",
437 xbt_cfgelm_int, &default_basic, 0, 1,
441 char *default_tracing_comment = xbt_strdup ("");
442 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_COMMENT,
443 "Comment to be added on the top of the trace file.",
444 xbt_cfgelm_string, &default_tracing_comment, 1, 1,
448 char *default_tracing_comment_file = xbt_strdup ("");
449 xbt_cfg_register(&_sg_cfg_set, OPT_TRACING_COMMENT_FILE,
450 "The contents of the file are added to the top of the trace file as comment.",
451 xbt_cfgelm_string, &default_tracing_comment_file, 1, 1,
454 /* Viva graph configuration for uncategorized tracing */
455 char *default_viva_uncat_conf_file = xbt_strdup ("");
456 xbt_cfg_register(&_sg_cfg_set, OPT_VIVA_UNCAT_CONF,
457 "Viva Graph configuration file for uncategorized resource utilization traces.",
458 xbt_cfgelm_string, &default_viva_uncat_conf_file, 1, 1,
461 /* Viva graph configuration for uncategorized tracing */
462 char *default_viva_cat_conf_file = xbt_strdup ("");
463 xbt_cfg_register(&_sg_cfg_set, OPT_VIVA_CAT_CONF,
464 "Viva Graph configuration file for categorized resource utilization traces.",
465 xbt_cfgelm_string, &default_viva_cat_conf_file, 1, 1,
468 /* instrumentation can be considered configured now */
469 trace_configured = 1;
472 static void print_line (const char *option, const char *desc, const char *longdesc, int detailed)
474 char str[INSTR_DEFAULT_STR_SIZE];
475 snprintf (str, INSTR_DEFAULT_STR_SIZE, "--cfg=%s ", option);
477 int len = strlen (str);
478 printf ("%s%*.*s %s\n", str, 30-len, 30-len, "", desc);
479 if (!!longdesc && detailed){
480 printf ("%s\n\n", longdesc);
484 void TRACE_help (int detailed)
487 "Description of the tracing options accepted by this simulator:\n\n");
488 print_line (OPT_TRACING, "Enable the tracing system",
489 " It activates the tracing system and register the simulation platform\n"
490 " in the trace file. You have to enable this option to others take effect.",
492 print_line (OPT_TRACING_CATEGORIZED, "Trace categorized resource utilization",
493 " It activates the categorized resource utilization tracing. It should\n"
494 " be enabled if tracing categories are used by this simulator.",
496 print_line (OPT_TRACING_UNCATEGORIZED, "Trace uncategorized resource utilization",
497 " It activates the uncategorized resource utilization tracing. Use it if\n"
498 " this simulator do not use tracing categories and resource use have to be\n"
501 print_line (OPT_TRACING_FILENAME, "Filename to register traces",
502 " A file with this name will be created to register the simulation. The file\n"
503 " is in the Paje format and can be analyzed using Viva, Paje, and PajeNG visualization\n"
504 " tools. More information can be found in these webpages:\n"
505 " http://github.com/schnorr/viva/\n"
506 " http://github.com/schnorr/pajeng/\n"
507 " http://paje.sourceforge.net/",
509 print_line (OPT_TRACING_SMPI, "Trace the MPI Interface (SMPI)",
510 " This option only has effect if this simulator is SMPI-based. Traces the MPI\n"
511 " interface and generates a trace that can be analyzed using Gantt-like\n"
512 " visualizations. Every MPI function (implemented by SMPI) is transformed in a\n"
513 " state, and point-to-point communications can be analyzed with arrows.",
515 print_line (OPT_TRACING_SMPI_GROUP, "Group MPI processes by host (SMPI)",
516 " This option only has effect if this simulator is SMPI-based. The processes\n"
517 " are grouped by the hosts where they were executed.",
519 print_line (OPT_TRACING_SMPI_COMPUTING, "Generates a \" Computing \" State",
520 " This option aims at tracing computations in the application, outside SMPI\n"
521 " to allow further study of simulated or real computation time",
523 print_line (OPT_TRACING_SMPI_INTERNALS, "Generates tracing events corresponding",
524 " to point-to-point messages sent by collective communications",
526 print_line (OPT_TRACING_MSG_PROCESS, "Trace processes behavior (MSG)",
527 " This option only has effect if this simulator is MSG-based. It traces the\n"
528 " behavior of all categorized MSG processes, grouping them by hosts. This option\n"
529 " can be used to track process location if this simulator has process migration.",
531 print_line (OPT_TRACING_BUFFER, "Buffer events to put them in temporal order",
532 " This option put some events in a time-ordered buffer using the insertion\n"
533 " sort algorithm. The process of acquiring and releasing locks to access this\n"
534 " buffer and the cost of the sorting algorithm make this process slow. The\n"
535 " simulator performance can be severely impacted if this option is activated,\n"
536 " but you are sure to get a trace file with events sorted.",
538 print_line (OPT_TRACING_ONELINK_ONLY, "Consider only one link routes to trace platform",
539 " This option changes the way SimGrid register its platform on the trace file.\n"
540 " Normally, the tracing considers all routes (no matter their size) on the\n"
541 " platform file to re-create the resource topology. If this option is activated,\n"
542 " only the routes with one link are used to register the topology within an AS.\n"
543 " Routes among AS continue to be traced as usual.",
545 print_line (OPT_TRACING_DISABLE_DESTROY, "Disable platform containers destruction",
546 " Disable the destruction of containers at the end of simulation. This can be\n"
547 " used with simulators that have a different notion of time (different from\n"
548 " the simulated time).",
550 print_line (OPT_TRACING_BASIC, "Avoid extended events (impoverished trace file).",
551 " Some visualization tools are not able to parse correctly the Paje file format.\n"
552 " Use this option if you are using one of these tools to visualize the simulation\n"
553 " trace. Keep in mind that the trace might be incomplete, without all the\n"
554 " information that would be registered otherwise.",
556 print_line (OPT_TRACING_COMMENT, "Comment to be added on the top of the trace file.",
557 " Use this to add a comment line to the top of the trace file.",
559 print_line (OPT_TRACING_COMMENT_FILE, "File contents added to trace file as comment.",
560 " Use this to add the contents of a file to the top of the trace file as comment.",
562 print_line (OPT_VIVA_UNCAT_CONF, "Generate a graph configuration for Viva",
563 " This option can be used in all types of simulators build with SimGrid\n"
564 " to generate a uncategorized resource utilization graph to be used as\n"
565 " configuration for the Viva visualization tool. This option\n"
566 " can be used with tracing/categorized:1 and tracing:1 options to\n"
567 " analyze an unmodified simulator before changing it to contain\n"
570 print_line (OPT_VIVA_CAT_CONF, "Generate an uncategorized graph configuration for Viva",
571 " This option can be used if this simulator uses tracing categories\n"
572 " in its code. The file specified by this option holds a graph configuration\n"
573 " file for the Viva visualization tool that can be used to analyze a categorized\n"
574 " resource utilization.",
576 print_line (OPT_TRACING_TOPOLOGY, "Register the platform topology as a graph",
577 " This option (enabled by default) can be used to disable the tracing of\n"
578 " the platform topology in the trace file. Sometimes, such task is really\n"
579 " time consuming, since it must get the route from each host ot other hosts\n"
580 " within the same Autonomous System (AS).",
584 static void output_types (const char *name, xbt_dynar_t types, FILE *file)
587 fprintf (file, " %s = (", name);
588 for (i = xbt_dynar_length(types); i > 0; i--) {
589 char *type = *(char**)xbt_dynar_get_ptr(types, i - 1);
590 fprintf (file, "\"%s\"", type);
594 fprintf (file, ");\n");
597 xbt_dynar_free (&types);
600 static void output_categories (const char *name, xbt_dynar_t cats, FILE *file)
603 fprintf (file, " values = (");
604 for (i = xbt_dynar_length(cats); i > 0; i--) {
605 char *cat = *(char**)xbt_dynar_get_ptr(cats, i - 1);
606 fprintf (file, "\"%s%s\"", name, cat);
610 fprintf (file, ");\n");
613 xbt_dynar_free (&cats);
616 static void uncat_configuration (FILE *file)
618 //register NODE and EDGE types
619 output_types ("node", TRACE_get_node_types(), file);
620 output_types ("edge", TRACE_get_edge_types(), file);
621 fprintf (file, "\n");
623 //configuration for all nodes
626 " type = \"square\";\n"
627 " size = \"power\";\n"
628 " values = (\"power_used\");\n"
631 " type = \"rhombus\";\n"
632 " size = \"bandwidth\";\n"
633 " values = (\"bandwidth_used\");\n"
638 static void cat_configuration (FILE *file)
640 //register NODE and EDGE types
641 output_types ("node", TRACE_get_node_types(), file);
642 output_types ("edge", TRACE_get_edge_types(), file);
643 fprintf (file, "\n");
645 //configuration for all nodes
648 " type = \"square\";\n"
649 " size = \"power\";\n");
650 output_categories ("p", TRACE_get_categories(), file);
654 " type = \"rhombus\";\n"
655 " size = \"bandwidth\";\n");
656 output_categories ("b", TRACE_get_categories(), file);
657 fprintf (file, " };\n");
661 static void generate_uncat_configuration (const char *output, const char *name, int brackets)
663 if (output && strlen(output) > 0){
664 FILE *file = fopen (output, "w");
666 THROWF (system_error, 1, "Unable to open file (%s) for writing %s graph "
667 "configuration (uncategorized).", output, name);
670 if (brackets) fprintf (file, "{\n");
671 uncat_configuration (file);
672 if (brackets) fprintf (file, "}\n");
677 static void generate_cat_configuration (const char *output, const char *name, int brackets)
679 if (output && strlen(output) > 0){
680 //check if we do have categories declared
681 if (xbt_dict_is_empty(created_categories)){
682 XBT_INFO("No categories declared, ignoring generation of %s graph configuration", name);
686 FILE *file = fopen (output, "w");
688 THROWF (system_error, 1, "Unable to open file (%s) for writing %s graph "
689 "configuration (categorized).", output, name);
692 if (brackets) fprintf (file, "{\n");
693 cat_configuration (file);
694 if (brackets) fprintf (file, "}\n");
699 void TRACE_generate_viva_uncat_conf (void)
701 generate_uncat_configuration (TRACE_get_viva_uncat_conf (), "viva", 0);
704 void TRACE_generate_viva_cat_conf (void)
706 generate_cat_configuration (TRACE_get_viva_cat_conf(), "viva", 0);
709 static int previous_trace_state = -1;
711 void instr_pause_tracing (void)
713 previous_trace_state = trace_enabled;
714 if (!TRACE_is_enabled()){
715 XBT_DEBUG ("Tracing is already paused, therefore do nothing.");
717 XBT_DEBUG ("Tracing is being paused.");
720 XBT_DEBUG ("Tracing is paused.");
723 void instr_resume_tracing (void)
725 if (TRACE_is_enabled()){
726 XBT_DEBUG ("Tracing is already running while trying to resume, therefore do nothing.");
728 XBT_DEBUG ("Tracing is being resumed.");
731 if (previous_trace_state != -1){
732 trace_enabled = previous_trace_state;
736 XBT_DEBUG ("Tracing is resumed.");
737 previous_trace_state = -1;
741 #undef OPT_TRACING_PLATFORM
742 #undef OPT_TRACING_TOPOLOGY
743 #undef OPT_TRACING_SMPI
744 #undef OPT_TRACING_SMPI_GROUP
745 #undef OPT_TRACING_CATEGORIZED
746 #undef OPT_TRACING_UNCATEGORIZED
747 #undef OPT_TRACING_MSG_PROCESS
748 #undef OPT_TRACING_FILENAME
749 #undef OPT_TRACING_BUFFER
750 #undef OPT_TRACING_ONELINK_ONLY
751 #undef OPT_TRACING_DISABLE_DESTROY
752 #undef OPT_TRACING_BASIC
753 #undef OPT_TRACING_COMMENT
754 #undef OPT_TRACING_COMMENT_FILE
755 #undef OPT_VIVA_UNCAT_CONF
756 #undef OPT_VIVA_CAT_CONF
758 #endif /* HAVE_TRACING */