1 This file follows the Doxygen syntax to be included in the
2 documentation, but it should remain readable directly.
5 @defgroup MSG_examples MSG examples
7 @brief Find the MSG example fitting your needs from the extensive set provided in the archive.
13 - @ref msg_ex_tracing_user_variables
17 - @ref msg_ex_full_apps
20 @section msg_ex_basic Basic examples and features
22 - <b>Ping Pong</b>: @ref examples/msg/app-pingpong/app-pingpong.c\n
23 It's hard to think of a simpler example: it is just sending one
24 message back and forth.
25 The tesh file laying in the directory show how to start the
26 simulator binary, enlighting how to pass options to the simulators
27 (as detailed in Section \ref options).
30 @ref examples/msg/app-token-ring/app-token-ring.c\n
31 Classical communication pattern, where a token is exchanged
32 along a ring to reach every participant.
33 The tesh file laying in the directory shows how to run the same
34 example on different virtual platforms.
36 - <b>Master Workers</b>.
37 @ref examples/msg/app-masterworker/app-masterworker.c\n
38 Another good old example, where one Master process has a bunch of
39 task to dispatch to a set of several Worker processes. It is fully
40 commented in @ref MSG_ex_master_worker.
42 @section msg_ex_async Asynchronous communications
44 In addition to the fully documented example of @ref
45 MSG_ex_asynchronous_communications, there are several other examples
46 shipped in the archive:
48 - <b>Basic asynchronous communications</b>.
49 @ref examples/msg/async-wait/async-wait.c \n
50 Illustrates how to have non-blocking communications, that are
51 communications running in the background leaving the process free
52 to do something else during their completion. The main functions
53 involved are @ref MSG_task_isend, @ref MSG_task_irecv, and @ref
56 - <b>Waiting for all communications in a set</b>.
57 @ref examples/msg/async-waitall/async-waitall.c\n
58 The @ref MSG_comm_waitall function is useful when you want to block
59 until all activities in a given set have completed.
61 - <b>Waiting for the first completed communication in a set</b>.
62 @ref examples/msg/async-waitall/async-waitany.c\n
63 The @ref MSG_comm_waitany function is useful when you want to block
64 until one activity of the set completes, no matter which terminates
67 @section msg_ex_process Acting on Processes
69 - <b>Suspend and Resume processes</b>.
70 @ref examples/msg/process-suspend/process-suspend.c \n
71 Processes can be suspended and resumed during their executions
72 thanks to the @ref MSG_process_suspend and @ref MSG_process_resume functions.
74 - <b>Kill processes</b>.
75 @ref examples/msg/process-kill/process-kill.c \n
76 Processes can forcefully stop other processes with the @ref MSG_process_kill function.
78 - <b>Migrating processes</b>.
79 @ref examples/msg/process-migration/process-migration.c \n
80 Processes can move or be moved from a host to another with the @ref MSG_process_migrate function.
82 - <b>Controling the process life cycle from the XML</b>.
83 @ref examples/msg/process-startkilltime/process-startkilltime.c \n
84 You can specify a start time and a kill time in the deployment
85 file. See all *_d.xml files in this directory.
87 @section msg_ex_tracing Tracing and visualization features
89 Tracing can be activated by various configuration options which
90 are illustrated in these example. See also the
91 @ref tracing_tracing_options "full list of options related to tracing".
93 - <b>Basic example</b>. @ref examples/msg/trace-simple/trace-simple.c \n
94 In this very simple program, each process creates, executes,
95 and destroy a task. You might want to run it with the
96 <i>--cfg=tracing/uncategorized:yes</i> option.
98 - <b>Platform tracing</b>.
99 @ref examples/msg/trace-platform/trace-platform.c \n
100 This program is a toy example just loading the platform, so that
101 you can play with the <i>--cfg=tracing:yes</i> and
102 <i>--cfg=tracing/categorized:yes</i> options and visualize the
105 - <b>Setting Categories</b>.
106 @ref examples/msg/trace-categories/trace-categories.c \n
107 This example declares several tracing categories
108 to that are used to classify its tasks. When the program is executed,
109 the tracing mechanism registers the resource utilization of hosts
110 and links according to these categories.\n
111 You want to run this program with the following options:
112 <i>--cfg=tracing:yes</i>, <i>--cfg=tracing/categorized:yes</i>,
113 <i>--cfg=tracing/uncategorized:yes</i>, <i>--cfg=viva/categorized:viva_cat.plist</i>, and
114 <i>--cfg=viva/uncategorized:viva_uncat.plist</i>.
118 @example examples/msg/trace-masterworker/trace-masterworker.c
119 @example examples/msg/trace-process-migration/trace-process-migration.c
120 @example examples/msg/trace-user-variables/trace-user-variables.c
121 @example examples/msg/trace-link-user-variables/trace-link-user-variables.c
122 @example examples/msg/trace-link-srcdst-user-variables/trace-link-srcdst-user-variables.c
123 @example examples/msg/network-ns3/network-ns3.c
124 @example examples/msg/io-storage/io-storage.c
125 @example examples/msg/io-file/io-file.c
126 @example examples/msg/io-remote/io-remote.c
127 @example examples/msg/actions-comm/actions-comm.c
128 @example examples/msg/actions-storage/actions-storage.c
129 @example examples/msg/app-pmm/app-pmm.c
130 @example examples/msg/dht-chord
131 @example examples/msg/task-priority/task-priority.c
132 @example examples/msg/properties/properties.c
136 As a human, you can stop reading at this point. The rest is garbage:
138 Every example must be listed in the following, but it's not possible
139 to move this content upper as each @example directive seems to eat the
140 next doxygen commands (and the content is placed at the top of the
145 @defgroup MSG_ex_examples ignored
146 @example examples/msg/app-pingpong/app-pingpong.c
147 @example examples/msg/app-token-ring/app-token-ring.c
148 @example examples/msg/app-masterworker/app-masterworker.c
150 @example examples/msg/async-wait/async-wait.c
151 @example examples/msg/async-waitall/async-waitall.c
152 @example examples/msg/async-waitall/async-waitany.c
154 @example examples/msg/process-suspend/process-suspend.c
155 @example examples/msg/process-kill/process-kill.c
156 @example examples/msg/process-migration/process-migration.c
157 @example examples/msg/process-startkilltime/process-startkilltime.c
159 @example examples/msg/trace-simple/trace-simple.c
160 @example examples/msg/trace-platform/trace-platform.c
161 @example examples/msg/trace-categories/trace-categories.c
162 @example examples/msg/trace-masterworker/trace-masterworker.c
163 @example examples/msg/trace-process-migration/trace-process-migration.c
164 @example examples/msg/trace-user-variables/trace-user-variables.c
165 @example examples/msg/trace-link-user-variables/trace-link-user-variables.c
166 @example examples/msg/trace-link-srcdst-user-variables/trace-link-srcdst-user-variables.c
168 @example examples/msg/network-ns3/network-ns3.c
169 @example examples/msg/io-storage/io-storage.c
170 @example examples/msg/io-file/io-file.c
171 @example examples/msg/io-remote/io-remote.c
172 @example examples/msg/actions-comm/actions-comm.c
173 @example examples/msg/actions-storage/actions-storage.c
174 @example examples/msg/app-pmm/app-pmm.c
175 @example examples/msg/dht-chord
176 @example examples/msg/task-priority/task-priority.c
177 @example examples/msg/properties/properties.c
181 Basic examples and features
182 ===========================
184 * migration/migration.c Demonstrates how to use the
185 MSG_process_migrate() function to let processes change the host
186 they run on after their start.
188 * suspend/suspend.c: Demonstrates how to suspend and resume processes
189 using MSG_process_suspend() and MSG_process_resume().
191 * properties/msg_prop.c Attaching arbitrary information to host,
192 processes and such, and retrieving them with
193 MSG_host_get_properties(), MSG_host_get_property_value(),
194 MSG_process_get_properties() and MSG_process_get_property_value().
195 Also make sure to read the platform and deployment XML files to see
196 how to declare these data.
198 * parallel_task/parallel_task.c: Demonstrates the use of
199 MSG_parallel_task_create(), to create special tasks that run on
200 several hosts at the same time. The resulting simulations are very
201 close to what can be achieved in SimDag, but still allows to use
202 the other features of MSG (it'd be cool to be able to mix
203 interfaces, but it's not possible ATM).
205 * priority/priority.c: Demonstrates the use of
206 MSG_task_set_priority() to change the computation priority of a
209 Tracing and visualization features
210 ==================================
211 * tracing/simple.c very simple program that creates, executes and
214 * tracing/categories.c example with the declaration of multiple
216 * tracing/procmig.c example to trace process migration using the mask
218 * tracing/trace_platform.c: Demonstrates how to trace the platform
219 * tracing/user_variables.c: Demonstrates how to trace user-provided
222 Models-related examples
223 =======================
225 Packet level simulators
226 -----------------------
227 These examples demonstrate how to use the bindings to classical
228 Packet-Level Simulators (PLS), as explained in the relevant part of
229 the web documentation. The most interesting is probably not the C
230 files since they are unchanged from the other simulations, but the
231 associated files, such as the platform files to see how to declare a
232 platform to be used with the PLS bindings of SimGrid and the tesh
233 files to see how to actually start a simulation in these settings.
235 * ns3: Simple ping-pong using ns3 instead of the SimGrid models
236 * gtnets Simple ping-pong using GTNeTs instead of the SimGrid models
240 This section contains some sparse examples of how to use the other
241 kind of resources, such as disk. These resources are quite
242 experimental for now, but here we go anyway.
244 * io/file.c Example with the disk resource
246 Trace driven simulations
247 ========================
249 The actions/actions.c example demonstrates how to run trace-driven
250 simulations. It is very handy when you want to test an algorithm or
251 protocol that does nothing unless it receives some events from
252 outside. For example, a P2P protocol reacts to requests from the user,
253 but does nothing if there is no such event.
255 In such situations, SimGrid allows to write your protocol in your C
256 file, and the events to react to in a separate text file. Declare a
257 function handling each of the events that you want to accept in your
258 trace files, register them using MSG_action_register in your main, and
259 then use MSG_action_trace_run to launch the simulation. You can either
260 have one trace file containing all your events, or a file per
261 simulated process. Check the tesh files in the example directory for
262 details on how to do it.
264 This example uses this approach to replay MPI-like traces. It comes
265 with a set of event handlers reproducing MPI events. This is somehow
266 similar to SMPI, yet differently implemented. This code should
267 probably be changed to use SMPI internals instead, but wasn't, so far.
269 Examples of full applications
270 =============================
272 * chord/chord.c: Classical Chord P2P protocol This example implements
273 the well known Chord P2P protocol. Its main advantage is that it
274 constitute a fully working non-trivial example. In addition, its
275 implementation is rather efficient, as demonstrated in
276 [57]http://hal.inria.fr/inria-00602216/