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. Recommanded options:
96 @verbatim --cfg=tracing:yes --cfg=tracing/uncategorized:yes @endverbatim
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 platform visualization. Recommanded options:
102 @verbatim --cfg=tracing:yes --cfg=tracing/categorized:yes
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. Recommanded options:
111 @verbatim --cfg=tracing:yes --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes --cfg=viva/categorized:viva_cat.plist --cfg=viva/uncategorized:viva_uncat.plist
114 - <b>Master Workers tracing</b>.
115 @ref examples/msg/trace-masterworker/trace-masterworker.c \n
116 This is an augmented version of our basic master/worker example
117 using several tracing features. It traces resource usage, sorted
118 out in several categories; Trace marks and user variables are also
119 used. Recommanded options:
120 @verbatim --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes --cfg=viva/categorized:viva_cat.plist --cfg=viva/uncategorized:viva_uncat.plist
123 - <b>Process migration tracing</b>.
124 @ref examples/msg/trace-process-migration/trace-process-migration.c \n
125 This version is enhanced so that the process migrations can be
126 displayed as arrows in a Gantt-chart visualization. Recommanded
127 options to that extend:
128 @verbatim -cfg=tracing:yes --cfg=tracing/msg/process:yes
131 @subsection msg_ex_tracing_user_variables Tracing user variables
133 You can also attach your own variables to a any resource described in
134 the platform file. The following examples illustrate this feature.
135 They have to be run with the following options:
136 @verbatim --cfg=tracing:yes --cfg=tracing/platform:yes
139 - <b>Attaching variables to Hosts</b>.
140 @ref examples/msg/trace-user-variables/trace-user-variables.c
142 - <b>Attaching variables to Links</b>.
143 @ref examples/msg/trace-link-user-variables/trace-link-user-variables.c \n
144 The tricky part is that you have to know the name of the link you
145 want to enhance with a variable.
147 - <b>Attaching variables to network Routes</b>
148 @ref examples/msg/trace-link-srcdst-user-variables/trace-link-srcdst-user-variables.c \n
149 It is often easier to update a given variable for all links of a
150 given network path (identified by its source and destination
151 hosts) instead of knowing the name of each specific link.
153 - @ref examples/msg/network-ns3/network-ns3.c \n
154 - @ref examples/msg/io-storage/io-storage.c \n
155 - @ref examples/msg/io-file/io-file.c \n
156 - @ref examples/msg/io-remote/io-remote.c \n
157 - @ref examples/msg/actions-comm/actions-comm.c \n
158 - @ref examples/msg/actions-storage/actions-storage.c \n
159 - @ref examples/msg/app-pmm/app-pmm.c \n
160 - @ref examples/msg/dht-chord \n
161 - @ref examples/msg/task-priority/task-priority.c \n
162 - @ref examples/msg/properties/properties.c \n
166 As a human, you can stop reading at this point. The rest is garbage:
168 Every example must be listed in the following, but it's not possible
169 to move this content upper as each @example directive seems to eat the
170 next doxygen commands (and the content is placed at the top of the
175 @defgroup MSG_ex_examples ignored
176 @example examples/msg/app-pingpong/app-pingpong.c
177 @example examples/msg/app-token-ring/app-token-ring.c
178 @example examples/msg/app-masterworker/app-masterworker.c
180 @example examples/msg/async-wait/async-wait.c
181 @example examples/msg/async-waitall/async-waitall.c
182 @example examples/msg/async-waitall/async-waitany.c
184 @example examples/msg/process-suspend/process-suspend.c
185 @example examples/msg/process-kill/process-kill.c
186 @example examples/msg/process-migration/process-migration.c
187 @example examples/msg/process-startkilltime/process-startkilltime.c
189 @example examples/msg/trace-simple/trace-simple.c
190 @example examples/msg/trace-platform/trace-platform.c
191 @example examples/msg/trace-categories/trace-categories.c
192 @example examples/msg/trace-masterworker/trace-masterworker.c
193 @example examples/msg/trace-process-migration/trace-process-migration.c
194 @example examples/msg/trace-user-variables/trace-user-variables.c
195 @example examples/msg/trace-link-user-variables/trace-link-user-variables.c
196 @example examples/msg/trace-link-srcdst-user-variables/trace-link-srcdst-user-variables.c
198 @example examples/msg/network-ns3/network-ns3.c
199 @example examples/msg/io-storage/io-storage.c
200 @example examples/msg/io-file/io-file.c
201 @example examples/msg/io-remote/io-remote.c
202 @example examples/msg/actions-comm/actions-comm.c
203 @example examples/msg/actions-storage/actions-storage.c
204 @example examples/msg/app-pmm/app-pmm.c
205 @example examples/msg/dht-chord
206 @example examples/msg/task-priority/task-priority.c
207 @example examples/msg/properties/properties.c
211 Basic examples and features
212 ===========================
214 * properties/msg_prop.c Attaching arbitrary information to host,
215 processes and such, and retrieving them with
216 MSG_host_get_properties(), MSG_host_get_property_value(),
217 MSG_process_get_properties() and MSG_process_get_property_value().
218 Also make sure to read the platform and deployment XML files to see
219 how to declare these data.
221 * parallel_task/parallel_task.c: Demonstrates the use of
222 MSG_parallel_task_create(), to create special tasks that run on
223 several hosts at the same time. The resulting simulations are very
224 close to what can be achieved in SimDag, but still allows to use
225 the other features of MSG (it'd be cool to be able to mix
226 interfaces, but it's not possible ATM).
228 * priority/priority.c: Demonstrates the use of
229 MSG_task_set_priority() to change the computation priority of a
232 Models-related examples
233 =======================
235 Packet level simulators
236 -----------------------
237 These examples demonstrate how to use the bindings to classical
238 Packet-Level Simulators (PLS), as explained in the relevant part of
239 the web documentation. The most interesting is probably not the C
240 files since they are unchanged from the other simulations, but the
241 associated files, such as the platform files to see how to declare a
242 platform to be used with the PLS bindings of SimGrid and the tesh
243 files to see how to actually start a simulation in these settings.
245 * ns3: Simple ping-pong using ns3 instead of the SimGrid models
246 * gtnets Simple ping-pong using GTNeTs instead of the SimGrid models
250 This section contains some sparse examples of how to use the other
251 kind of resources, such as disk. These resources are quite
252 experimental for now, but here we go anyway.
254 * io/file.c Example with the disk resource
256 Trace driven simulations
257 ========================
259 The actions/actions.c example demonstrates how to run trace-driven
260 simulations. It is very handy when you want to test an algorithm or
261 protocol that does nothing unless it receives some events from
262 outside. For example, a P2P protocol reacts to requests from the user,
263 but does nothing if there is no such event.
265 In such situations, SimGrid allows to write your protocol in your C
266 file, and the events to react to in a separate text file. Declare a
267 function handling each of the events that you want to accept in your
268 trace files, register them using MSG_action_register in your main, and
269 then use MSG_action_trace_run to launch the simulation. You can either
270 have one trace file containing all your events, or a file per
271 simulated process. Check the tesh files in the example directory for
272 details on how to do it.
274 This example uses this approach to replay MPI-like traces. It comes
275 with a set of event handlers reproducing MPI events. This is somehow
276 similar to SMPI, yet differently implemented. This code should
277 probably be changed to use SMPI internals instead, but wasn't, so far.
279 Examples of full applications
280 =============================
282 * chord/chord.c: Classical Chord P2P protocol This example implements
283 the well known Chord P2P protocol. Its main advantage is that it
284 constitute a fully working non-trivial example. In addition, its
285 implementation is rather efficient, as demonstrated in
286 [57]http://hal.inria.fr/inria-00602216/