SimGrid: MSG examples

SimGrid 3.10 Versatile Simulation of Distributed Systems

- Home page
- Online documentation
- Dev's Corner

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
MSG examples
MSG

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

- sendrecv/sendrecv.c: Ping-pong example. It's hard to think of a simpler example. The tesh files laying in the directory are instructive concerning the way to pass options to the simulators (as described in Simgrid options and configurations).

- masterslave/masterslave_forwarder.c: Master/slaves example. This good old example is also very simple. Its basic version is fully commented on this page: Basic Master/Slaves, but several variants can be found in the same directory.

- migration/migration.c Demonstrates how to use the MSG_process_migrate function to let processes change the host they run on after their start.

- suspend/suspend.c: Demonstrates how to suspend and resume processes using MSG_process_suspend and MSG_process_resume.

- properties/msg_prop.c Attaching arbitrary informations to host, processes and such, and retrieving them with MSG_host_get_properties, MSG_host_get_property_value, MSG_process_get_properties and MSG_process_get_property_value. Also make sure to read the platform and deployment XML files to see how to declare these data.

- parallel_task/parallel_task.c: Demonstrates the use of MSG_parallel_task_create, to create special tasks that run on several hosts at the same time. The resulting simulations are very close to what can be achieved in SimDag, but still allows to use the other features of MSG (it'd be cool to be able to mix interfaces, but it's not possible ATM).

- priority/priority.c: Demonstrates the use of MSG_task_set_priority to change the computation priority of a given task.

# 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:

- msg/icomms/peer.c: basic example of async functions (MSG_task_isend, MSG_task_irecv, MSG_comm_wait)

- msg/icomms/peer2.c: demonstrates the MSG_comm_waitall function

- msg/icomms/peer3.c: demonstrates the MSG_comm_waitany function

# Tracing and vizualization features

- tracing/simple.c very simple program where each process creates, executes and destroy a task. You might want to run this program with the following parameters: –cfg=tracing/uncategorized:yes (See Tracing configuration Options for details)

- tracing/ms.c This is a master/slave program where the master creates tasks, send them to the slaves. For each task received, the slave executes it and then destroys it. This program 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 parameters: –cfg=tracing/categorized:yes –cfg=tracing/uncategorized:yes –cfg=viva/categorized:viva_cat.plist –cfg=viva/uncategorized:viva_uncat.plist (See Tracing configuration Options for details)

- tracing/categories.c This is a master/slave program where the master creates tasks, send them to the slaves. For each task received, the slave executes it and then destroys it. This program 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 parameters: –cfg=tracing:yes –cfg=tracing/categorized:yes –cfg=tracing/uncategorized:yes –cfg=viva/categorized:viva_cat.plist –cfg=viva/uncategorized:viva_uncat.plist (See Tracing configuration Options for details)

- tracing/procmig.c This program shows a process migration. Tracing this program with the options below enables a gantt-chart visualization of where the process has been during its execution. Migrations are represented by arrows from the origin to the destination host. You might want to run this program with the following parameters: –cfg=tracing:yes –cfg=tracing/msg/process:yes (See Tracing configuration Options for details)

- tracing/trace_platform.c: This program demonstrates how a platform file is traced to a Paje trace file format using the tracing mechanism of Simgrid. You might want to run this program with the following parameters: –cfg=tracing:yes –cfg=tracing/categorized:yes (See Tracing configuration Options for details)

- tracing/user_variables.c: This program demonstrates how to trace user variables associated to the hosts of the platform file. You might want to run this program with the following parameters: –cfg=tracing:yes –cfg=tracing/platform:yes (See Tracing configuration Options for details)

- tracing/link_user_variables.c: This program demonstrates how to trace user variables associated to the links of the platform file. You need to provide the name of the link to update the value of the variable associated to that link. You might want to run this program with the following parameters: –cfg=tracing:yes –cfg=tracing/platform:yes (See Tracing configuration Options for details)

- tracing/link_srcdst_user_variables.c: This program demonstrates how to trace user variables associated to the links of the platform file. Instead of providing the name of the link to update one of its variable, this example shows how to provide two hosts as parameter (source and destination, use their names as defined in the platform file). The tracing mechanism will get the route between these two hosts, if there is one defined in the platform file, and update the variable of all the links of that route to the value provided. You might want to run this program with the following parameters: –cfg=tracing:yes –cfg=tracing/platform:yes (See Tracing configuration Options for details)

# 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.

- ns3: Simple ping-pong using ns3 instead of the SimGrid network models.

- gtnets Simple ping-pong using GTNeTs instead of the SimGrid network models.

## 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.

- io/file.c Example with the disk resource

- gpu/test_MSG_gpu_task_create.c Example of use of the very experimental (for now) GPU resource.

# 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

- token_ring/ring_call.c: Classical token ring communication, where a token is exchanged along a ring to reach every participant.

# Examples of full applications

- token_ring/token_bypass.c: Classical token ring with a bypass deployment. A token is exchanged along a ring to reach every participant.

- pmm/msg_pmm.c: Parallel Matrix Multiplication is a little application. This is something that most MPI developper have written during their class, here implemented using MSG instead of MPI.

- chord/chord.c: Classical Chord P2P protocol This example implements the well known Chord P2P protocol. Its main advantage is that it constitute a fully working non-trivial example. In addition, its implementation is rather efficient, as demonstrated in http://hal.inria.fr/inria-00602216/