Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
61f955966742a5024684ebef334993b69c374b8c
[simgrid.git] / examples / msg / README.doc
1 This file follows the Doxygen syntax to be included in the
2 documentation, but it should remain readable directly.
3
4 /** 
5  @defgroup MSG_examples MSG examples
6  @ingroup MSG_API
7  @brief Find the MSG example fitting your needs from the extensive set provided in the archive.
8
9   - @ref msg_ex_basic
10   - @ref msg_ex_async
11   - @ref msg_ex_process
12   - @ref msg_ex_tracing
13     - @ref msg_ex_tracing_user_variables
14   - @ref msg_ex_models
15     - @ref msg_ex_ns3
16     - @ref msg_ex_io
17   - @ref msg_ex_actions
18   - @ref msg_ex_full_apps
19   - @ref msg_ex_misc
20                     
21 @section msg_ex_basic Basic examples and features
22
23  - <b>Ping Pong</b>: @ref examples/msg/app-pingpong/app-pingpong.c\n
24    It's hard to think of a simpler example: it is just sending one
25    message back and forth.  
26    The tesh file laying in the directory show how to start the
27    simulator binary, enlighting how to pass options to the simulators
28    (as detailed in Section \ref options). 
29
30  - <b>Token Ring</b>.
31    @ref examples/msg/app-token-ring/app-token-ring.c\n
32    Classical communication pattern, where a token is exchanged
33    along a ring to reach every participant. 
34    The tesh file laying in the directory shows how to run the same
35    example on different virtual platforms.
36
37  - <b>Master Workers</b>.
38    @ref examples/msg/app-masterworker/app-masterworker.c\n
39    Another good old example, where one Master process has a bunch of
40    task to dispatch to a set of several Worker processes. It is fully
41    commented in @ref MSG_ex_master_worker.
42
43 @section msg_ex_async Asynchronous communications
44
45 In addition to the fully documented example of @ref
46 MSG_ex_asynchronous_communications, there are several other examples
47 shipped in the archive:
48   
49  - <b>Basic asynchronous communications</b>. 
50    @ref examples/msg/async-wait/async-wait.c \n
51    Illustrates how to have non-blocking communications, that are
52    communications running in the background leaving the process free
53    to do something else during their completion. The main functions
54    involved are @ref MSG_task_isend, @ref MSG_task_irecv, and @ref
55    MSG_comm_wait.
56  
57  - <b>Waiting for all communications in a set</b>.
58    @ref examples/msg/async-waitall/async-waitall.c\n
59    The @ref MSG_comm_waitall function is useful when you want to block
60    until all activities in a given set have completed.
61    
62  - <b>Waiting for the first completed communication in a set</b>.
63    @ref examples/msg/async-waitall/async-waitany.c\n
64    The @ref MSG_comm_waitany function is useful when you want to block
65    until one activity of the set completes, no matter which terminates
66    first.
67
68 @section msg_ex_process Acting on Processes
69
70   - <b>Suspend and Resume processes</b>.
71     @ref examples/msg/process-suspend/process-suspend.c \n
72     Processes can be suspended and resumed during their executions
73     thanks to the @ref MSG_process_suspend and @ref MSG_process_resume functions.
74
75   - <b>Kill processes</b>.
76     @ref examples/msg/process-kill/process-kill.c \n
77     Processes can forcefully stop other processes with the @ref MSG_process_kill function.
78      
79   - <b>Migrating processes</b>.
80     @ref examples/msg/process-migration/process-migration.c \n
81     Processes can move or be moved from a host to another with the @ref MSG_process_migrate function.
82     
83   - <b>Controling the process life cycle from the XML</b>.
84     @ref examples/msg/process-startkilltime/process-startkilltime.c \n
85     You can specify a start time and a kill time in the deployment
86     file. See all *_d.xml files in this directory.
87
88 TODO: add an example using @ref MSG_process_create()
89
90 @section msg_ex_tracing Tracing and visualization features
91
92 Tracing can be activated by various configuration options which
93 are illustrated in these example. See also the 
94 @ref tracing_tracing_options "full list of options related to tracing".
95
96   - <b>Basic example</b>. @ref examples/msg/trace-simple/trace-simple.c \n
97     In this very simple program, each process creates, executes,
98     and destroy a task. Recommanded options:
99     @verbatim --cfg=tracing:yes --cfg=tracing/uncategorized:yes @endverbatim
100
101   - <b>Platform tracing</b>.
102     @ref examples/msg/trace-platform/trace-platform.c \n
103     This program is a toy example just loading the platform, so that
104     you can play with the platform visualization. Recommanded options:
105     @verbatim --cfg=tracing:yes --cfg=tracing/categorized:yes
106     @endverbatim
107
108   - <b>Setting Categories</b>.
109     @ref examples/msg/trace-categories/trace-categories.c \n
110     This example declares several tracing categories
111     to that are used to classify its tasks. When the program is executed,
112     the tracing mechanism registers the resource utilization of hosts
113     and links according to these categories. Recommanded options:
114     @verbatim --cfg=tracing:yes --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes --cfg=viva/categorized:viva_cat.plist --cfg=viva/uncategorized:viva_uncat.plist
115     @endverbatim
116     
117   - <b>Master Workers tracing</b>.
118     @ref examples/msg/trace-masterworker/trace-masterworker.c \n
119     This is an augmented version of our basic master/worker example
120     using several tracing features. It traces resource usage, sorted
121     out in several categories; Trace marks and user variables are also
122     used. Recommanded options:
123     @verbatim --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes --cfg=viva/categorized:viva_cat.plist --cfg=viva/uncategorized:viva_uncat.plist
124     @endverbatim
125     
126   - <b>Process migration tracing</b>.
127     @ref examples/msg/trace-process-migration/trace-process-migration.c \n
128     This version is enhanced so that the process migrations can be
129     displayed as arrows in a Gantt-chart visualization. Recommanded
130     options to that extend:
131     @verbatim -cfg=tracing:yes --cfg=tracing/msg/process:yes
132     @endverbatim     
133
134 TODO: These tracing examples should be integrated in the examples to
135 not dupplicate the C files. A full command line to see the result in
136 the right tool (viva/vite/FrameSoc) should be given along with some
137 screenshots.
138
139 @subsection msg_ex_tracing_user_variables Tracing user variables
140
141 You can also attach your own variables to a any resource described in
142 the platform file. The following examples illustrate this feature.
143 They have to be run with the following options:
144 @verbatim --cfg=tracing:yes --cfg=tracing/platform:yes
145 @endverbatim
146  
147   - <b>Attaching variables to Hosts</b>.
148     @ref examples/msg/trace-user-variables/trace-user-variables.c 
149   
150   - <b>Attaching variables to Links</b>.
151     @ref examples/msg/trace-link-user-variables/trace-link-user-variables.c \n
152     The tricky part is that you have to know the name of the link you
153     want to enhance with a variable.
154     
155   - <b>Attaching variables to network Routes</b>
156     @ref examples/msg/trace-link-srcdst-user-variables/trace-link-srcdst-user-variables.c \n
157     It is often easier to update a given variable for all links of a
158     given network path (identified by its source and destination
159     hosts) instead of knowing the name of each specific link.
160
161 TODO: rename trace-user-variables to trace-host-user-variables
162
163 TODO: rename trace-link-srcdst-user-variables to trace-route-user-variables
164
165 @section msg_ex_models Models-related examples
166
167 @subsection msg_ex_ns3 NS3 as a SimGrid Network Model
168
169 This example demonstrates how to use the bindings to the Network
170 Simulator, as explained in @ref pls. The most
171 interesting is probably not the C files since they are unchanged from
172 the other simulations, but the associated files, such as the platform
173 file to see how to declare a platform to be used with the PLS bindings
174 of SimGrid and the tesh file to see how to actually start a simulation
175 in these settings.
176   
177   - @ref examples/msg/network-ns3/network-ns3.c. Simple ping-pong using
178     ns-3 instead of the SimGrid network models.
179
180 TODO: merge the C files
181
182 TODO: show the XML files instead if it's what is interesting. On a "XML example files" page that does not exist yet.
183
184 @subsection msg_ex_io Simulating disks and files
185
186 The examples of this section demonstrate how to interact with the
187 simulated storages.
188
189   - <b>Basic example</b>.
190     @ref examples/msg/io-storage/io-storage.c \n
191     All main storage and file functions are demoed.
192     
193   - <b>File Management</b>. @ref examples/msg/io-file/io-file.c \n
194     This example illustrates the use of operations on file
195     (@ref MSG_file_open, @ref MSG_file_read, @ref MSG_file_write,
196     or @ref MSG_file_close).
197     
198   - <b>Remote I/O</b>. @ref examples/msg/io-remote/io-remote.c \n
199     I/O operations can also be done in a remote, i.e. when the
200     accessed disk is not mounted on the caller's host.
201
202   - @ref examples/msg/actions-comm/actions-comm.c \n
203   - @ref examples/msg/actions-storage/actions-storage.c \n
204   - @ref examples/msg/app-pmm/app-pmm.c \n
205   - @ref examples/msg/dht-chord \n
206   - @ref examples/msg/task-priority/task-priority.c \n
207   - @ref examples/msg/properties/properties.c \n
208
209 */
210
211 As a human, you can stop reading at this point. The rest is garbage:
212
213 Every example must be listed in the following, but it's not possible
214 to move this content upper as each @example directive seems to eat the
215 next doxygen commands (and the content is placed at the top of the
216 example file). 
217
218
219 /**
220 @defgroup MSG_ex_examples ignored
221 @example examples/msg/app-pingpong/app-pingpong.c        
222 @example examples/msg/app-token-ring/app-token-ring.c    
223 @example examples/msg/app-masterworker/app-masterworker.c
224
225 @example examples/msg/async-wait/async-wait.c
226 @example examples/msg/async-waitall/async-waitall.c
227 @example examples/msg/async-waitall/async-waitany.c
228
229 @example examples/msg/process-suspend/process-suspend.c
230 @example examples/msg/process-kill/process-kill.c
231 @example examples/msg/process-migration/process-migration.c
232 @example examples/msg/process-startkilltime/process-startkilltime.c
233
234 @example examples/msg/trace-simple/trace-simple.c
235 @example examples/msg/trace-platform/trace-platform.c
236 @example examples/msg/trace-categories/trace-categories.c
237 @example examples/msg/trace-masterworker/trace-masterworker.c
238 @example examples/msg/trace-process-migration/trace-process-migration.c
239 @example examples/msg/trace-user-variables/trace-user-variables.c
240 @example examples/msg/trace-link-user-variables/trace-link-user-variables.c
241 @example examples/msg/trace-link-srcdst-user-variables/trace-link-srcdst-user-variables.c
242
243 @example examples/msg/network-ns3/network-ns3.c
244
245 @example examples/msg/io-storage/io-storage.c
246 @example examples/msg/io-file/io-file.c
247 @example examples/msg/io-remote/io-remote.c
248 @example examples/msg/actions-comm/actions-comm.c
249 @example examples/msg/actions-storage/actions-storage.c
250 @example examples/msg/app-pmm/app-pmm.c
251 @example examples/msg/dht-chord
252 @example examples/msg/task-priority/task-priority.c
253 @example examples/msg/properties/properties.c
254                          
255 */
256
257 Basic examples and features
258 ===========================
259
260  * properties/msg_prop.c Attaching arbitrary information to host,
261    processes and such, and retrieving them with
262    MSG_host_get_properties(), MSG_host_get_property_value(),
263    MSG_process_get_properties() and MSG_process_get_property_value().
264    Also make sure to read the platform and deployment XML files to see
265    how to declare these data.
266
267  * parallel_task/parallel_task.c: Demonstrates the use of
268    MSG_parallel_task_create(), to create special tasks that run on
269    several hosts at the same time. The resulting simulations are very
270    close to what can be achieved in SimDag, but still allows to use
271    the other features of MSG (it'd be cool to be able to mix
272    interfaces, but it's not possible ATM).
273
274  * priority/priority.c: Demonstrates the use of
275    MSG_task_set_priority() to change the computation priority of a
276    given task.
277
278 Trace driven simulations
279 ========================
280
281 The actions/actions.c example demonstrates how to run trace-driven
282 simulations. It is very handy when you want to test an algorithm or
283 protocol that does nothing unless it receives some events from
284 outside. For example, a P2P protocol reacts to requests from the user,
285 but does nothing if there is no such event.
286
287 In such situations, SimGrid allows to write your protocol in your C
288 file, and the events to react to in a separate text file. Declare a
289 function handling each of the events that you want to accept in your
290 trace files, register them using MSG_action_register in your main, and
291 then use MSG_action_trace_run to launch the simulation. You can either
292 have one trace file containing all your events, or a file per
293 simulated process. Check the tesh files in the example directory for
294 details on how to do it.
295
296 This example uses this approach to replay MPI-like traces. It comes
297 with a set of event handlers reproducing MPI events. This is somehow
298 similar to SMPI, yet differently implemented. This code should
299 probably be changed to use SMPI internals instead, but wasn't, so far.
300
301 Examples of full applications
302 =============================
303
304  * chord/chord.c: Classical Chord P2P protocol This example implements
305    the well known Chord P2P protocol. Its main advantage is that it
306    constitute a fully working non-trivial example. In addition, its
307    implementation is rather efficient, as demonstrated in
308    [57]http://hal.inria.fr/inria-00602216/
309
310