Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
doc: add an hint on platform calibration, and various fixes
[simgrid.git] / docs / source / Configuring_SimGrid.rst
1 .. _options:
2
3 Configuring SimGrid
4 ===================
5
6 .. raw:: html
7
8    <object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
9    <script>
10    window.onload=function() { // Wait for the SVG to be loaded before changing it
11      var elem=document.querySelector("#TOC").contentDocument.getElementById("ConfigBox")
12      elem.style="opacity:0.93999999;fill:#ff0000;fill-opacity:0.1;stroke:#000000;stroke-width:0.35277778;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1";
13    }
14    </script>
15    <br/>
16    <br/>
17
18 A number of options can be given at runtime to change the default
19 SimGrid behavior. For a complete list of all configuration options
20 accepted by the SimGrid version used in your simulator, simply pass
21 the --help configuration flag to your program. If some of the options
22 are not documented on this page, this is a bug that you should please
23 report so that we can fix it. Note that some of the options presented
24 here may not be available in your simulators, depending on the
25 :ref:`compile-time options <install_src_config>` that you used.
26
27 Setting Configuration Items
28 ---------------------------
29
30 There is several way to pass configuration options to the simulators.
31 The most common way is to use the ``--cfg`` command line argument. For
32 example, to set the item ``Item`` to the value ``Value``, simply
33 type the following on the command-line:
34
35 .. code-block:: shell
36
37    my_simulator --cfg=Item:Value (other arguments)
38
39 Several ``--cfg`` command line arguments can naturally be used. If you
40 need to include spaces in the argument, don't forget to quote the
41 argument. You can even escape the included quotes (write ``@'`` for ``'`` if
42 you have your argument between simple quotes).
43
44 Another solution is to use the ``<config>`` tag in the platform file. The
45 only restriction is that this tag must occur before the first
46 platform element (be it ``<zone>``, ``<cluster>``, ``<peer>`` or whatever).
47 The ``<config>`` tag takes an ``id`` attribute, but it is currently
48 ignored so you don't really need to pass it. The important part is that
49 within that tag, you can pass one or several ``<prop>`` tags to specify
50 the configuration to use. For example, setting ``Item`` to ``Value``
51 can be done by adding the following to the beginning of your platform
52 file:
53
54 .. code-block:: xml
55
56   <config>
57     <prop id="Item" value="Value"/>
58   </config>
59
60 A last solution is to pass your configuration directly in your program
61 with :cpp:func:`simgrid::s4u::Engine::set_config` or :cpp:func:`MSG_config`.
62
63 .. code-block:: cpp
64
65    #include <simgrid/s4u.hpp>
66
67    int main(int argc, char *argv[]) {
68      simgrid::s4u::Engine e(&argc, argv);
69
70      simgrid::s4u::Engine::set_config("Item:Value");
71
72      // Rest of your code
73    }
74
75 .. _options_list:
76
77 Existing Configuration Items
78 ----------------------------
79
80 .. note::
81   The full list can be retrieved by passing ``--help`` and
82   ``--help-cfg`` to an executable that uses SimGrid. Try passing
83   ``help`` as a value to get the list of values accepted by a given
84   option. For example, ``--cfg=plugin:help`` will give you the list
85   of plugins available in your installation of SimGrid.
86
87 - **contexts/factory:** :ref:`cfg=contexts/factory`
88 - **contexts/guard-size:** :ref:`cfg=contexts/guard-size`
89 - **contexts/nthreads:** :ref:`cfg=contexts/nthreads`
90 - **contexts/stack-size:** :ref:`cfg=contexts/stack-size`
91 - **contexts/synchro:** :ref:`cfg=contexts/synchro`
92
93 - **cpu/maxmin-selective-update:** :ref:`Cpu Optimization Level <options_model_optim>`
94 - **cpu/model:** :ref:`options_model_select`
95 - **cpu/optim:** :ref:`Cpu Optimization Level <options_model_optim>`
96
97 - **debug/breakpoint:** :ref:`cfg=debug/breakpoint`
98 - **debug/clean-atexit:** :ref:`cfg=debug/clean-atexit`
99 - **debug/verbose-exit:** :ref:`cfg=debug/verbose-exit`
100
101 - **exception/cutpath:** :ref:`cfg=exception/cutpath`
102
103 - **host/model:** :ref:`options_model_select`
104
105 - **maxmin/precision:** :ref:`cfg=maxmin/precision`
106 - **maxmin/concurrency-limit:** :ref:`cfg=maxmin/concurrency-limit`
107
108 - **msg/debug-multiple-use:** :ref:`cfg=msg/debug-multiple-use`
109
110 - **model-check:** :ref:`options_modelchecking`
111 - **model-check/checkpoint:** :ref:`cfg=model-check/checkpoint`
112 - **model-check/communications-determinism:** :ref:`cfg=model-check/communications-determinism`
113 - **model-check/dot-output:** :ref:`cfg=model-check/dot-output`
114 - **model-check/max-depth:** :ref:`cfg=model-check/max-depth`
115 - **model-check/property:** :ref:`cfg=model-check/property`
116 - **model-check/reduction:** :ref:`cfg=model-check/reduction`
117 - **model-check/replay:** :ref:`cfg=model-check/replay`
118 - **model-check/send-determinism:** :ref:`cfg=model-check/send-determinism`
119 - **model-check/termination:** :ref:`cfg=model-check/termination`
120 - **model-check/timeout:** :ref:`cfg=model-check/timeout`
121 - **model-check/visited:** :ref:`cfg=model-check/visited`
122
123 - **network/bandwidth-factor:** :ref:`cfg=network/bandwidth-factor`
124 - **network/crosstraffic:** :ref:`cfg=network/crosstraffic`
125 - **network/latency-factor:** :ref:`cfg=network/latency-factor`
126 - **network/loopback-lat:** :ref:`cfg=network/loopback`
127 - **network/loopback-bw:** :ref:`cfg=network/loopback`
128 - **network/maxmin-selective-update:** :ref:`Network Optimization Level <options_model_optim>`
129 - **network/model:** :ref:`options_model_select`
130 - **network/optim:** :ref:`Network Optimization Level <options_model_optim>`
131 - **network/TCP-gamma:** :ref:`cfg=network/TCP-gamma`
132 - **network/weight-S:** :ref:`cfg=network/weight-S`
133
134 - **ns3/TcpModel:** :ref:`options_pls`
135 - **ns3/seed:** :ref:`options_pls`
136 - **path:** :ref:`cfg=path`
137 - **plugin:** :ref:`cfg=plugin`
138
139 - **storage/max_file_descriptors:** :ref:`cfg=storage/max_file_descriptors`
140
141 - **surf/precision:** :ref:`cfg=surf/precision`
142
143 - **For collective operations of SMPI,** please refer to Section :ref:`cfg=smpi/coll-selector`
144 - **smpi/async-small-thresh:** :ref:`cfg=smpi/async-small-thresh`
145 - **smpi/buffering:** :ref:`cfg=smpi/buffering`
146 - **smpi/bw-factor:** :ref:`cfg=smpi/bw-factor`
147 - **smpi/coll-selector:** :ref:`cfg=smpi/coll-selector`
148 - **smpi/comp-adjustment-file:** :ref:`cfg=smpi/comp-adjustment-file`
149 - **smpi/cpu-threshold:** :ref:`cfg=smpi/cpu-threshold`
150 - **smpi/display-timing:** :ref:`cfg=smpi/display-timing`
151 - **smpi/grow-injected-times:** :ref:`cfg=smpi/grow-injected-times`
152 - **smpi/host-speed:** :ref:`cfg=smpi/host-speed`
153 - **smpi/IB-penalty-factors:** :ref:`cfg=smpi/IB-penalty-factors`
154 - **smpi/iprobe:** :ref:`cfg=smpi/iprobe`
155 - **smpi/iprobe-cpu-usage:** :ref:`cfg=smpi/iprobe-cpu-usage`
156 - **smpi/init:** :ref:`cfg=smpi/init`
157 - **smpi/keep-temps:** :ref:`cfg=smpi/keep-temps`
158 - **smpi/lat-factor:** :ref:`cfg=smpi/lat-factor`
159 - **smpi/ois:** :ref:`cfg=smpi/ois`
160 - **smpi/or:** :ref:`cfg=smpi/or`
161 - **smpi/os:** :ref:`cfg=smpi/os`
162 - **smpi/papi-events:** :ref:`cfg=smpi/papi-events`
163 - **smpi/privatization:** :ref:`cfg=smpi/privatization`
164 - **smpi/privatize-libs:** :ref:`cfg=smpi/privatize-libs`
165 - **smpi/send-is-detached-thresh:** :ref:`cfg=smpi/send-is-detached-thresh`
166 - **smpi/shared-malloc:** :ref:`cfg=smpi/shared-malloc`
167 - **smpi/shared-malloc-hugepage:** :ref:`cfg=smpi/shared-malloc-hugepage`
168 - **smpi/simulate-computation:** :ref:`cfg=smpi/simulate-computation`
169 - **smpi/test:** :ref:`cfg=smpi/test`
170 - **smpi/wtime:** :ref:`cfg=smpi/wtime`
171 - **smpi/list-leaks** :ref:`cfg=smpi/list-leaks`
172
173 - **Tracing configuration options** can be found in Section :ref:`tracing_tracing_options`
174
175 - **storage/model:** :ref:`options_model_select`
176
177 - **vm/model:** :ref:`options_model_select`
178
179 .. _options_model:
180
181 Configuring the Platform Models
182 -------------------------------
183
184 .. _options_model_select:
185
186 Choosing the Platform Models
187 ............................
188
189 SimGrid comes with several network, CPU and disk models built in,
190 and you can change the used model at runtime by changing the passed
191 configuration. The three main configuration items are given below.
192 For each of these items, passing the special ``help`` value gives you
193 a short description of all possible values (for example,
194 ``--cfg=network/model:help`` will present all provided network
195 models). Also, ``--help-models`` should provide information about all
196 models for all existing resources.
197
198 - ``network/model``: specify the used network model. Possible values:
199
200   - **LV08 (default one):** Realistic network analytic model
201     (slow-start modeled by multiplying latency by 13.01, bandwidth by
202     .97; bottleneck sharing uses a payload of S=20537 for evaluating
203     RTT). Described in `Accuracy Study and Improvement of Network
204     Simulation in the SimGrid Framework
205     <http://mescal.imag.fr/membres/arnaud.legrand/articles/simutools09.pdf>`_.
206   - **Constant:** Simplistic network model where all communication
207     take a constant time (one second). This model provides the lowest
208     realism, but is (marginally) faster.
209   - **SMPI:** Realistic network model specifically tailored for HPC
210     settings (accurate modeling of slow start with correction factors on
211     three intervals: < 1KiB, < 64 KiB, >= 64 KiB). This model can be
212     :ref:`further configured <options_model_network>`.
213   - **IB:** Realistic network model specifically tailored for HPC
214     settings with InfiniBand networks (accurate modeling contention
215     behavior, based on the model explained in `this PhD work
216     <http://mescal.imag.fr/membres/jean-marc.vincent/index.html/PhD/Vienne.pdf>`_.
217     This model can be :ref:`further configured <options_model_network>`.
218   - **CM02:** Legacy network analytic model. Very similar to LV08, but
219     without corrective factors. The timings of small messages are thus
220     poorly modeled. This model is described in `A Network Model for
221     Simulation of Grid Application
222     <https://hal.inria.fr/inria-00071989/document>`_.
223   - **ns-3** (only available if you compiled SimGrid accordingly):
224     Use the packet-level network
225     simulators as network models (see :ref:`model_ns3`).
226     This model can be :ref:`further configured <options_pls>`.
227
228 - ``cpu/model``: specify the used CPU model.  We have only one model
229   for now:
230
231   - **Cas01:** Simplistic CPU model (time=size/speed)
232
233 - ``host/model``: The host concept is the aggregation of a CPU with a
234   network card. Three models exists, but actually, only 2 of them are
235   interesting. The "compound" one is simply due to the way our
236   internal code is organized, and can easily be ignored. So at the
237   end, you have two host models: The default one allows aggregation of
238   an existing CPU model with an existing network model, but does not
239   allow parallel tasks because these beasts need some collaboration
240   between the network and CPU model. That is why, ptask_07 is used by
241   default when using SimDag.
242
243   - **default:** Default host model. Currently, CPU:Cas01 and
244     network:LV08 (with cross traffic enabled)
245   - **compound:** Host model that is automatically chosen if
246     you change the network and CPU models
247   - **ptask_L07:** Host model somehow similar to Cas01+CM02 but
248     allowing "parallel tasks", that are intended to model the moldable
249     tasks of the grid scheduling literature.
250
251 - ``storage/model``: specify the used storage model. Only one model is
252   provided so far.
253 - ``vm/model``: specify the model for virtual machines. Only one model
254   is provided so far.
255
256 .. todo: make 'compound' the default host model.
257
258 .. _options_model_optim:
259
260 Optimization Level
261 ..................
262
263 The network and CPU models that are based on lmm_solve (that
264 is, all our analytical models) accept specific optimization
265 configurations.
266
267   - items ``network/optim`` and ``cpu/optim`` (both default to 'Lazy'):
268
269     - **Lazy:** Lazy action management (partial invalidation in lmm +
270       heap in action remaining).
271     - **TI:** Trace integration. Highly optimized mode when using
272       availability traces (only available for the Cas01 CPU model for
273       now).
274     - **Full:** Full update of remaining and variables. Slow but may be
275       useful when debugging.
276
277   - items ``network/maxmin-selective-update`` and
278     ``cpu/maxmin-selective-update``: configure whether the underlying
279     should be lazily updated or not. It should have no impact on the
280     computed timings, but should speed up the computation. |br| It is
281     still possible to disable this feature because it can reveal
282     counter-productive in very specific scenarios where the
283     interaction level is high. In particular, if all your
284     communication share a given backbone link, you should disable it:
285     without it, a simple regular loop is used to update each
286     communication. With it, each of them is still updated (because of
287     the dependency induced by the backbone), but through a complicated
288     and slow pattern that follows the actual dependencies.
289
290 .. _cfg=maxmin/precision:
291 .. _cfg=surf/precision:
292
293 Numerical Precision
294 ...................
295
296 **Option** ``maxmin/precision`` **Default:** 0.00001 (in flops or bytes) |br|
297 **Option** ``surf/precision`` **Default:** 0.00001 (in seconds)
298
299 The analytical models handle a lot of floating point values. It is
300 possible to change the epsilon used to update and compare them through
301 this configuration item. Changing it may speedup the simulation by
302 discarding very small actions, at the price of a reduced numerical
303 precision. You can modify separately the precision used to manipulate
304 timings (in seconds) and the one used to manipulate amounts of work
305 (in flops or bytes).
306
307 .. _cfg=maxmin/concurrency-limit:
308
309 Concurrency Limit
310 .................
311
312 **Option** ``maxmin/concurrency-limit`` **Default:** -1 (no limit)
313
314 The maximum number of variables per resource can be tuned through this
315 option. You can have as many simultaneous actions per resources as you
316 want. If your simulation presents a very high level of concurrency, it
317 may help to use e.g. 100 as a value here. It means that at most 100
318 actions can consume a resource at a given time. The extraneous actions
319 are queued and wait until the amount of concurrency of the considered
320 resource lowers under the given boundary.
321
322 Such limitations help both to the simulation speed and simulation accuracy
323 on highly constrained scenarios, but the simulation speed suffers of this
324 setting on regular (less constrained) scenarios so it is off by default.
325
326 .. _options_model_network:
327
328 Configuring the Network Model
329 .............................
330
331 .. _cfg=network/TCP-gamma:
332
333 Maximal TCP Window Size
334 ^^^^^^^^^^^^^^^^^^^^^^^
335
336 **Option** ``network/TCP-gamma`` **Default:** 4194304
337
338 The analytical models need to know the maximal TCP window size to take
339 the TCP congestion mechanism into account.  On Linux, this value can
340 be retrieved using the following commands. Both give a set of values,
341 and you should use the last one, which is the maximal size.
342
343 .. code-block:: shell
344
345    cat /proc/sys/net/ipv4/tcp_rmem # gives the sender window
346    cat /proc/sys/net/ipv4/tcp_wmem # gives the receiver window
347
348 .. _cfg=smpi/IB-penalty-factors:
349 .. _cfg=network/bandwidth-factor:
350 .. _cfg=network/latency-factor:
351 .. _cfg=network/weight-S:
352
353 Correcting Important Network Parameters
354 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
355
356 SimGrid can take network irregularities such as a slow startup or
357 changing behavior depending on the message size into account.  You
358 should not change these values unless you really know what you're
359 doing.  The corresponding values were computed through data fitting
360 one the timings of packet-level simulators, as described in `Accuracy
361 Study and Improvement of Network Simulation in the SimGrid Framework
362 <http://mescal.imag.fr/membres/arnaud.legrand/articles/simutools09.pdf>`_.
363
364
365 If you are using the SMPI model, these correction coefficients are
366 themselves corrected by constant values depending on the size of the
367 exchange.  By default SMPI uses factors computed on the Stampede
368 Supercomputer at TACC, with optimal deployment of processes on
369 nodes. Again, only hardcore experts should bother about this fact.
370
371 InfiniBand network behavior can be modeled through 3 parameters
372 ``smpi/IB-penalty-factors:"βe;βs;γs"``, as explained in `this PhD
373 thesis
374 <http://mescal.imag.fr/membres/jean-marc.vincent/index.html/PhD/Vienne.pdf>`_.
375
376 .. todo:: This section should be rewritten, and actually explain the
377           options network/bandwidth-factor, network/latency-factor,
378           network/weight-S.
379
380 .. _cfg=network/crosstraffic:
381
382 Simulating Cross-Traffic
383 ^^^^^^^^^^^^^^^^^^^^^^^^
384
385 Since SimGrid v3.7, cross-traffic effects can be taken into account in
386 analytical simulations. It means that ongoing and incoming
387 communication flows are treated independently. In addition, the LV08
388 model adds 0.05 of usage on the opposite direction for each new
389 created flow. This can be useful to simulate some important TCP
390 phenomena such as ack compression.
391
392 For that to work, your platform must have two links for each
393 pair of interconnected hosts. An example of usable platform is
394 available in ``examples/platforms/crosstraffic.xml``.
395
396 This is activated through the ``network/crosstraffic`` item, that
397 can be set to 0 (disable this feature) or 1 (enable it).
398
399 Note that with the default host model this option is activated by default.
400
401 .. _cfg=network/loopback:
402
403 Configuring loopback link
404 ^^^^^^^^^^^^^^^^^^^^^^^^^
405
406 Several network model provide an implicit loopback link to account for local 
407 communication on a host. By default it has a 10GBps bandwidth and a null latency.
408 This can be changed with ``network/loopback-lat`` and ``network/loopback-bw`` 
409 items.
410
411 .. _cfg=smpi/async-small-thresh:
412
413 Simulating Asynchronous Send
414 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
415
416 (this configuration item is experimental and may change or disappear)
417
418 It is possible to specify that messages below a certain size (in bytes) will be
419 sent as soon as the call to MPI_Send is issued, without waiting for
420 the correspondent receive. This threshold can be configured through
421 the ``smpi/async-small-thresh`` item. The default value is 0. This
422 behavior can also be manually set for mailboxes, by setting the
423 receiving mode of the mailbox with a call to
424 :cpp:func:`MSG_mailbox_set_async`. After this, all messages sent to
425 this mailbox will have this behavior regardless of the message size.
426
427 This value needs to be smaller than or equals to the threshold set at
428 :ref:`cfg=smpi/send-is-detached-thresh`, because asynchronous messages
429 are meant to be detached as well.
430
431 .. _options_pls:
432
433 Configuring ns-3
434 ^^^^^^^^^^^^^^^^
435
436 **Option** ``ns3/TcpModel`` **Default:** "default" (ns-3 default)
437
438 When using ns-3, there is an extra item ``ns3/TcpModel``, corresponding
439 to the ``ns3::TcpL4Protocol::SocketType`` configuration item in
440 ns-3. The only valid values (enforced on the SimGrid side) are
441 'default' (no change to the ns-3 configuration), 'NewReno' or 'Reno' or
442 'Tahoe'.
443
444 **Option** ``ns3/seed`` **Default:** "" (don't set the seed in ns-3)
445
446 This option is the random seed to provide to ns-3 with
447 ``ns3::RngSeedManager::SetSeed`` and ``ns3::RngSeedManager::SetRun``.
448
449 If left blank, no seed is set in ns-3. If the value 'time' is
450 provided, the current amount of seconds since epoch is used as a seed.
451 Otherwise, the provided value must be a number to use as a seed.
452
453 Configuring the Storage model
454 .............................
455
456 .. _cfg=storage/max_file_descriptors:
457
458 File Descriptor Count per Host
459 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
460
461 **Option** ``storage/max_file_descriptors`` **Default:** 1024
462
463 Each host maintains a fixed-size array of its file descriptors. You
464 can change its size through this item to either enlarge it if your
465 application requires it or to reduce it to save memory space.
466
467 .. _cfg=plugin:
468
469 Activating Plugins
470 ------------------
471
472 SimGrid plugins allow one to extend the framework without changing its
473 source code directly. Read the source code of the existing plugins to
474 learn how to do so (in ``src/plugins``), and ask your questions to the
475 usual channels (Stack Overflow, Mailing list, IRC). The basic idea is
476 that plugins usually register callbacks to some signals of interest.
477 If they need to store some information about a given object (Link, CPU
478 or Actor), they do so through the use of a dedicated object extension.
479
480 Some of the existing plugins can be activated from the command line,
481 meaning that you can activate them from the command line without any
482 modification to your simulation code. For example, you can activate
483 the host energy plugin by adding ``--cfg=plugin:host_energy`` to your
484 command line.
485
486 Here is a partial list of plugins that can be activated this way. You can get
487 the full list by passing ``--cfg=plugin:help`` to your simulator.
488
489   - :ref:`Host Energy <plugin_host_energy>`: models the energy dissipation of the compute units.
490   - :ref:`Link Energy <plugin_link_energy>`: models the energy dissipation of the network.
491   - :ref:`Host Load <plugin_host_load>`: monitors the load of the compute units.
492
493 .. _options_modelchecking:
494
495 Configuring the Model-Checking
496 ------------------------------
497
498 To enable SimGrid's model-checking support, the program should
499 be executed using the simgrid-mc wrapper:
500
501 .. code-block:: shell
502
503    simgrid-mc ./my_program
504
505 Safety properties are expressed as assertions using the function
506 :cpp:func:`void MC_assert(int prop)`.
507
508 .. _cfg=smpi/buffering:
509
510 Specifying the MPI buffering behavior
511 .....................................
512
513 **Option** ``smpi/buffering`` **Default:** infty
514
515 Buffering in MPI has a huge impact on the communication semantic. For example,
516 standard blocking sends are synchronous calls when the system buffers are full
517 while these calls can complete immediately without even requiring a matching
518 receive call for small messages sent when the system buffers are empty.
519
520 In SMPI, this depends on the message size, that is compared against two thresholds:
521
522 - if (size < :ref:`smpi/async-small-thresh <cfg=smpi/async-small-thresh>`) then
523   MPI_Send returns immediately, even if the corresponding receive has not be issued yet.
524 - if (:ref:`smpi/async-small-thresh <cfg=smpi/async-small-thresh>` < size < :ref:`smpi/send-is-detached-thresh <cfg=smpi/send-is-detached-thresh>`) then
525   MPI_Send returns as soon as the corresponding receive has been issued. This is known as the eager mode.
526 - if (:ref:`smpi/send-is-detached-thresh <cfg=smpi/send-is-detached-thresh>` < size) then
527   MPI_Send returns only when the message has actually been sent over the network. This is known as the rendez-vous mode.
528
529 The ``smpi/buffering`` (only valid with MC) option gives an easier interface to choose between these semantics. It can take two values:
530
531 - **zero:** means that buffering should be disabled. All communications are actually blocking.
532 - **infty:** means that buffering should be made infinite. All communications are non-blocking.
533
534 .. _cfg=model-check/property:
535
536 Specifying a liveness property
537 ..............................
538
539 **Option** ``model-check/property`` **Default:** unset
540
541 If you want to specify liveness properties, you have to pass them on
542 the command line, specifying the name of the file containing the
543 property, as formatted by the `ltl2ba <https://github.com/utwente-fmt/ltl2ba>`_ program.
544 Note that ltl2ba is not part of SimGrid and must be installed separately.
545
546 .. code-block:: shell
547
548    simgrid-mc ./my_program --cfg=model-check/property:<filename>
549
550 .. _cfg=model-check/checkpoint:
551
552 Going for Stateful Verification
553 ...............................
554
555 By default, the system is backtracked to its initial state to explore
556 another path, instead of backtracking to the exact step before the fork
557 that we want to explore (this is called stateless verification). This
558 is done this way because saving intermediate states can rapidly
559 exhaust the available memory. If you want, you can change the value of
560 the ``model-check/checkpoint`` item. For example,
561 ``--cfg=model-check/checkpoint:1`` asks to take a checkpoint every
562 step.  Beware, this will certainly explode your memory. Larger values
563 are probably better, make sure to experiment a bit to find the right
564 setting for your specific system.
565
566 .. _cfg=model-check/reduction:
567
568 Specifying the kind of reduction
569 ................................
570
571 The main issue when using the model-checking is the state space
572 explosion. You can activate some reduction technique with
573 ``--cfg=model-check/reduction:<technique>``. For now, this
574 configuration variable can take 2 values:
575
576  - **none:** Do not apply any kind of reduction (mandatory for
577    liveness properties, as our current DPOR algorithm breaks cycles)
578  - **dpor:** Apply Dynamic Partial Ordering Reduction. Only valid if
579    you verify local safety properties (default value for safety
580    checks).
581
582 Another way to mitigate the state space explosion is to search for
583 cycles in the exploration with the :ref:`cfg=model-check/visited`
584 configuration. Note that DPOR and state-equality reduction may not
585 play well together. You should choose between them.
586
587 Our current DPOR implementation could be improved in may ways. We are
588 currently improving its efficiency (both in term of reduction ability
589 and computational speed), and future work could make it compatible
590 with liveness properties.
591
592 .. _cfg=model-check/visited:
593
594 Size of Cycle Detection Set (state equality reduction)
595 ......................................................
596
597 Mc SimGrid can be asked to search for cycles during the exploration,
598 i.e. situations where a new explored state is in fact the same state
599 than a previous one.. This can prove useful to mitigate the state
600 space explosion with safety properties, and this is the crux when
601 searching for counter-examples to the liveness properties.
602
603 Note that this feature may break the current implementation of the
604 DPOR reduction technique.
605
606 The ``model-check/visited`` item is the maximum number of states, which
607 are stored in memory. If the maximum number of snapshotted state is
608 reached, some states will be removed from the memory and some cycles
609 might be missed. Small values can lead to incorrect verifications, but
610 large values can exhaust your memory and be CPU intensive as each new
611 state must be compared to that amount of older saved states.
612
613 The default settings depend on the kind of exploration. With safety
614 checking, no state is snapshotted and cycles cannot be detected. With
615 liveness checking, all states are snapshotted because missing a cycle
616 could hinder the exploration soundness.
617
618 .. _cfg=model-check/termination:
619
620 Non-Termination Detection
621 .........................
622
623 The ``model-check/termination`` configuration item can be used to
624 report if a non-termination execution path has been found. This is a
625 path with a cycle, which means that the program might never terminate.
626
627 This only works in safety mode, not in liveness mode.
628
629 This options is disabled by default.
630
631 .. _cfg=model-check/dot-output:
632
633 Dot Output
634 ..........
635
636 If set, the ``model-check/dot-output`` configuration item is the name
637 of a file in which to write a dot file of the path leading to the
638 property violation discovered (safety or liveness violation), as well
639 as the cycle for liveness properties. This dot file can then be fed to the
640 graphviz dot tool to generate a corresponding graphical representation.
641
642 .. _cfg=model-check/max-depth:
643
644 Exploration Depth Limit
645 .......................
646
647 The ``model-checker/max-depth`` can set the maximum depth of the
648 exploration graph of the model checker. If this limit is reached, a
649 logging message is sent and the results might not be exact.
650
651 By default, there is no depth limit.
652
653 .. _cfg=model-check/timeout:
654
655 Handling of Timeouts
656 ....................
657
658 By default, the model checker does not handle timeout conditions: the `wait`
659 operations never time out. With the ``model-check/timeout`` configuration item
660 set to **yes**, the model checker will explore timeouts of `wait` operations.
661
662 .. _cfg=model-check/communications-determinism:
663 .. _cfg=model-check/send-determinism:
664
665 Communication Determinism
666 .........................
667
668 The ``model-check/communications-determinism`` and
669 ``model-check/send-determinism`` items can be used to select the
670 communication determinism mode of the model checker, which checks
671 determinism properties of the communications of an application.
672
673 .. _options_mc_perf:
674
675 Verification Performance Considerations
676 .......................................
677
678 The size of the stacks can have a huge impact on the memory
679 consumption when using model-checking. By default, each snapshot will
680 save a copy of the whole stacks and not only of the part that is
681 really meaningful: you should expect the contribution of the memory
682 consumption of the snapshots to be:
683 :math:`\text{number of processes} \times \text{stack size} \times \text{number of states}`.
684
685 When compiled against the model checker, the stacks are not
686 protected with guards: if the stack size is too small for your
687 application, the stack will silently overflow into other parts of the
688 memory (see :ref:`contexts/guard-size <cfg=contexts/guard-size>`).
689
690 .. _cfg=model-check/replay:
691
692 Replaying buggy execution paths from the model checker
693 ......................................................
694
695 Debugging the problems reported by the model checker is challenging:
696 First, the application under verification cannot be debugged with gdb
697 because the model checker already traces it. Then, the model checker may
698 explore several execution paths before encountering the issue, making it
699 very difficult to understand the output. Fortunately, SimGrid provides
700 the execution path leading to any reported issue so that you can replay
701 this path reported by the model checker, enabling the usage of classical
702 debugging tools.
703
704 When the model checker finds an interesting path in the application
705 execution graph (where a safety or liveness property is violated), it
706 generates an identifier for this path. Here is an example of the output:
707
708 .. code-block:: shell
709
710    [  0.000000] (0:@) Check a safety property
711    [  0.000000] (0:@) **************************
712    [  0.000000] (0:@) *** PROPERTY NOT VALID ***
713    [  0.000000] (0:@) **************************
714    [  0.000000] (0:@) Counter-example execution trace:
715    [  0.000000] (0:@)   [(1)Tremblay (app)] MC_RANDOM(3)
716    [  0.000000] (0:@)   [(1)Tremblay (app)] MC_RANDOM(4)
717    [  0.000000] (0:@) Path = 1/3;1/4
718    [  0.000000] (0:@) Expanded states = 27
719    [  0.000000] (0:@) Visited states = 68
720    [  0.000000] (0:@) Executed transitions = 46
721
722 The interesting line is ``Path = 1/3;1/4``, which means that you should use
723 ``--cfg=model-check/replay:1/3;1/4`` to replay your application on the buggy
724 execution path. All options (but the model checker related ones) must
725 remain the same. In particular, if you ran your application with
726 ``smpirun -wrapper simgrid-mc``, then do it again. Remove all
727 MC-related options, keep non-MC-related ones and add
728 ``--cfg=model-check/replay:???``.
729
730 Currently, if the path is of the form ``X;Y;Z``, each number denotes
731 the actor's pid that is selected at each indecision point. If it's of
732 the form ``X/a;Y/b``, the X and Y are the selected pids while the a
733 and b are the return values of their simcalls. In the previous
734 example, ``1/3;1/4``, you can see from the full output that the actor
735 1 is doing MC_RANDOM simcalls, so the 3 and 4 simply denote the values
736 that these simcall return on the execution branch leading to the
737 violation.
738
739 Configuring the User Code Virtualization
740 ----------------------------------------
741
742 .. _cfg=contexts/factory:
743
744 Selecting the Virtualization Factory
745 ....................................
746
747 **Option** contexts/factory **Default:** "raw"
748
749 In SimGrid, the user code is virtualized in a specific mechanism that
750 allows the simulation kernel to control its execution: when a user
751 process requires a blocking action (such as sending a message), it is
752 interrupted, and only gets released when the simulated clock reaches
753 the point where the blocking operation is done. This is explained
754 graphically in the `relevant tutorial, available online
755 <https://simgrid.org/tutorials/simgrid-simix-101.pdf>`_.
756
757 In SimGrid, the containers in which user processes are virtualized are
758 called contexts. Several context factory are provided, and you can
759 select the one you want to use with the ``contexts/factory``
760 configuration item. Some of the following may not exist on your
761 machine because of portability issues. In any case, the default one
762 should be the most effcient one (please report bugs if the
763 auto-detection fails for you). They are approximately sorted here from
764 the slowest to the most efficient:
765
766  - **thread:** very slow factory using full featured threads (either
767    pthreads or windows native threads). They are slow but very
768    standard. Some debuggers or profilers only work with this factory.
769  - **java:** Java applications are virtualized onto java threads (that
770    are regular pthreads registered to the JVM)
771  - **ucontext:** fast factory using System V contexts (Linux and FreeBSD only)
772  - **boost:** This uses the `context
773    implementation <http://www.boost.org/doc/libs/1_59_0/libs/context/doc/html/index.html>`_
774    of the boost library for a performance that is comparable to our
775    raw implementation.
776    |br| Install the relevant library (e.g. with the
777    libboost-contexts-dev package on Debian/Ubuntu) and recompile
778    SimGrid.
779  - **raw:** amazingly fast factory using a context switching mechanism
780    of our own, directly implemented in assembly (only available for x86
781    and amd64 platforms for now) and without any unneeded system call.
782
783 The main reason to change this setting is when the debugging tools become
784 fooled by the optimized context factories. Threads are the most
785 debugging-friendly contexts, as they allow one to set breakpoints
786 anywhere with gdb and visualize backtraces for all processes, in order
787 to debug concurrency issues. Valgrind is also more comfortable with
788 threads, but it should be usable with all factories (Exception: the
789 callgrind tool really dislikes raw and ucontext factories).
790
791 .. _cfg=contexts/stack-size:
792
793 Adapting the Stack Size
794 .......................
795
796 **Option** ``contexts/stack-size`` **Default:** 8192 KiB
797
798 Each virtualized used process is executed using a specific system
799 stack. The size of this stack has a huge impact on the simulation
800 scalability, but its default value is rather large. This is because
801 the error messages that you get when the stack size is too small are
802 rather disturbing: this leads to stack overflow (overwriting other
803 stacks), leading to segfaults with corrupted stack traces.
804
805 If you want to push the scalability limits of your code, you might
806 want to reduce the ``contexts/stack-size`` item. Its default value is
807 8192 (in KiB), while our Chord simulation works with stacks as small
808 as 16 KiB, for example. You can ensure that some actors have a specific
809 size by simply changing the value of this configuration item before
810 creating these actors. The :cpp:func:`simgrid::s4u::Engine::set_config` 
811 functions are handy for that.
812
813 This *setting is ignored* when using the thread factory (because there
814 is no way to modify the stack size with C++ system threads). Instead,
815 you should compile SimGrid and your application with
816 ``-fsplit-stack``. Note that this compilation flag is not compatible
817 with the model checker right now.
818
819 The operating system should only allocate memory for the pages of the
820 stack which are actually used and you might not need to use this in
821 most cases. However, this setting is very important when using the
822 model checker (see :ref:`options_mc_perf`).
823
824 .. _cfg=contexts/guard-size:
825
826 Disabling Stack Guard Pages
827 ...........................
828
829 **Option** ``contexts/guard-size`` **Default** 1 page in most case (0 pages on Windows or with MC)
830
831 Unless you use the threads context factory (see
832 :ref:`cfg=contexts/factory`), a stack guard page is usually used
833 which prevents the stack of a given actor from overflowing on another
834 stack. But the performance impact may become prohibitive when the
835 amount of actors increases.  The option ``contexts/guard-size`` is the
836 number of stack guard pages used.  By setting it to 0, no guard pages
837 will be used: in this case, you should avoid using small stacks (with
838 :ref:`contexts/stack-size <cfg=contexts/stack-size>`) as the stack
839 will silently overflow on other parts of the memory.
840
841 When no stack guard page is created, stacks may then silently overflow
842 on other parts of the memory if their size is too small for the
843 application.
844
845 .. _cfg=contexts/nthreads:
846 .. _cfg=contexts/synchro:
847
848 Running User Code in Parallel
849 .............................
850
851 Parallel execution of the user code is only considered stable in
852 SimGrid v3.7 and higher, and mostly for MSG simulations. SMPI
853 simulations may well fail in parallel mode. It is described in
854 `INRIA RR-7653 <http://hal.inria.fr/inria-00602216/>`_.
855
856 If you are using the **ucontext** or **raw** context factories, you can
857 request to execute the user code in parallel. Several threads are
858 launched, each of them handling the same number of user contexts at each
859 run. To activate this, set the ``contexts/nthreads`` item to the amount
860 of cores that you have in your computer (or lower than 1 to have the
861 amount of cores auto-detected).
862
863 When parallel execution is activated, you can choose the
864 synchronization schema used with the ``contexts/synchro`` item,
865 which value is either:
866
867  - **futex:** ultra optimized synchronisation schema, based on futexes
868    (fast user-mode mutexes), and thus only available on Linux systems.
869    This is the default mode when available.
870  - **posix:** slow but portable synchronisation using only POSIX
871    primitives.
872  - **busy_wait:** not really a synchronisation: the worker threads
873    constantly request new contexts to execute. It should be the most
874    efficient synchronisation schema, but it loads all the cores of
875    your machine for no good reason. You probably prefer the other less
876    eager schemas.
877
878 Configuring the Tracing
879 -----------------------
880
881 The :ref:`tracing subsystem <outcomes_vizu>` can be configured in
882 several different ways depending on the used interface (S4U, SMPI, SimDag)
883 and the kind of traces that needs to be obtained. See the
884 :ref:`Tracing Configuration Options subsection
885 <tracing_tracing_options>` for a full description of each
886 configuration option.
887
888 We detail here a simple way to get the traces working for you, even if
889 you never used the tracing API.
890
891
892 - Any SimGrid-based simulator (MSG, SimDag, SMPI, ...) and raw traces:
893
894   .. code-block:: shell
895
896      --cfg=tracing:yes --cfg=tracing/uncategorized:yes
897
898   The first parameter activates the tracing subsystem, and the second
899   tells it to trace host and link utilization (without any
900   categorization).
901
902 - MSG or SimDag-based simulator and categorized traces (you need to
903   declare categories and classify your tasks according to them) 
904
905   .. code-block:: shell
906
907      --cfg=tracing:yes --cfg=tracing/categorized:yes
908
909   The first parameter activates the tracing subsystem, and the second
910   tells it to trace host and link categorized utilization.
911
912 - SMPI simulator and traces for a space/time view:
913
914   .. code-block:: shell
915
916      smpirun -trace ...
917
918   The `-trace` parameter for the smpirun script runs the simulation
919   with ``--cfg=tracing:yes --cfg=tracing/smpi:yes``. Check the
920   smpirun's `-help` parameter for additional tracing options.
921
922 Sometimes you might want to put additional information on the trace to
923 correctly identify them later, or to provide data that can be used to
924 reproduce an experiment. You have two ways to do that:
925
926 - Add a string on top of the trace file as comment:
927
928   .. code-block:: shell
929
930      --cfg=tracing/comment:my_simulation_identifier
931
932 - Add the contents of a textual file on top of the trace file as comment:
933
934   .. code-block:: shell
935
936      --cfg=tracing/comment-file:my_file_with_additional_information.txt
937
938 Please, use these two parameters (for comments) to make reproducible
939 simulations. For additional details about this and all tracing
940 options, check See the :ref:`tracing_tracing_options`.
941
942 Configuring MSG
943 ---------------
944
945 .. _cfg=msg/debug-multiple-use:
946
947 Debugging MSG Code
948 ..................
949
950 **Option** ``msg/debug-multiple-use`` **Default:** off
951
952 Sometimes your application may try to send a task that is still being
953 executed somewhere else, making it impossible to send this task. However,
954 for debugging purposes, one may want to know what the other host is/was
955 doing. This option shows a backtrace of the other process.
956
957 Configuring SMPI
958 ----------------
959
960 The SMPI interface provides several specific configuration items.
961 These are not easy to see, since the code is usually launched through the
962 ``smiprun`` script directly.
963
964 .. _cfg=smpi/host-speed:
965 .. _cfg=smpi/cpu-threshold:
966 .. _cfg=smpi/simulate-computation:
967
968 Automatic Benchmarking of SMPI Code
969 ...................................
970
971 In SMPI, the sequential code is automatically benchmarked, and these
972 computations are automatically reported to the simulator. That is to
973 say that if you have a large computation between a ``MPI_Recv()`` and
974 a ``MPI_Send()``, SMPI will automatically benchmark the duration of
975 this code, and create an execution task within the simulator to take
976 this into account. For that, the actual duration is measured on the
977 host machine and then scaled to the power of the corresponding
978 simulated machine. The variable ``smpi/host-speed`` allows one to
979 specify the computational speed of the host machine (in flop/s by
980 default) to use when scaling the execution times.
981
982 The default value is ``smpi/host-speed=20kf`` (= 20,000 flop/s). This
983 is probably underestimated for most machines, leading SimGrid to
984 overestimate the amount of flops in the execution blocks that are
985 automatically injected in the simulator. As a result, the execution
986 time of the whole application will probably be overestimated until you
987 use a realistic value.
988
989 When the code consists of numerous consecutive MPI calls, the
990 previous mechanism feeds the simulation kernel with numerous tiny
991 computations. The ``smpi/cpu-threshold`` item becomes handy when this
992 impacts badly on the simulation performance. It specifies a threshold (in
993 seconds) below which the execution chunks are not reported to the
994 simulation kernel (default value: 1e-6).
995
996 .. note:: The option ``smpi/cpu-threshold`` ignores any computation
997    time spent below this threshold. SMPI does not consider the
998    `amount of time` of these computations; there is no offset for
999    this. Hence, a value that is too small, may lead to unreliable
1000    simulation results.
1001
1002 In some cases, however, one may wish to disable simulation of
1003 the computation of an application. This is the case when SMPI is used not to
1004 simulate an MPI application, but instead an MPI code that performs
1005 "live replay" of another MPI app (e.g., ScalaTrace's replay tool, or
1006 various on-line simulators that run an app at scale). In this case the
1007 computation of the replay/simulation logic should not be simulated by
1008 SMPI. Instead, the replay tool or on-line simulator will issue
1009 "computation events", which correspond to the actual MPI simulation
1010 being replayed/simulated. At the moment, these computation events can
1011 be simulated using SMPI by calling internal smpi_execute*() functions.
1012
1013 To disable the benchmarking/simulation of a computation in the simulated
1014 application, the variable ``smpi/simulate-computation`` should be set
1015 to **no**.  This option just ignores the timings in your simulation; it
1016 still executes the computations itself. If you want to stop SMPI from
1017 doing that, you should check the SMPI_SAMPLE macros, documented in
1018 Section :ref:`SMPI_use_faster`.
1019
1020 +------------------------------------+-------------------------+-----------------------------+
1021 |  Solution                          | Computations executed?  | Computations simulated?     |
1022 +====================================+=========================+=============================+
1023 | --cfg=smpi/simulate-computation:no | Yes                     | Never                       |
1024 +------------------------------------+-------------------------+-----------------------------+
1025 | --cfg=smpi/cpu-threshold:42        | Yes, in all cases       | If it lasts over 42 seconds |
1026 +------------------------------------+-------------------------+-----------------------------+
1027 | SMPI_SAMPLE() macro                | Only once per loop nest | Always                      |
1028 +------------------------------------+-------------------------+-----------------------------+
1029
1030 .. _cfg=smpi/comp-adjustment-file:
1031
1032 Slow-down or speed-up parts of your code
1033 ........................................
1034
1035 **Option** ``smpi/comp-adjustment-file:`` **Default:** unset
1036
1037 This option allows you to pass a file that contains two columns: The
1038 first column defines the section that will be subject to a speedup;
1039 the second column is the speedup. For instance:
1040
1041 .. code-block:: shell
1042
1043   "start:stop","ratio"
1044   "exchange_1.f:30:exchange_1.f:130",1.18244559422142
1045
1046 The first line is the header - you must include it.  The following
1047 line means that the code between two consecutive MPI calls on line 30
1048 in exchange_1.f and line 130 in exchange_1.f should receive a speedup
1049 of 1.18244559422142. The value for the second column is therefore a
1050 speedup, if it is larger than 1 and a slowdown if it is smaller
1051 than 1. Nothing will be changed if it is equal to 1.
1052
1053 Of course, you can set any arbitrary filenames you want (so the start
1054 and end don't have to be in the same file), but be aware that this
1055 mechanism only supports `consecutive calls!`
1056
1057 Please note that you must pass the ``-trace-call-location`` flag to
1058 smpicc or smpiff, respectively. This flag activates some internal
1059 macro definitions that help with obtaining the call location.
1060
1061 .. _cfg=smpi/bw-factor:
1062
1063 Bandwidth Factors
1064 .................
1065
1066 **Option** ``smpi/bw-factor``
1067 |br| **Default:** 65472:0.940694;15424:0.697866;9376:0.58729;5776:1.08739;3484:0.77493;1426:0.608902;732:0.341987;257:0.338112;0:0.812084
1068
1069 The possible throughput of network links is often dependent on the
1070 message sizes, as protocols may adapt to different message sizes. With
1071 this option, a series of message sizes and factors are given, helping
1072 the simulation to be more realistic. For instance, the current default
1073 value means that messages with size 65472 bytes and more will get a total of
1074 MAX_BANDWIDTH*0.940694, messages of size 15424 to 65471 will get
1075 MAX_BANDWIDTH*0.697866, and so on (where MAX_BANDWIDTH denotes the
1076 bandwidth of the link).
1077
1078 An experimental script to compute these factors is available online. See
1079 https://framagit.org/simgrid/platform-calibration/
1080 https://simgrid.org/contrib/smpi-saturation-doc.html
1081
1082 .. _cfg=smpi/display-timing:
1083
1084 Reporting Simulation Time
1085 .........................
1086
1087 **Option** ``smpi/display-timing`` **Default:** 0 (false)
1088
1089 Most of the time, you run MPI code with SMPI to compute the time it
1090 would take to run it on a platform. But since the code is run through
1091 the ``smpirun`` script, you don't have any control on the launcher
1092 code, making it difficult to report the simulated time when the
1093 simulation ends. If you enable the ``smpi/display-timing`` item,
1094 ``smpirun`` will display this information when the simulation
1095 ends.
1096
1097 .. _cfg=smpi/keep-temps:
1098
1099 Keeping temporary files after simulation
1100 ........................................
1101
1102 **Option** ``smpi/keep-temps`` **default:** 0 (false)
1103
1104 SMPI usually generates a lot of temporary files that are cleaned after
1105 use. This option requests to preserve them, for example to debug or
1106 profile your code. Indeed, the binary files are removed very early
1107 under the dlopen privatization schema, which tends to fool the
1108 debuggers.
1109
1110 .. _cfg=smpi/lat-factor:
1111
1112 Latency factors
1113 ...............
1114
1115 **Option** ``smpi/lat-factor`` |br|
1116 **default:** 65472:11.6436;15424:3.48845;9376:2.59299;5776:2.18796;3484:1.88101;1426:1.61075;732:1.9503;257:1.95341;0:2.01467
1117
1118 The motivation and syntax for this option is identical to the motivation/syntax
1119 of :ref:`cfg=smpi/bw-factor`.
1120
1121 There is an important difference, though: While smpi/bw-factor `reduces` the
1122 actual bandwidth (i.e., values between 0 and 1 are valid), latency factors
1123 increase the latency, i.e., values larger than or equal to 1 are valid here.
1124
1125 .. _cfg=smpi/papi-events:
1126
1127 Trace hardware counters with PAPI
1128 .................................
1129
1130 **Option** ``smpi/papi-events`` **default:** unset
1131
1132 When the PAPI support is compiled into SimGrid, this option takes the
1133 names of PAPI counters and adds their respective values to the trace
1134 files (See Section :ref:`tracing_tracing_options`).
1135
1136 .. warning::
1137
1138    This feature currently requires superuser privileges, as registers
1139    are queried.  Only use this feature with code you trust! Call
1140    smpirun for instance via ``smpirun -wrapper "sudo "
1141    <your-parameters>`` or run ``sudo sh -c "echo 0 >
1142    /proc/sys/kernel/perf_event_paranoid"`` In the later case, sudo
1143    will not be required.
1144
1145 It is planned to make this feature available on a per-process (or per-thread?) basis.
1146 The first draft, however, just implements a "global" (i.e., for all processes) set
1147 of counters, the "default" set.
1148
1149 .. code-block:: shell
1150
1151    --cfg=smpi/papi-events:"default:PAPI_L3_LDM:PAPI_L2_LDM"
1152
1153 .. _cfg=smpi/privatization:
1154
1155 Automatic Privatization of Global Variables
1156 ...........................................
1157
1158 **Option** ``smpi/privatization`` **default:** "dlopen" (when using smpirun)
1159
1160 MPI executables are usually meant to be executed in separate
1161 processes, but SMPI is executed in only one process. Global variables
1162 from executables will be placed in the same memory region and shared
1163 between processes, causing intricate bugs.  Several options are
1164 possible to avoid this, as described in the main `SMPI publication
1165 <https://hal.inria.fr/hal-01415484>`_ and in the :ref:`SMPI
1166 documentation <SMPI_what_globals>`. SimGrid provides two ways of
1167 automatically privatizing the globals, and this option allows one to
1168 choose between them.
1169
1170   - **no** (default when not using smpirun): Do not automatically
1171     privatize variables.  Pass ``-no-privatize`` to smpirun to disable
1172     this feature.
1173   - **dlopen** or **yes** (default when using smpirun): Link multiple
1174     times against the binary.
1175   - **mmap** (slower, but maybe somewhat more stable):
1176     Runtime automatic switching of the data segments.
1177
1178 .. warning::
1179    This configuration option cannot be set in your platform file. You can only
1180    pass it as an argument to smpirun.
1181
1182 .. _cfg=smpi/privatize-libs:
1183
1184 Automatic privatization of global variables inside external libraries
1185 .....................................................................
1186
1187 **Option** ``smpi/privatize-libs`` **default:** unset
1188
1189 **Linux/BSD only:** When using dlopen (default) privatization,
1190 privatize specific shared libraries with internal global variables, if
1191 they can't be linked statically.  For example libgfortran is usually
1192 used for Fortran I/O and indexes in files can be mixed up.
1193
1194 Multiple libraries can be given, semicolon separated.
1195
1196 This configuration option can only use either full paths to libraries,
1197 or full names.  Check with ldd the name of the library you want to
1198 use.  For example:
1199
1200 .. code-block:: shell
1201
1202    ldd allpairf90
1203       ...
1204       libgfortran.so.3 => /usr/lib/x86_64-linux-gnu/libgfortran.so.3 (0x00007fbb4d91b000)
1205       ...
1206
1207 Then you can use ``--cfg=smpi/privatize-libs:libgfortran.so.3``
1208 or ``--cfg=smpi/privatize-libs:/usr/lib/x86_64-linux-gnu/libgfortran.so.3``,
1209 but not ``libgfortran`` nor ``libgfortran.so``.
1210
1211 .. _cfg=smpi/send-is-detached-thresh:
1212
1213 Simulating MPI detached send
1214 ............................
1215
1216 **Option** ``smpi/send-is-detached-thresh`` **default:** 65536
1217
1218 This threshold specifies the size in bytes under which the send will
1219 return immediately. This is different from the threshold detailed in
1220 :ref:`cfg=smpi/async-small-thresh` because the message is not
1221 really sent when the send is posted. SMPI still waits for the
1222 corresponding receive to be posted, in order to perform the communication
1223 operation.
1224
1225 .. _cfg=smpi/coll-selector:
1226
1227 Simulating MPI collective algorithms
1228 ....................................
1229
1230 **Option** ``smpi/coll-selector`` **Possible values:** naive (default), ompi, mpich
1231
1232 SMPI implements more than 100 different algorithms for MPI collective
1233 communication, to accurately simulate the behavior of most of the
1234 existing MPI libraries. The ``smpi/coll-selector`` item can be used to
1235 select the decision logic either of the OpenMPI or the MPICH libraries. (By
1236 default SMPI uses naive version of collective operations.)
1237
1238 Each collective operation can be manually selected with a
1239 ``smpi/collective_name:algo_name``. Available algorithms are listed in
1240 :ref:`SMPI_use_colls`.
1241
1242 .. TODO:: All available collective algorithms will be made available
1243           via the ``smpirun --help-coll`` command.
1244
1245 .. _cfg=smpi/iprobe:
1246
1247 Inject constant times for MPI_Iprobe
1248 ....................................
1249
1250 **Option** ``smpi/iprobe`` **default:** 0.0001
1251
1252 The behavior and motivation for this configuration option is identical
1253 with :ref:`smpi/test <cfg=smpi/test>`, but for the function
1254 ``MPI_Iprobe()``
1255
1256 .. _cfg=smpi/iprobe-cpu-usage:
1257
1258 Reduce speed for iprobe calls
1259 .............................
1260
1261 **Option** ``smpi/iprobe-cpu-usage`` **default:** 1 (no change)
1262
1263 MPI_Iprobe calls can be heavily used in applications. To account
1264 correctly for the energy that cores spend probing, it is necessary to
1265 reduce the load that these calls cause inside SimGrid.
1266
1267 For instance, we measured a maximum power consumption of 220 W for a
1268 particular application but only 180 W while this application was
1269 probing. Hence, the correct factor that should be passed to this
1270 option would be 180/220 = 0.81.
1271
1272 .. _cfg=smpi/init:
1273
1274 Inject constant times for MPI_Init
1275 ..................................
1276
1277 **Option** ``smpi/init`` **default:** 0
1278
1279 The behavior and motivation for this configuration option is identical
1280 with :ref:`smpi/test <cfg=smpi/test>`, but for the function ``MPI_Init()``.
1281
1282 .. _cfg=smpi/ois:
1283
1284 Inject constant times for MPI_Isend()
1285 .....................................
1286
1287 **Option** ``smpi/ois``
1288
1289 The behavior and motivation for this configuration option is identical
1290 with :ref:`smpi/os <cfg=smpi/os>`, but for the function ``MPI_Isend()``.
1291
1292 .. _cfg=smpi/os:
1293
1294 Inject constant times for MPI_send()
1295 ....................................
1296
1297 **Option** ``smpi/os``
1298
1299 In several network models such as LogP, send (MPI_Send, MPI_Isend) and
1300 receive (MPI_Recv) operations incur costs (i.e., they consume CPU
1301 time). SMPI can factor these costs in as well, but the user has to
1302 configure SMPI accordingly as these values may vary by machine.  This
1303 can be done by using ``smpi/os`` for MPI_Send operations; for MPI_Isend
1304 and MPI_Recv, use ``smpi/ois`` and ``smpi/or``, respectively. These work
1305 exactly as ``smpi/ois``.
1306
1307 This item can consist of multiple sections; each section takes three
1308 values, for example ``1:3:2;10:5:1``.  The sections are divided by ";"
1309 so this example contains two sections.  Furthermore, each section
1310 consists of three values.
1311
1312 1. The first value denotes the minimum size in bytes for this section to take effect;
1313    read it as "if message size is greater than this value (and other section has a larger
1314    first value that is also smaller than the message size), use this".
1315    In the first section above, this value is "1".
1316
1317 2. The second value is the startup time; this is a constant value that will always
1318    be charged, no matter what the size of the message. In the first section above,
1319    this value is "3".
1320
1321 3. The third value is the `per-byte` cost. That is, it is charged for every
1322    byte of the message (incurring cost messageSize*cost_per_byte)
1323    and hence accounts also for larger messages. In the first
1324    section of the example above, this value is "2".
1325
1326 Now, SMPI always checks which section it should use for a given
1327 message; that is, if a message of size 11 is sent with the
1328 configuration of the example above, only the second section will be
1329 used, not the first, as the first value of the second section is
1330 closer to the message size. Hence, when ``smpi/os=1:3:2;10:5:1``, a
1331 message of size 11 incurs the following cost inside MPI_Send:
1332 ``5+11*1`` because 5 is the startup cost and 1 is the cost per byte.
1333
1334 Note that the order of sections can be arbitrary; they will be ordered internally.
1335
1336 .. _cfg=smpi/or:
1337
1338 Inject constant times for MPI_Recv()
1339 ....................................
1340
1341 **Option** ``smpi/or``
1342
1343 The behavior and motivation for this configuration option is identical
1344 with :ref:`smpi/os <cfg=smpi/os>`, but for the function ``MPI_Recv()``.
1345
1346 .. _cfg=smpi/test:
1347 .. _cfg=smpi/grow-injected-times:
1348
1349 Inject constant times for MPI_Test
1350 ..................................
1351
1352 **Option** ``smpi/test`` **default:** 0.0001
1353
1354 By setting this option, you can control the amount of time a process
1355 sleeps when MPI_Test() is called; this is important, because SimGrid
1356 normally only advances the time while communication is happening and
1357 thus, MPI_Test will not add to the time, resulting in deadlock if it is
1358 used as a break-condition as in the following example:
1359
1360 .. code-block:: cpp
1361
1362    while(!flag) {
1363        MPI_Test(request, flag, status);
1364        ...
1365    }
1366
1367 To speed up execution, we use a counter to keep track of how often we
1368 checked if the handle is now valid or not. Hence, we actually
1369 use counter*SLEEP_TIME, that is, the time MPI_Test() causes the
1370 process to sleep increases linearly with the number of previously
1371 failed tests. This behavior can be disabled by setting
1372 ``smpi/grow-injected-times`` to **no**. This will also disable this
1373 behavior for MPI_Iprobe.
1374
1375 .. _cfg=smpi/shared-malloc:
1376 .. _cfg=smpi/shared-malloc-hugepage:
1377
1378 Factorize malloc()s
1379 ...................
1380
1381 **Option** ``smpi/shared-malloc`` **Possible values:** global (default), local
1382
1383 If your simulation consumes too much memory, you may want to modify
1384 your code so that the working areas are shared by all MPI ranks. For
1385 example, in a block-cyclic matrix multiplication, you will only
1386 allocate one set of blocks, and all processes will share them.
1387 Naturally, this will lead to very wrong results, but this will save a
1388 lot of memory. So this is still desirable for some studies. For more on
1389 the motivation for that feature, please refer to the `relevant section
1390 <https://simgrid.github.io/SMPI_CourseWare/topic_understanding_performance/matrixmultiplication>`_
1391 of the SMPI CourseWare (see Activity #2.2 of the pointed
1392 assignment). In practice, change the calls for malloc() and free() into
1393 SMPI_SHARED_MALLOC() and SMPI_SHARED_FREE().
1394
1395 SMPI provides two algorithms for this feature. The first one, called 
1396 ``local``, allocates one block per call to SMPI_SHARED_MALLOC()
1397 (each call site gets its own block) ,and this block is shared
1398 among all MPI ranks.  This is implemented with the shm_* functions
1399 to create a new POSIX shared memory object (kept in RAM, in /dev/shm)
1400 for each shared block.
1401
1402 With the ``global`` algorithm, each call to SMPI_SHARED_MALLOC()
1403 returns a new address, but it only points to a shadow block: its memory
1404 area is mapped on a 1 MiB file on disk. If the returned block is of size
1405 N MiB, then the same file is mapped N times to cover the whole block.
1406 At the end, no matter how many times you call SMPI_SHARED_MALLOC, this will
1407 only consume 1 MiB in memory.
1408
1409 You can disable this behavior and come back to regular mallocs (for
1410 example for debugging purposes) using ``no`` as a value.
1411
1412 If you want to keep private some parts of the buffer, for instance if these
1413 parts are used by the application logic and should not be corrupted, you
1414 can use SMPI_PARTIAL_SHARED_MALLOC(size, offsets, offsets_count). For example:
1415
1416 .. code-block:: cpp
1417
1418    mem = SMPI_PARTIAL_SHARED_MALLOC(500, {27,42 , 100,200}, 2);
1419
1420 This will allocate 500 bytes to mem, such that mem[27..41] and
1421 mem[100..199] are shared while other area remain private.
1422
1423 Then, it can be deallocated by calling SMPI_SHARED_FREE(mem).
1424
1425 When smpi/shared-malloc:global is used, the memory consumption problem
1426 is solved, but it may induce too much load on the kernel's pages table.
1427 In this case, you should use huge pages so that the kernel creates only one
1428 entry per MB of malloced data instead of one entry per 4 kB.
1429 To activate this, you must mount a hugetlbfs on your system and allocate
1430 at least one huge page:
1431
1432 .. code-block:: shell
1433
1434     mkdir /home/huge
1435     sudo mount none /home/huge -t hugetlbfs -o rw,mode=0777
1436     sudo sh -c 'echo 1 > /proc/sys/vm/nr_hugepages' # echo more if you need more
1437
1438 Then, you can pass the option
1439 ``--cfg=smpi/shared-malloc-hugepage:/home/huge`` to smpirun to
1440 actually activate the huge page support in shared mallocs.
1441
1442 .. _cfg=smpi/wtime:
1443
1444 Inject constant times for MPI_Wtime, gettimeofday and clock_gettime
1445 ...................................................................
1446
1447 **Option** ``smpi/wtime`` **default:** 10 ns
1448
1449 This option controls the amount of (simulated) time spent in calls to
1450 MPI_Wtime(), gettimeofday() and clock_gettime(). If you set this value
1451 to 0, the simulated clock is not advanced in these calls, which leads
1452 to issues if your application contains such a loop:
1453
1454 .. code-block:: cpp
1455
1456    while(MPI_Wtime() < some_time_bound) {
1457         /* some tests, with no communication nor computation */
1458    }
1459
1460 When the option smpi/wtime is set to 0, the time advances only on
1461 communications and computations. So the previous code results in an
1462 infinite loop: the current [simulated] time will never reach
1463 ``some_time_bound``.  This infinite loop is avoided when that option
1464 is set to a small value, as it is by default since SimGrid v3.21.
1465
1466 Note that if your application does not contain any loop depending on
1467 the current time only, then setting this option to a non-zero value
1468 will slow down your simulations by a tiny bit: the simulation loop has
1469 to be broken out of and reset each time your code asks for the current time.
1470 If the simulation speed really matters to you, you can avoid this
1471 extra delay by setting smpi/wtime to 0.
1472
1473 .. _cfg=smpi/list-leaks:
1474
1475 Report leaked MPI objects
1476 .........................
1477
1478 **Option** ``smpi/list-leaks`` **default:** 0
1479
1480 This option controls whether to report leaked MPI objects.
1481 The parameter is the number of leaks to report.
1482
1483 Other Configurations
1484 --------------------
1485
1486 .. _cfg=debug/clean-atexit:
1487
1488 Cleanup at Termination
1489 ......................
1490
1491 **Option** ``debug/clean-atexit`` **default:** on
1492
1493 If your code is segfaulting during its finalization, it may help to
1494 disable this option to request that SimGrid not attempt any cleanups at
1495 the end of the simulation. Since the Unix process is ending anyway,
1496 the operating system will wipe it all.
1497
1498 .. _cfg=path:
1499
1500 Search Path
1501 ...........
1502
1503 **Option** ``path`` **default:** . (current dir)
1504
1505 It is possible to specify a list of directories to search in for the
1506 trace files (see :ref:`pf_trace`) by using this configuration
1507 item. To add several directory to the path, set the configuration
1508 item several times, as in ``--cfg=path:toto --cfg=path:tutu``
1509
1510 .. _cfg=debug/breakpoint:
1511
1512 Set a Breakpoint
1513 ................
1514
1515 **Option** ``debug/breakpoint`` **default:** unset
1516
1517 This configuration option sets a breakpoint: when the simulated clock
1518 reaches the given time, a SIGTRAP is raised.  This can be used to stop
1519 the execution and get a backtrace with a debugger.
1520
1521 It is also possible to set the breakpoint from inside the debugger, by
1522 writing in global variable simgrid::simix::breakpoint. For example,
1523 with gdb:
1524
1525 .. code-block:: shell
1526
1527    set variable simgrid::simix::breakpoint = 3.1416
1528
1529 .. _cfg=debug/verbose-exit:
1530
1531 Behavior on Ctrl-C
1532 ..................
1533
1534 **Option** ``debug/verbose-exit`` **default:** on
1535
1536 By default, when Ctrl-C is pressed, the status of all existing actors
1537 is displayed before exiting the simulation. This is very useful to
1538 debug your code, but it can become troublesome if you have many
1539 actors. Set this configuration item to **off** to disable this
1540 feature.
1541
1542 .. _cfg=exception/cutpath:
1543
1544 Truncate local path from exception backtrace
1545 ............................................
1546
1547 **Option** ``exception/cutpath`` **default:** off
1548
1549 This configuration option is used to remove the path from the
1550 backtrace shown when an exception is thrown. This is mainly useful for
1551 the tests: the full file path would makes the tests non-reproducible because
1552 the paths of source files depend of the build settings. That would
1553 break most of the tests since their output is continually compared.
1554
1555 .. _logging_config:
1556
1557 Logging configuration
1558 ---------------------
1559
1560 As introduced in :ref:`outcome_logs`, the SimGrid logging mechanism allows to configure at runtime the messages that should be displayed and those that should be omitted. Each
1561 message produced in the code is given a category (denoting its topic) and a priority. Then at runtime, each category is given a threshold (only messages of priority higher than
1562 that threshold are displayed), a layout (deciding how the messages in this category are formatted), and an appender (deciding what to do with the message: either print on stderr or
1563 to a file).
1564
1565 This section explains how to configure this logging features. You can also refer to the documentation of the :ref:`programmer's interface <logging_prog>`, that allows to produce
1566 messages from your code.
1567
1568 Most of the time, the logging mechanism is configured at runtime using the ``--log`` command-line argument, even if you can also use :c:func:`xbt_log_control_set()` to control it from
1569 your program. To pass configure more than one setting, you can either pass several ``--log`` arguments, or separate your settings with spaces, that must be quoted accordingly. In
1570 practice, the following is equivalent to the above settings: ``--log=root.thresh:error --log=s4u_host.thresh:debug``.
1571
1572 If you want to specify more than one setting, you can either pass several ``--log`` argument to your program as above, or separate them with spaces. In this case, you want to quote
1573 your settings, as in ``--log="root.thresh:error s4u_host.thresh:debug"``. The parameters are interpreted in order, from left to right.
1574
1575
1576 Threshold configuration
1577 .......................
1578
1579 The keyword ``threshold`` controls which logging event will get displayed in a given category. For example, ``--log=root.threshold:debug`` displays *every* message produced in the
1580 ``root`` category and its subcategories (i.e., every message produced -- this is *extremely* verbose), while ``--log=root.thres:critical`` turns almost everything off. As you can
1581 see, ``threshold`` can be abbreviated here.
1582
1583 Existing thresholds:
1584
1585  - ``trace`` some functions display a message at this level when entering or returning
1586  - ``debug`` output that is mostly useful when debugging the corresponding module.
1587  - ``verbose`` verbose output that is only mildly interesting and can easily be ignored
1588  - ``info`` usual output (this is the default threshold of all categories)
1589  - ``warning`` minor issue encountered
1590  - ``error`` issue encountered
1591  - ``critical`` major issue encountered, such as assertions failures
1592
1593 .. _log/fmt:
1594
1595 Format configuration
1596 ....................
1597
1598 The keyword ``fmt`` controls the layout (the format) of a logging category. For example, ``--log=root.fmt:%m`` reduces the output to the user-message only, removing any decoration such
1599 as the date, or the actor ID, everything. Existing format directives:
1600
1601  - %%: the % char
1602  - %n: line separator (LOG4J compatible)
1603  - %e: plain old space (SimGrid extension)
1604
1605  - %m: user-provided message
1606
1607  - %c: Category name (LOG4J compatible)
1608  - %p: Priority name (LOG4J compatible)
1609
1610  - %h: Hostname (SimGrid extension)
1611  - %a: Actor name (SimGrid extension -- note that with SMPI this is the integer value of the process rank)
1612  - %i: Actor PID (SimGrid extension -- this is a 'i' as in 'i'dea)
1613  - %t: Thread "name" (LOG4J compatible -- actually the address of the thread in memory)
1614
1615  - %F: file name where the log event was raised (LOG4J compatible)
1616  - %l: location where the log event was raised (LOG4J compatible, like '%%F:%%L' -- this is a l as in 'l'etter)
1617  - %L: line number where the log event was raised (LOG4J compatible)
1618  - %M: function name (LOG4J compatible -- called method name here of course).
1619
1620  - %d: date (UNIX-like epoch)
1621  - %r: application age (time elapsed since the beginning of the application)
1622
1623
1624 ``--log=root.fmt:'[%h:%a:(%i) %r] %l: %m%n'`` gives you the default layout used for info messages while ``--log=root.fmt:'[%h:%a:(%i) %r] %l: [%c/%p] %m%n'`` gives you the default
1625 layout for the other priorities (it adds the source code location). Also, the actor identification is omitted by the default layout for the messages coming directly from the
1626 SimGrid kernel, so info messages are formatted with ``[%r] [%c/%p] %m%n`` in this case. When specifying the layout manually, such distinctions are currently impossible, and the
1627 provided layout is used for every messages.
1628
1629 As with printf, you can specify the precision and width of the fields. For example, ``%.4r`` limits the date precision to four digits while ``%15h`` limits the host name to at most
1630 15 chars.
1631
1632
1633 If you want to have spaces in your log format, you should protect it. Otherwise, SimGrid will consider that this is a space-separated list of several parameters. But you should
1634 also protect it from the shell that also splits command line arguments on spaces. At the end, you should use something such as ``--log="'root.fmt:%l: [%p/%c]: %m%n'"``. 
1635 Another option is to use the ``%e`` directive for spaces, as in ``--log=root.fmt:%l:%e[%p/%c]:%e%m%n``. 
1636
1637 Category appender
1638 .................
1639
1640 The keyword ``app`` controls the appended of a logging category. For example ``--log=root.app:file:mylogfile`` redirects every output to the file ``mylogfile``.
1641
1642 With the ``splitfile`` appender, a new file is created when the size of the output reaches the specified size. The format is ``--log=root.app:splitfile:<size>:<file name>``. For
1643 example, ``--log=root.app:splitfile:500:mylog_%`` creates log files of at most 500 bytes, using the names ``mylog_0``, ``mylog_1``, ``mylog_2``, etc.
1644
1645 The ``rollfile`` appender uses one file only, but the file is emptied and recreated when its size reaches the specified maximum. For example, ``--log=root.app:rollfile:500:mylog``
1646 ensures that the log file ``mylog`` will never overpass 500 bytes in size.
1647
1648 Any appender setup this way have its own layout format, that you may change afterward. When specifying a new appender, its additivity is set to false to prevent log event displayed
1649 by this appender to "leak" to any other appender higher in the hierarchy. You can naturally change that if you want your messages to be displayed twice.
1650
1651 Category additivity
1652 ...................
1653
1654 The keyword ``add`` controls the additivity of a logging category. By default, the messages are only passed one appender only: the more specific, i.e. the first one found when
1655 climbing the tree from the category in which they were produced. In Log4J parlance, it is said that the default additivity of appenders is false. If you change this setting to
1656 ``on`` (or ``yes`` or ``1``), the produced messages will also be passed to the upper appender.
1657
1658 Let's consider a more complex example: ``--log="root.app:file:all.log s4u.app:file:iface.log xbt.app:file:xbt.log xbt.add:yes``. Here, the logging of s4u will be sent to the
1659 ``iface.log`` file; the logging of the xbt toolbox will be sent to both the ``xbt.log`` file and the ``all.log`` file (because xbt additivity was enabled); and every other loggings
1660 will only be sent to ``all.log``.
1661
1662 Other options
1663 .............
1664
1665 ``--help-logs`` displays a complete help message about logging in SimGrid.
1666
1667 ``--help-log-categories`` displays the actual hierarchy of log categories for this binary.
1668
1669 ``--log=no_loc`` hides the source locations (file names and line numbers) from the messages. This is useful to make tests reproducible.
1670
1671
1672 .. |br| raw:: html
1673
1674    <br />