Finding the right example in examples/msg is sometimes difficult. This list aims at helping you to find the example from which you can learn what you want to.
Basic examples
Asynchronous communications
In addition to the fully documented example of Asynchronous communications, there are several other examples shipped in the archive:
Acting on Processes
Tracing and visualization features
Tracing can be activated by various configuration options which are illustrated in these example. See Tracing configuration Options for details.
- Basic example: trace-simple/trace-simple.c. In this very simple program, each process creates, executes, and destroy a task. You might want to run it with the –cfg=tracing/uncategorized:yes option.
- Tracing the platform: trace-platform/trace-platform.c. This example just loads a platform file to demonstrate how it can be traced into the Paje trace file format. You might want to run this program with the following options: –cfg=tracing:yes and –cfg=tracing/categorized:yes.
- Setting Categories: trace-categories/trace-categories.c. This example declares several tracing categories that are used to classify tasks. When the program is executed, the tracing mechanism registers the resource utilization of hosts and links according to these categories. You might want to run this program with the following options: –cfg=tracing:yes, –cfg=tracing/categorized:yes, –cfg=tracing/uncategorized:yes, –cfg=viva/categorized:viva_cat.plist, and –cfg=viva/uncategorized:viva_uncat.plist.
- Master/Worker: trace-masterworker/trace-masterworker.c This is an augmented version of our basic master/worker example. It uses several tracing functions that enable the tracing of categorized resource utilization, the use of trace marks, and user variables associated to the hosts of the platform file. You might want to run this program with the following configuration options: –cfg=tracing/categorized:yes, –cfg=tracing/uncategorized:yes, –cfg=viva/categorized:viva_cat.plist, and –cfg=viva/uncategorized:viva_uncat.plist.
- Process migration: trace-process-migration/trace-process-migration.c. Running this program with the –cfg=tracing:yes and –cfg=tracing/msg/process:yes options enables a Gantt-chart visualization of where the process has been hosted during its execution. Migrations are represented by arrows from the origin to the destination host.
Tracing user variables
The tracing mechanism of SimGrid also allows to associate user variables to resources described in the platform file. The following examples illustrate this feature. They have to be run with the –cfg=tracing:yes and –cfg=tracing/platform:yes options.
Models-related examples
Packet level simulators
This example demonstrates how to use the bindings to a 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 file to see how to declare a platform to be used with the PLS bindings of SimGrid and the tesh file to see how to actually start a simulation in these settings.
Simulation disks and files
This section lists some examples of storage simulation. This part of SimGrid is still preliminary.
Trace driven simulations
This section details 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 you to write your protocol in a 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 directories for details on how to do it.
- Communication: actions-comm/actions-comm.c. This example comes with a set of event handlers reproducing some classical communication primitives (synchronous and asynchronous send/receive, broadcast, barrier, ...).
- I/O: actions-comm/actions-comm.c. This example comes with a set of event handlers reproducing some classical I/O primitives (open, read, write, close, ...).
Examples of full applications
- Parallel Matrix Multiplication: app-pmm/app-pmm.c. This little application is something that most MPI developers have written during their studies. Here it is implemented in MSG.
- Chord P2P protocol dht-chord/dht-chord.c:. This example implements the well known Chord P2P protocol. Its main advantage is that it constitutes a fully working non-trivial example. In addition, its implementation is rather efficient, as demonstrated in http://hal.inria.fr/inria-00602216/
Miscellaneous