SimGrid  3.12
Versatile Simulation of Distributed Systems
MSG examples

MSG examples from examples directory examples/msg. More...

MSG examples from examples directory examples/msg.

MSG comes with an extensive set of examples. It is sometimes difficult to find the one you need. This list aims at helping you finding the example from which you can learn what you want to.

Basic examples

Asynchronous communications

There is several examples of asynchronous communications coming in the archive. In addition to the fully documented example Asynchronous communications, there is several other examples in the archive:

Tracing and vizualisation features

Models-related examples

Packet level simulators

These examples demonstrate how to use the bindings to classical Packet-Level Simulators (PLS), as explained in Packet level simulation. The most interesting is probably not the C files since they are unchanged from the other simulations, but the associated files, such as the platform files to see how to declare a platform to be used with the PLS bindings of SimGrid and the tesh files to see how to actually start a simulation in these settings.

Other resource kinds

This section contains some sparse examples of how to use the other kind of resources, such as disk or GPU. These resources are quite experimental for now, but here we go anyway.

Trace driven simulations

The actions/actions.c example demonstrates how to run trace-driven simulations. It is very handy when you want to test an algorithm or protocol that does nothing unless it receives some events from outside. For example, a P2P protocol reacts to requests from the user, but does nothing if there is no such event.

In such situations, SimGrid allows to write your protocol in your C file, and the events to react to in a separate text file. Declare a function handling each of the events that you want to accept in your trace files, register them using xbt_replay_action_register in your main, and then use MSG_action_trace_run to launch the simulation. You can either have one trace file containing all your events, or a file per simulated process. Check the tesh files in the example directory for details on how to do it.

This example uses this approach to replay MPI-like traces. It comes with a set of event handlers reproducing MPI events. This is somehow similar to SMPI, yet differently implemented. This code should probably be changed to use SMPI internals instead, but wasn't, so far.

Examples of full applications