1 /*! \page tracing Tracing Simulations for Visualization
3 \htmlinclude .tracing.doc.toc
5 \section tracing_tracing Tracing Simulations for Visualization
7 The trace visualization is widely used to observe and understand the behavior
8 of parallel applications and distributed algorithms. Usually, this is done in a
9 two-step fashion: the user instruments the application and the traces are
10 analyzed after the end of the execution. The visualization itself can highlights
11 unexpected behaviors, bottlenecks and sometimes can be used to correct
12 distributed algorithms. The SimGrid team has instrumented the library
13 in order to let users trace their simulations and analyze them. This part of the
14 user manual explains how the tracing-related features can be enabled and used
15 during the development of simulators using the SimGrid library.
17 \subsection tracing_tracing_howitworks How it works
19 For now, the SimGrid library is instrumented so users can trace the <b>platform
20 utilization</b> using the MSG, SimDAG and SMPI interface. This means that the tracing will
21 register how much power is used for each host and how much bandwidth is used for
22 each link of the platform. The idea with this type of tracing is to observe the
23 overall view of resources utilization in the first place, especially the
24 identification of bottlenecks, load-balancing among hosts, and so on.
26 The idea of the tracing facilities is to give SimGrid users to possibility to
27 classify MSG and SimDAG tasks by category, tracing the platform utilization
28 (hosts and links) for each of the categories. For that,
29 the tracing interface enables the declaration of categories and a function to
30 mark a task with a previously declared category. <em>The tasks that are not
31 classified according to a category are not traced</em>. Even if the user
32 does not specify any category, the simulations can still be traced in terms
33 of resource utilization by using a special parameter that is detailed below.
35 \subsection tracing_tracing_enabling Enabling using CMake
37 With the sources of SimGrid, it is possible to enable the tracing
38 using the parameter <b>-Denable_tracing=ON</b> when the cmake is executed.
39 The section \ref tracing_tracing_functions describes all the functions available
40 when this Cmake options is activated. These functions will have no effect
41 if SimGrid is configured without this option (they are wiped-out by the
45 $ cmake -Denable_tracing=ON .
49 \subsection instr_category_functions Tracing categories functions
50 \li \c TRACE_category(const char *category)
51 \li \c TRACE_category_with_color(const char *category, const char *color)
52 \li \c MSG_task_set_category(m_task_t task, const char *category)
53 \li \c MSG_task_get_category(m_task_t task)
54 \li \c SD_task_set_category(SD_task_t task, const char *category)
55 \li \c SD_task_get_category(SD_task_t task)
57 \subsection instr_mark_functions Tracing marks functions
58 \li \c TRACE_declare_mark(const char *mark_type)
59 \li \c TRACE_mark(const char *mark_type, const char *mark_value)
61 \subsection instr_uservariables_functions Tracing user variables functions
65 \li \c TRACE_host_variable_declare(const char *variable)
66 \li \c TRACE_host_variable_declare_with_color(const char *variable, const char *color)
67 \li \c TRACE_host_variable_set(const char *host, const char *variable, double value)
68 \li \c TRACE_host_variable_add(const char *host, const char *variable, double value)
69 \li \c TRACE_host_variable_sub(const char *host, const char *variable, double value)
70 \li \c TRACE_host_variable_set_with_time(double time, const char *host, const char *variable, double value)
71 \li \c TRACE_host_variable_add_with_time(double time, const char *host, const char *variable, double value)
72 \li \c TRACE_host_variable_sub_with_time(double time, const char *host, const char *variable, double value)
76 \li \c TRACE_link_variable_declare(const char *variable)
77 \li \c TRACE_link_variable_declare_with_color(const char *variable, const char *color)
78 \li \c TRACE_link_variable_set(const char *link, const char *variable, double value)
79 \li \c TRACE_link_variable_add(const char *link, const char *variable, double value)
80 \li \c TRACE_link_variable_sub(const char *link, const char *variable, double value)
81 \li \c TRACE_link_variable_set_with_time(double time, const char *link, const char *variable, double value)
82 \li \c TRACE_link_variable_add_with_time(double time, const char *link, const char *variable, double value)
83 \li \c TRACE_link_variable_sub_with_time(double time, const char *link, const char *variable, double value)
85 For links, but use source and destination to get route:
87 \li \c TRACE_link_srcdst_variable_set(const char *src, const char *dst, const char *variable, double value)
88 \li \c TRACE_link_srcdst_variable_add(const char *src, const char *dst, const char *variable, double value)
89 \li \c TRACE_link_srcdst_variable_sub(const char *src, const char *dst, const char *variable, double value)
90 \li \c TRACE_link_srcdst_variable_set_with_time(double time, const char *src, const char *dst, const char *variable, double value)
91 \li \c TRACE_link_srcdst_variable_add_with_time(double time, const char *src, const char *dst, const char *variable, double value)
92 \li \c TRACE_link_srcdst_variable_sub_with_time(double time, const char *src, const char *dst, const char *variable, double value)
94 \subsection tracing_tracing_options Tracing configuration Options
96 To check which tracing options are available for your simulator, you
97 can just run it with the option <b>--help-tracing</b>. These are the
98 options accepted by the tracing system of SimGrid as of today, you
99 can use them by running your simulator with the <b>--cfg=</b> switch:
104 Safe switch. It activates (or deactivates) the tracing system.
105 No other tracing options take effect if this one is not activated.
113 It activates the categorized resource utilization tracing. It should
114 be enabled if tracing categories are used by this simulator.
116 --cfg=tracing/categorized:1
120 tracing/uncategorized
122 It activates the uncategorized resource utilization tracing. Use it if
123 this simulator do not use tracing categories and resource use have to be
126 --cfg=tracing/uncategorized:1
132 A file with this name will be created to register the simulation. The file
133 is in the Paje format and can be analyzed using Triva or Paje visualization
134 tools. More information can be found in these webpages:
135 <a href="http://triva.gforge.inria.fr/">http://triva.gforge.inria.fr/</a>
136 <a href="http://paje.sourceforge.net/">http://paje.sourceforge.net/</a>
138 --cfg=tracing/filename:mytracefile.trace
140 If you do not provide this parameter, the trace file will be named simgrid.trace.
145 By default, the tracing system uses all routes in the platform file
146 to re-create a "graph" of the platform and register it in the trace file.
147 This option let the user tell the tracing system to use only the routes
148 that are composed with just one link.
150 --cfg=tracing/onelink_only:1
156 This option only has effect if this simulator is SMPI-based. Traces the MPI
157 interface and generates a trace that can be analyzed using Gantt-like
158 visualizations. Every MPI function (implemented by SMPI) is transformed in a
159 state, and point-to-point communications can be analyzed with arrows.
167 This option only has effect if this simulator is SMPI-based. The processes
168 are grouped by the hosts where they were executed.
170 --cfg=tracing/smpi/group:1
176 This option only has effect if this simulator is MSG-based. It traces the
177 behavior of all categorized MSG processes, grouping them by hosts. This option
178 can be used to track process location if this simulator has process migration.
180 --cfg=tracing/msg/process:1
186 This option put some events in a time-ordered buffer using the
187 insertion sort algorithm. The process of acquiring and releasing
188 locks to access this buffer and the cost of the sorting algorithm
189 make this process slow. The simulator performance can be severely
190 impacted if this option is activated, but you are sure to get a trace
191 file with events sorted.
193 --cfg=tracing/buffer:1
199 This option changes the way SimGrid register its platform on the trace
200 file. Normally, the tracing considers all routes (no matter their
201 size) on the platform file to re-create the resource topology. If this
202 option is activated, only the routes with one link are used to
203 register the topology within an AS. Routes among AS continue to be
206 --cfg=tracing/onelink_only:1
210 tracing/disable_destroy
212 Disable the destruction of containers at the end of simulation. This
213 can be used with simulators that have a different notion of time
214 (different from the simulated time).
216 --cfg=tracing/disable_destroy:1
222 This option generates a graph configuration file for Triva considering
223 categorized resource utilization.
225 --cfg=triva/categorized:graph_categorized.plist
231 This option generates a graph configuration file for Triva considering
232 uncategorized resource utilization.
234 --cfg=triva/uncategorized:graph_uncategorized.plist
237 \subsection tracing_tracing_example_parameters Case studies
239 Some scenarios that might help you decide which tracing options
240 you should use to analyze your simulator.
242 \li I want to trace the resource utilization of all hosts
243 and links of the platform, and my simulator <b>does not</b> use
244 the tracing API. For that, you can run a uncategorized trace
245 with the following parameters (it will work with <b>any</b> Simgrid
250 --cfg=tracing/uncategorized:1 \
251 --cfg=tracing/filename:mytracefile.trace \
252 --cfg=triva/uncategorized:uncat.plist
255 \li I want to trace only a subset of my MSG (or SimDAG) tasks.
256 For that, you will need to create tracing categories using the
257 <b>TRACE_category (...)</b> function (as explained above),
258 and then classify your tasks to a previously declared category
259 using the <b>TRACE_msg_set_task_category (...)</b>
260 (or <b>TRACE_sd_set_task_category (...)</b> for SimDAG tasks). After
261 recompiling, run your simulator with the following parameters:
265 --cfg=tracing/categorized:1 \
266 --cfg=tracing/filename:mytracefile.trace \
267 --cfg=triva/categorized:cat.plist
271 \subsection tracing_tracing_example Example of Instrumentation
273 A simplified example using the tracing mandatory functions.
276 int main (int argc, char **argv)
278 MSG_global_init (&argc, &argv);
280 //(... after deployment ...)
282 //note that category declaration must be called after MSG_create_environment
283 TRACE_category_with_color ("request", "1 0 0");
284 TRACE_category_with_color ("computation", "0.3 1 0.4");
285 TRACE_category ("finalize");
287 m_task_t req1 = MSG_task_create("1st_request_task", 10, 10, NULL);
288 m_task_t req2 = MSG_task_create("2nd_request_task", 10, 10, NULL);
289 m_task_t req3 = MSG_task_create("3rd_request_task", 10, 10, NULL);
290 m_task_t req4 = MSG_task_create("4th_request_task", 10, 10, NULL);
291 TRACE_msg_set_task_category (req1, "request");
292 TRACE_msg_set_task_category (req2, "request");
293 TRACE_msg_set_task_category (req3, "request");
294 TRACE_msg_set_task_category (req4, "request");
296 m_task_t comp = MSG_task_create ("comp_task", 100, 100, NULL);
297 TRACE_msg_set_task_category (comp, "computation");
299 m_task_t finalize = MSG_task_create ("finalize", 0, 0, NULL);
300 TRACE_msg_set_task_category (finalize, "finalize");
309 \subsection tracing_tracing_analyzing Analyzing the SimGrid Traces
311 The SimGrid library, during an instrumented simulation, creates a trace file in
312 the Paje file format that contains the platform utilization for the simulation
313 that was executed. The visualization analysis of this file is performed with the
314 visualization tool <a href="http://triva.gforge.inria.fr">Triva</a>, with
315 special configurations tunned to SimGrid needs. This part of the documentation
316 explains how to configure and use Triva to analyse a SimGrid trace file.
318 - <b>Installing Triva</b>: the tool is available in the Inria's Forge,
319 at <a href="http://triva.gforge.inria.fr">http://triva.gforge.inria.fr</a>.
320 Use the following command to get the sources, and then check the file
321 <i>INSTALL</i>. This file contains instructions to install
322 the tool's dependencies in a Ubuntu/Debian Linux. The tool can also
323 be compiled in MacOSX natively, check <i>INSTALL.mac</i> file.
325 $ git clone git://scm.gforge.inria.fr/triva/triva.git
330 - <b>Executing Triva</b>: a binary called <i>Triva</i> is available after the
331 installation (you can execute it passing <em>--help</em> to check its
332 options). If the triva binary is not available after following the
333 installation instructions, you may want to execute the following command to
334 initialize the GNUstep environment variables. We strongly recommend that you
335 use the latest GNUstep packages, and not the packages available through apt-get
336 in Ubuntu/Debian packaging systems. If you install GNUstep using the latest
337 available packages, you can execute this command:
339 $ source /usr/GNUstep/System/Library/Makefiles/GNUstep.sh
341 You should be able to see this output after the installation of triva:
343 $ ./Triva.app/Triva --help
344 Usage: Triva [OPTIONS...] TRACE0 [TRACE1]
345 Trace Analysis through Visualization
348 --ti_frequency {double} Animation: frequency of updates
349 --ti_hide Hide the TimeInterval window
350 --ti_forward {double} Animation: value to move time-slice
351 --ti_apply Apply the configuration
352 --ti_update Update on slider change
353 --ti_animate Start animation
354 --ti_start {double} Start of time slice
355 --ti_size {double} Size of time slice
357 --comparison Compare Trace Files (Experimental)
358 --graph Configurable Graph
359 --list Print Trace Type Hierarchy
360 --hierarchy Export Trace Type Hierarchy (dot)
361 --stat Trace Statistics and Memory Utilization
362 --instances List All Trace Entities
363 --linkview Link View (Experimental)
364 --treemap Squarified Treemap
365 --merge Merge Trace Files (Experimental)
366 --check Check Trace File Integrity
368 --gc_conf {file} Graph Configuration in Property List Format
369 --gc_apply Apply the configuration
370 --gc_hide Hide the GraphConfiguration window
372 Triva expects that the user choose one of the available options
373 (currently <em>--graph</em> or <em>--treemap</em> for a visualization analysis)
374 and the trace file from the simulation.
376 - <b>Understanding Triva - time-slice</b>: the analysis of a trace file using
377 the tool always takes into account the concept of the <em>time-slice</em>.
378 This concept means that what is being visualized in the screen is always
379 calculated considering a specific time frame, with its beggining and end
380 timestamp. The time-slice is configured by the user and can be changed
381 dynamically through the window called <em>Time Interval</em> that is opened
382 whenever a trace file is being analyzed. The next figure depicts the time-slice
383 configuration window.
384 In the top of the window, in the space named <i>Trace Time</i>,
385 the two fields show the beggining of the trace (which usually starts in 0) and
386 the end (that depends on the time simulated by SimGrid). The middle of the
387 window, in the square named <i>Time Slice Configuration</i>, contains the
388 aspects related to the time-slice, including its <i>start</i> and its
389 <i>size</i>. The gray rectangle in the bottom of this part indicates the
390 <i>current time-slice</i> that is considered for the drawings. If the checkbox
391 <i>Update Drawings on Sliders Change</i> is not selected, the button
392 <i>Apply</i> must be clicked in order to inform triva that the
393 new time-slice must be considered. The bottom part of the window, in the space
394 indicated by the square <i>Time Slice Animation</i> can be used to advance
395 the time-frame automatically. The user configures the amount of time that the
396 time-frame will forward and how frequent this update will happen. Once this is
397 configured, the user clicks the <i>Play</i> button in order to see the dynamic
398 changes on the drawings.
401 <a href="triva-time_interval.png" border=0><img src="triva-time_interval.png" width="50%" border=0></a>
404 <b>Remarks:</b> when the trace has too many hosts or links, the computation to
405 take into account a new time-slice can be expensive. When this happens, the
406 <i>Frequency</i> parameter, but also updates caused by change on configurations
407 when the checkbox <i>Update Drawings on Sliders
408 Change</i> is selected will not be followed.
410 - <b>Understanding Triva - graph</b>: one possibility to analyze
411 SimGrid traces is to use Triva's graph view, using the
412 <em>--graph</em> parameter to activate this view, and
413 <em>--gc_conf</em> with a graph configuration to customize the graph
414 according to the traces. A valid graph configuration (we are using
416 href="http://en.wikipedia.org/wiki/Property_list">Property List
417 Format</a> to describe the configuration) can be created for any
418 SimGrid-based simulator using the
419 <em>--cfg=triva/uncategorized:graph_uncategorized.plist</em> or
420 <em>--cfg=triva/categorized:graph_categorized.plist</em> (if the
421 simulator defines resource utilization categories) when executing
424 <b>Basic SimGrid Configuration</b>: The basic description of the configuration
428 node = (LINK, HOST, );
429 edge = (HOST-LINK, LINK-HOST, LINK-LINK, );
432 The nodes of the graph will be created based on the <i>node</i>
433 parameter, which in this case is the different <em>"HOST"</em>s and
434 <em>"LINK"</em>s of the platform used to simulate. The <i>edge</i>
435 parameter indicates that the edges of the graph will be created based
436 on the <em>"HOST-LINK"</em>s, <em>"LINK-HOST"</em>s, and
437 <em>"LINK-LINK"</em>s of the platform. After the definition of these
438 two parameters, the configuration must detail how the nodes
439 (<em>HOST</em>s and <em>LINK</em>s) should be drawn.
441 For that, the configuration must have an entry for each of
442 the types used. For <em>HOST</em>, as basic configuration, we have:
448 values = (power_used);
452 The parameter <em>size</em> indicates which variable from the trace
453 file will be used to define the size of the node HOST in the
454 visualization. If the simulation was executed with availability
455 traces, the size of the nodes will be changed according to these
456 traces. The parameter <em>type</em> indicates which geometrical shape
457 will be used to represent HOST, and the <em>values</em> parameter
458 indicates which values from the trace will be used to fill the shape.
460 For <em>LINK</em> we have:
466 values = (bandwidth_used);
471 The same configuration parameters are used here: <em>type</em> (with a
472 rhombus), the <em>size</em> (whose value is from trace's bandwidth
473 variable) and the <em>values</em>.
475 <b>Customizing the Graph Representation</b>: triva is capable to handle
476 a customized graph representation based on the variables present in the trace
477 file. In the case of SimGrid, every time a category is created for tasks, two
478 variables in the trace file are defined: one to indicate node utilization (how
479 much power was used by that task category), and another to indicate link
480 utilization (how much bandwidth was used by that category). For instance, if the
481 user declares a category named <i>request</i>, there will be variables named
482 <b>p</b><i>request</i> and a <b>b</b><i>request</i> (<b>p</b> for power and
483 <b>b</b> for bandwidth). It is important to notice that the variable
484 <i>prequest</i> in this case is only available for HOST, and
485 <i>brequest</i> is only available for LINK. <b>Example</b>: suppose there are
486 two categories for tasks: request and compute. To create a customized graph
487 representation with a proportional separation of host and link utilization, use
488 as configuration for HOST and LINK this:
494 values = (prequest, pcomputation);
499 values = (brequest, bcomputation);
503 This configuration enables the analysis of resource utilization by MSG tasks,
504 and the identification of load-balancing issues, network bottlenecks, for
507 <b>The Graph Visualization</b>: The next figure shows a graph visualization of a
508 given time-slice of the masterslave_forwarder example (present in the SimGrid
509 sources). The red color indicates tasks from the <i>compute</i> category. This
510 visualization was generated with the following configuration:
514 node = (LINK, HOST, );
515 edge = (HOST-LINK, LINK-HOST, LINK-LINK, );
520 values = (pcompute, pfinalize);
525 values = (bcompute, bfinalize);
532 <a href="triva-graph_visualization.png" border=0><img src="triva-graph_visualization.png" width="50%" border=0></a>
536 - <b>Understading Triva - colors</b>: Colors are now registered in
537 trace files. See the tracing API to how to define them for your