1 /*! \page tracing Tracing Simulations
4 Tracing is widely used to observe and understand the behavior of
5 parallel applications and distributed algorithms. Usually, this is
6 done in a two-step fashion: the user instruments the application and
7 the traces are analyzed after the end of the execution. The analysis
8 can highlights unexpected behaviors, bottlenecks and sometimes can be
9 used to correct distributed algorithms. The SimGrid team has
10 instrumented the library in order to let users trace their simulations
11 and analyze them. This part of the user manual explains how the
12 tracing-related features can be enabled and used during the
13 development of simulators using the SimGrid library.
15 \section tracing_tracing_enabling Enabling using CMake
17 With the sources of SimGrid, it is possible to enable the tracing
18 using the parameter <b>-Denable_tracing=ON</b> when the cmake is
19 executed. The sections \ref instr_category_functions, \ref
20 instr_mark_functions, and \ref instr_uservariables_functions describe
21 all the functions available when this Cmake options is
22 activated. These functions will have no effect if SimGrid is
23 configured without this option (they are wiped-out by the
27 $ cmake -Denable_tracing=ON .
31 \section instr_category_functions Tracing categories functions
33 The SimGrid library is instrumented so users can trace the platform
34 utilization using MSG, SimDAG and SMPI interfaces. It registers how
35 much power is used for each host and how much bandwidth is used for
36 each link of the platform. The idea with this type of tracing is to
37 observe the overall view of resources utilization in the first place,
38 especially the identification of bottlenecks, load-balancing among
41 Another possibility is to trace resource utilization by
42 categories. Categorized resource utilization tracing gives SimGrid
43 users to possibility to classify MSG and SimDAG tasks by category,
44 tracing resource utilization for each of the categories. The functions
45 below let the user declare a category and apply it to tasks. <em>The
46 tasks that are not classified according to a category are not
47 traced</em>. Even if the user does not specify any category, the
48 simulations can still be traced in terms of resource utilization by
49 using a special parameter that is detailed below (see section \ref
50 tracing_tracing_options).
52 \li \c TRACE_category(const char *category)
53 \li \c TRACE_category_with_color(const char *category, const char *color)
54 \li \c MSG_task_set_category(msg_task_t task, const char *category)
55 \li \c MSG_task_get_category(msg_task_t task)
56 \li \c SD_task_set_category(SD_task_t task, const char *category)
57 \li \c SD_task_get_category(SD_task_t task)
59 \section instr_mark_functions Tracing marks functions
60 \li \c TRACE_declare_mark(const char *mark_type)
61 \li \c TRACE_mark(const char *mark_type, const char *mark_value)
63 \section instr_uservariables_functions Tracing user variables functions
67 \li \c TRACE_host_variable_declare(const char *variable)
68 \li \c TRACE_host_variable_declare_with_color(const char *variable, const char *color)
69 \li \c TRACE_host_variable_set(const char *host, const char *variable, double value)
70 \li \c TRACE_host_variable_add(const char *host, const char *variable, double value)
71 \li \c TRACE_host_variable_sub(const char *host, const char *variable, double value)
72 \li \c TRACE_host_variable_set_with_time(double time, const char *host, const char *variable, double value)
73 \li \c TRACE_host_variable_add_with_time(double time, const char *host, const char *variable, double value)
74 \li \c TRACE_host_variable_sub_with_time(double time, const char *host, const char *variable, double value)
78 \li \c TRACE_link_variable_declare(const char *variable)
79 \li \c TRACE_link_variable_declare_with_color(const char *variable, const char *color)
80 \li \c TRACE_link_variable_set(const char *link, const char *variable, double value)
81 \li \c TRACE_link_variable_add(const char *link, const char *variable, double value)
82 \li \c TRACE_link_variable_sub(const char *link, const char *variable, double value)
83 \li \c TRACE_link_variable_set_with_time(double time, const char *link, const char *variable, double value)
84 \li \c TRACE_link_variable_add_with_time(double time, const char *link, const char *variable, double value)
85 \li \c TRACE_link_variable_sub_with_time(double time, const char *link, const char *variable, double value)
87 For links, but use source and destination to get route:
89 \li \c TRACE_link_srcdst_variable_set(const char *src, const char *dst, const char *variable, double value)
90 \li \c TRACE_link_srcdst_variable_add(const char *src, const char *dst, const char *variable, double value)
91 \li \c TRACE_link_srcdst_variable_sub(const char *src, const char *dst, const char *variable, double value)
92 \li \c TRACE_link_srcdst_variable_set_with_time(double time, const char *src, const char *dst, const char *variable, double value)
93 \li \c TRACE_link_srcdst_variable_add_with_time(double time, const char *src, const char *dst, const char *variable, double value)
94 \li \c TRACE_link_srcdst_variable_sub_with_time(double time, const char *src, const char *dst, const char *variable, double value)
96 \section tracing_tracing_options Tracing configuration Options
98 To check which tracing options are available for your simulator, you
99 can just run it with the option \verbatim --help-tracing \endverbatim
100 to get a very detailed and updated explanation of each tracing
101 parameter. These are some of the options accepted by the tracing
102 system of SimGrid, you can use them by running your simulator with the
103 <b>--cfg=</b> switch:
108 Safe switch. It activates (or deactivates) the tracing system.
109 No other tracing options take effect if this one is not activated.
117 It activates the categorized resource utilization tracing. It should
118 be enabled if tracing categories are used by this simulator.
120 --cfg=tracing/categorized:yes
124 tracing/uncategorized
126 It activates the uncategorized resource utilization tracing. Use it if
127 this simulator do not use tracing categories and resource use have to be
130 --cfg=tracing/uncategorized:yes
136 A file with this name will be created to register the simulation. The file
137 is in the Paje format and can be analyzed using Viva or Paje visualization
138 tools. More information can be found in these webpages:
139 <a href="http://github.com/schnorr/viva/">http://github.com/schnorr/viva/</a>
140 <a href="http://github.com/schnorr/pajeng/">http://github.com/schnorr/pajeng/</a>
142 --cfg=tracing/filename:mytracefile.trace
144 If you do not provide this parameter, the trace file will be named simgrid.trace.
149 This option only has effect if this simulator is SMPI-based. Traces the MPI
150 interface and generates a trace that can be analyzed using Gantt-like
151 visualizations. Every MPI function (implemented by SMPI) is transformed in a
152 state, and point-to-point communications can be analyzed with arrows.
154 --cfg=tracing/smpi:yes
160 This option only has effect if this simulator is SMPI-based. The processes
161 are grouped by the hosts where they were executed.
163 --cfg=tracing/smpi/group:yes
167 tracing/smpi/computing
169 This option only has effect if this simulator is SMPI-based. The parts external
170 to SMPI are also outputted to the trace. Provides better way to analyze the data automatically.
172 --cfg=tracing/smpi/computing:yes
176 tracing/smpi/internals
178 This option only has effect if this simulator is SMPI-based. Display internal communications
179 happening during a collective MPI call.
181 --cfg=tracing/smpi/internals:yes
185 tracing/smpi/display_sizes
187 This option only has effect if this simulator is SMPI-based. Display the sizes of the messages
188 exchanged in the trace, both in the links and on the states. For collective, size means the global size of data sent by the process in general.
190 --cfg=tracing/smpi/display_sizes:yes
194 tracing/smpi/sleeping
210 tracing/smpi/format/ti_one_file
228 This option only has effect if this simulator is MSG-based. It traces the
229 behavior of all categorized MSG processes, grouping them by hosts. This option
230 can be used to track process location if this simulator has process migration.
232 --cfg=tracing/msg/process:yes
238 This option put some events in a time-ordered buffer using the
239 insertion sort algorithm. The process of acquiring and releasing
240 locks to access this buffer and the cost of the sorting algorithm
241 make this process slow. The simulator performance can be severely
242 impacted if this option is activated, but you are sure to get a trace
243 file with events sorted.
245 --cfg=tracing/buffer:yes
251 This option changes the way SimGrid register its platform on the trace
252 file. Normally, the tracing considers all routes (no matter their
253 size) on the platform file to re-create the resource topology. If this
254 option is activated, only the routes with one link are used to
255 register the topology within an AS. Routes among AS continue to be
258 --cfg=tracing/onelink_only:yes
270 tracing/disable_power
278 tracing/disable_destroy
280 Disable the destruction of containers at the end of simulation. This
281 can be used with simulators that have a different notion of time
282 (different from the simulated time).
284 --cfg=tracing/disable_destroy:yes
290 Some visualization tools are not able to parse correctly the Paje file format.
291 Use this option if you are using one of these tools to visualize the simulation
292 trace. Keep in mind that the trace might be incomplete, without all the
293 information that would be registered otherwise.
295 --cfg=tracing/basic:yes
301 Use this to add a comment line to the top of the trace file.
303 --cfg=tracing/comment:my_string
309 Use this to add the contents of a file to the top of the trace file as comment.
311 --cfg=tracing/comment_file:textual_file.txt
331 tracing/platform/topology
341 This option generates a graph configuration file for Viva considering
342 categorized resource utilization.
344 --cfg=viva/categorized:graph_categorized.plist
350 This option generates a graph configuration file for Viva considering
351 uncategorized resource utilization.
353 --cfg=viva/uncategorized:graph_uncategorized.plist
356 Please pass \verbatim --help-tracing \endverbatim to your simulator
357 for the updated list of tracing options.
359 \section tracing_tracing_example_parameters Case studies
361 Some scenarios that might help you decide which tracing options
362 you should use to analyze your simulator.
364 \li I want to trace the resource utilization of all hosts
365 and links of the platform, and my simulator <b>does not</b> use
366 the tracing API. For that, you can run a uncategorized trace
367 with the following parameters (it will work with <b>any</b> Simgrid
372 --cfg=tracing/uncategorized:yes \
373 --cfg=tracing/filename:mytracefile.trace \
374 --cfg=viva/uncategorized:uncat.plist
377 \li I want to trace only a subset of my MSG (or SimDAG) tasks.
378 For that, you will need to create tracing categories using the
379 <b>TRACE_category (...)</b> function (as explained above),
380 and then classify your tasks to a previously declared category
381 using the <b>MSG_task_set_category (...)</b>
382 (or <b>SD_task_set_category (...)</b> for SimDAG tasks). After
383 recompiling, run your simulator with the following parameters:
387 --cfg=tracing/categorized:yes \
388 --cfg=tracing/filename:mytracefile.trace \
389 --cfg=viva/categorized:cat.plist
393 \section tracing_tracing_example Example of Instrumentation
395 A simplified example using the tracing mandatory functions.
398 int main (int argc, char **argv)
400 MSG_init (&argc, &argv);
402 //(... after deployment ...)
404 //note that category declaration must be called after MSG_create_environment
405 TRACE_category_with_color ("request", "1 0 0");
406 TRACE_category_with_color ("computation", "0.3 1 0.4");
407 TRACE_category ("finalize");
409 msg_task_t req1 = MSG_task_create("1st_request_task", 10, 10, NULL);
410 msg_task_t req2 = MSG_task_create("2nd_request_task", 10, 10, NULL);
411 msg_task_t req3 = MSG_task_create("3rd_request_task", 10, 10, NULL);
412 msg_task_t req4 = MSG_task_create("4th_request_task", 10, 10, NULL);
413 MSG_task_set_category (req1, "request");
414 MSG_task_set_category (req2, "request");
415 MSG_task_set_category (req3, "request");
416 MSG_task_set_category (req4, "request");
418 msg_task_t comp = MSG_task_create ("comp_task", 100, 100, NULL);
419 MSG_task_set_category (comp, "computation");
421 msg_task_t finalize = MSG_task_create ("finalize", 0, 0, NULL);
422 MSG_task_set_category (finalize, "finalize");
431 \section tracing_tracing_analyzing Analyzing SimGrid Simulation Traces
433 A SimGrid-based simulator, when executed with the correct parameters
434 (see above) creates a trace file in the Paje file format holding the
435 simulated behavior of the application or the platform. You have
436 several options to analyze this trace file:
438 - Dump its contents to a CSV-like format using `pj_dump` (see <a
439 href="https://github.com/schnorr/pajeng/wiki/pj_dump">PajeNG's wiki
440 on pj_dump</a> and more generally the <a
441 href="https://github.com/schnorr/pajeng/">PajeNG suite</a>) and use
442 gnuplot to plot resource usage, time spent on blocking/executing
443 functions, and so on. Filtering capabilities are at your hand by
444 doing `grep`, with the best regular expression you can provide, to
445 get only parts of the trace (for instance, only a subset of
446 resources or processes).
448 - Derive statistics from trace metrics (the ones built-in with any
449 SimGrid simulation, but also those metrics you injected in the trace
450 using the TRACE module) using the <a
451 href="http://www.r-project.org/">R project</a> and all its
452 modules. You can also combine R with <a
453 href="http://ggplot2.org/">ggplot2</a> to get a number of high
454 quality plots from your simulation metrics. You need to `pj_dump`
455 the contents of the SimGrid trace file to use R.
457 - Visualize the behavior of your simulation using classic space/time
458 views (gantt-charts) provided by the <a
459 href="https://github.com/schnorr/pajeng/">PajeNG suite</a> and any
460 other tool that supports the <a
461 href="http://paje.sourceforge.net/download/publication/lang-paje.pdf">Paje
462 file format</a>. Consider this option if you need to understand the
463 causality of your distributed simulation.
465 - Visualize the behavior of your simulation with treemaps (specially
466 if your simulation has a platform with several thousand resources),
467 provided by the <a href="http://github.com/schnorr/viva/">Viva</a>
468 visualization tool. See <a
469 href="https://github.com/schnorr/viva/wiki">Viva's wiki</a> for
470 further details on what is a treemap and how to use it.
472 - Correlate the behavior of your simulator with the platform topology
473 with an interactive, force-directed, and hierarchical graph
474 visualization, provided by <a
475 href="http://github.com/schnorr/viva/">Viva</a>. Check <a
476 href="https://github.com/schnorr/viva/wiki">Viva's wiki</a> for
477 further details. This <a
478 href="http://hal.inria.fr/hal-00738321/">research report</a>,
479 published at ISPASS 2013, has a detailed description of this
480 visualization technique.
482 - You can also check our online <a
483 href="http://simgrid.gforge.inria.fr/tutorials.html"> tutorial
484 section</a> that contains a dedicated tutorial with several
485 suggestions on how to use the tracing infrastructure. Look for the
486 SimGrid User::Visualization 101 tutorial.
488 - Ask for help on the <a
489 href="mailto:simgrid-user@lists.gforge.inria.fr">simgrid-user@lists.gforge.inria.fr</a>
490 mailing list, giving us a detailed explanation on what your
491 simulator does and what kind of information you want to trace. You
492 can also check the <a
493 href="http://lists.gforge.inria.fr/pipermail/simgrid-user/">mailing
494 list archive</a> for old messages regarding tracing and analysis.
496 \subsection tracing_viva_analysis Viva Visualization Tool
498 This subsection describe some of the concepts regarding the <a
499 href="http://github.com/schnorr/viva/">Viva Visualization Tool</a> and
500 its relation with SimGrid traces. You should refer to Viva's website
501 for further details on all its visualization techniques.
503 \subsubsection tracing_viva_time_slice Time Slice
505 The analysis of a trace file using the tool always takes into account
506 the concept of the <em>time-slice</em>. This concept means that what
507 is being visualized in the screen is always calculated considering a
508 specific time frame, with its beggining and end timestamp. The
509 time-slice is configured by the user and can be changed dynamically
510 through the window called <em>Time Interval</em> that is opened
511 whenever a trace file is being analyzed. Users are capable to select
512 the beggining and size of the time slice.
514 \subsubsection tracing_viva_graph Hierarchical Graph View
516 %As stated above (see section \ref tracing_tracing_analyzing), one
517 possibility to analyze SimGrid traces is to use Viva's graph view with
518 a graph configuration to customize the graph according to the
519 traces. A valid graph configuration (we are using the non-XML <a
520 href="http://en.wikipedia.org/wiki/Property_list">Property List
521 Format</a> to describe the configuration) can be created for any
522 SimGrid-based simulator using the
523 <em>--cfg=viva/uncategorized:graph_uncategorized.plist</em> or
524 <em>--cfg=viva/categorized:graph_categorized.plist</em> (if the
525 simulator defines resource utilization categories) when executing the
528 \subsubsection basic_conf Basic Graph Configuration
530 The basic description of the configuration is as follows:
533 node = (LINK, HOST, );
534 edge = (HOST-LINK, LINK-HOST, LINK-LINK, );
537 The nodes of the graph will be created based on the <i>node</i>
538 parameter, which in this case is the different <em>"HOST"</em>s and
539 <em>"LINK"</em>s of the platform used to simulate. The <i>edge</i>
540 parameter indicates that the edges of the graph will be created based
541 on the <em>"HOST-LINK"</em>s, <em>"LINK-HOST"</em>s, and
542 <em>"LINK-LINK"</em>s of the platform. After the definition of these
543 two parameters, the configuration must detail how the nodes
544 (<em>HOST</em>s and <em>LINK</em>s) should be drawn.
546 For that, the configuration must have an entry for each of
547 the types used. For <em>HOST</em>, as basic configuration, we have:
553 values = (power_used);
557 The parameter <em>size</em> indicates which variable from the trace
558 file will be used to define the size of the node HOST in the
559 visualization. If the simulation was executed with availability
560 traces, the size of the nodes will be changed according to these
561 traces. The parameter <em>type</em> indicates which geometrical shape
562 will be used to represent HOST, and the <em>values</em> parameter
563 indicates which values from the trace will be used to fill the shape.
565 For <em>LINK</em> we have:
571 values = (bandwidth_used);
576 The same configuration parameters are used here: <em>type</em> (with a
577 rhombus), the <em>size</em> (whose value is from trace's bandwidth
578 variable) and the <em>values</em>.
580 \subsubsection custom_graph Customizing the Graph Representation
582 Viva is capable to handle a customized graph representation based on
583 the variables present in the trace file. In the case of SimGrid, every
584 time a category is created for tasks, two variables in the trace file
585 are defined: one to indicate node utilization (how much power was used
586 by that task category), and another to indicate link utilization (how
587 much bandwidth was used by that category). For instance, if the user
588 declares a category named <i>request</i>, there will be variables
589 named <b>p</b><i>request</i> and a <b>b</b><i>request</i> (<b>p</b>
590 for power and <b>b</b> for bandwidth). It is important to notice that
591 the variable <i>prequest</i> in this case is only available for HOST,
592 and <i>brequest</i> is only available for LINK. <b>Example</b>:
593 suppose there are two categories for tasks: request and compute. To
594 create a customized graph representation with a proportional
595 separation of host and link utilization, use as configuration for HOST
602 values = (prequest, pcomputation);
607 values = (brequest, bcomputation);
611 This configuration enables the analysis of resource utilization by MSG
612 tasks through the identification of load-balancing issues and network
613 bottlenecks, for instance.