Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[Energy] Fix broken commit c6fc463d75e4daa67ddf9c460cbc473b1aa9d6ba
[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_basics
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_apps
19   - @ref msg_ex_misc
20                     
21 @section msg_ex_basics 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-waitany/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  - <b>Yielding to other processes</b>.
69    @ref examples/msg/async-yield/async-yield.c\n
70    The @ref MSG_process_yield function interrupts the execution of the
71    current process, leaving a chance to run to the other processes
72    that are ready to run at the exact same timestamp
73
74 @section msg_ex_process Acting on Processes
75
76   - <b>Creating processes</b>. 
77     @ref examples/msg/process-create/process-create.c \n
78     Most processes are started from the deployment XML file, but they
79     can also be used with the @ref MSG_process_create() function.
80
81   - <b>Suspend and Resume processes</b>.
82     @ref examples/msg/process-suspend/process-suspend.c \n
83     Processes can be suspended and resumed during their executions
84     thanks to the @ref MSG_process_suspend and @ref MSG_process_resume functions.
85
86   - <b>Kill processes</b>.
87     @ref examples/msg/process-kill/process-kill.c \n
88     Processes can forcefully stop other processes with the @ref MSG_process_kill function.
89      
90   - <b>Migrating processes</b>.
91     @ref examples/msg/process-migration/process-migration.c \n
92     Processes can move or be moved from a host to another with the @ref MSG_process_migrate function.
93     
94   - <b>Controling the process life cycle from the XML</b>.
95     @ref examples/msg/process-startkilltime/process-startkilltime.c \n
96     You can specify a start time and a kill time in the deployment
97     file. See all *_d.xml files in this directory.
98
99 @section msg_ex_tracing Tracing and visualization features
100
101 Tracing can be activated by various configuration options which
102 are illustrated in these example. See also the 
103 @ref tracing_tracing_options "full list of options related to tracing".
104
105 It is interesting to run the process-create example with the following
106 options to see the task executions:
107
108   - <b>Platform tracing</b>.
109     @ref examples/msg/trace-platform/trace-platform.c \n
110     This program is a toy example just loading the platform, so that
111     you can play with the platform visualization. Recommanded options:
112     @verbatim --cfg=tracing:yes --cfg=tracing/categorized:yes
113     @endverbatim
114
115   - <b>Setting Categories</b>.
116     @ref examples/msg/trace-categories/trace-categories.c \n
117     This example declares several tracing categories
118     to that are used to classify its tasks. When the program is executed,
119     the tracing mechanism registers the resource utilization of hosts
120     and links according to these categories. Recommanded options:
121     @verbatim --cfg=tracing:yes --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes --cfg=viva/categorized:viva_cat.plist --cfg=viva/uncategorized:viva_uncat.plist
122     @endverbatim
123     
124   - <b>Master Workers tracing</b>.
125     @ref examples/msg/trace-masterworker/trace-masterworker.c \n
126     This is an augmented version of our basic master/worker example
127     using several tracing features. It traces resource usage, sorted
128     out in several categories; Trace marks and user variables are also
129     used. Recommanded options:
130     @verbatim --cfg=tracing/categorized:yes --cfg=tracing/uncategorized:yes --cfg=viva/categorized:viva_cat.plist --cfg=viva/uncategorized:viva_uncat.plist
131     @endverbatim
132     
133   - <b>Process migration tracing</b>.
134     @ref examples/msg/trace-process-migration/trace-process-migration.c \n
135     This version is enhanced so that the process migrations can be
136     displayed as arrows in a Gantt-chart visualization. Recommanded
137     options to that extend:
138     @verbatim -cfg=tracing:yes --cfg=tracing/msg/process:yes
139     @endverbatim     
140
141 TODO: These tracing examples should be integrated in the examples to
142 not duplicate the C files. A full command line to see the result in
143 the right tool (viva/vite/FrameSoc) should be given along with some
144 screenshots.
145
146 @subsection msg_ex_tracing_user_variables Tracing user variables
147
148 You can also attach your own variables to a any resource described in
149 the platform file. The following examples illustrate this feature.
150 They have to be run with the following options:
151 @verbatim --cfg=tracing:yes --cfg=tracing/platform:yes
152 @endverbatim
153
154   - <b>Attaching variables to Hosts</b>.
155     @ref examples/msg/trace-host-user-variables/trace-host-user-variables.c 
156
157   - <b>Attaching variables to Links</b>.
158     @ref examples/msg/trace-link-user-variables/trace-link-user-variables.c \n
159     The tricky part is that you have to know the name of the link you
160     want to enhance with a variable.
161
162   - <b>Attaching variables to network Routes</b>
163     @ref examples/msg/trace-route-user-variables/trace-route-user-variables.c \n
164     It is often easier to update a given variable for all links of a
165     given network path (identified by its source and destination
166     hosts) instead of knowing the name of each specific link.
167
168 @section msg_ex_models Models-related examples
169
170 @subsection msg_ex_ns3 NS3 as a SimGrid Network Model
171
172 This example demonstrates how to use the bindings to the Network
173 Simulator, as explained in @ref pls_ns3. The most
174 interesting is probably not the C files since they are unchanged from
175 the other simulations, but the associated files, such as the platform
176 file to see how to declare a platform to be used with the ns-3 bindings
177 of SimGrid and the tesh file to see how to actually start a simulation
178 in these settings.
179   
180   - @ref examples/msg/network-ns3/network-ns3.c. Simple ping-pong using
181     ns-3 instead of the SimGrid network models.
182
183 TODO: merge the C files
184
185 TODO: show the XML files instead if it's what is interesting. On a "XML example files" page that does not exist yet.
186
187 @subsection msg_ex_io Simulating disks and files
188
189 The examples of this section demonstrate how to interact with the
190 simulated storages.
191
192   - <b>Basic example</b>.
193     @ref examples/msg/io-storage/io-storage.c \n
194     All main storage and file functions are demoed.
195     
196   - <b>File Management</b>. @ref examples/msg/io-file/io-file.c \n
197     This example illustrates the use of operations on file
198     (@ref MSG_file_open, @ref MSG_file_read, @ref MSG_file_write,
199     or @ref MSG_file_close).
200     
201   - <b>Remote I/O</b>. @ref examples/msg/io-remote/io-remote.c \n
202     I/O operations can also be done in a remote, i.e. when the
203     accessed disk is not mounted on the caller's host.
204
205 @section msg_ex_actions Following Workload Traces
206
207 This section details how to run trace-driven simulations. It is very
208 handy when you want to test an algorithm or protocol that only react
209 to external events. For example, many P2P protocols react to user
210 requests, but do nothing if there is no such event.
211
212 In such situations, you should write your protocol in C, and separate
213 the workload that you want to play onto your protocol in a separate
214 text file. Declare a function handling each type of the events in your
215 trace, register them using @ref xbt_replay_action_register in your
216 main, and then use @ref MSG_action_trace_run to launch the simulation.
217
218 Then, you can either have one trace file containing all your events,
219 or a file per simulated process: the former may be easier to work
220 with, but the second is more efficient on very large traces. Check
221 also the tesh files in the example directories for details.
222
223   - <b>Communication replay</b>.
224     @ref examples/msg/actions-comm/actions-comm.c \n
225     Presents a set of event handlers reproducing classical communication
226     primitives (synchronous and asynchronous send/receive, broadcast,
227     barrier, etc).
228
229   - <b>I/O replay</b>.
230     @ref examples/msg/actions-storage/actions-storage.c \n
231     Presents a set of event handlers reproducing classical I/O
232     primitives (open, read, write, close, etc).
233
234 @section msg_ex_apps Examples of Full Applications
235  
236   - <b>Parallel Matrix Multiplication</b>.
237     @ref examples/msg/app-pmm/app-pmm.c \n
238     This little application multiplies two matrices in parallel. Each
239     of the 9 processes computes a sub-block of the result, with the
240     sub-blocks of the input matrices exchanged between the processes. \n
241     This is a classical assignment in MPI lectures, here implemented
242     in MSG.
243
244   - <b>Chord P2P protocol</b>.
245     @ref examples/msg/dht-chord/dht-chord.c \n
246     This example implements the well known Chord protocol,
247     constituting a fully working non-trivial example. This 
248     implementation is also very efficient, as demonstrated in 
249     http://hal.inria.fr/inria-00602216/
250
251 @section msg_ex_misc Miscellaneous
252
253  - <b>Task priorities</b>.
254    @ref examples/msg/task-priority/task-priority.c \n
255    Demonstrates the use of @ref MSG_task_set_priority to change the
256    computation priority of  a given task.
257
258  - <b>User-defined properties</b>.
259    @ref examples/msg/platform-properties/platform-properties.c \n
260    Attaching arbitrary information to host, processes and
261    such, and retrieving them with @ref MSG_host_get_properties,
262    @ref MSG_host_get_property_value, @ref MSG_process_get_properties, and 
263    @ref MSG_process_get_property_value. Also make sure to read the
264    platform and deployment XML files to see how to declare these data.
265  
266 TODO: Document the many other examples that we have 
267 */
268
269 As a human, you can stop reading at this point. The rest is garbage:
270
271 Every example must be listed in the following, but it's not possible
272 to move this content upper as each @example directive seems to eat
273 everything until the next */ marker (and the content is placed at the
274 top of the example file). 
275
276
277 /**
278 @example examples/msg/app-pingpong/app-pingpong.c        
279 @example examples/msg/app-token-ring/app-token-ring.c    
280 @example examples/msg/app-masterworker/app-masterworker.c
281
282 @example examples/msg/async-wait/async-wait.c
283 @example examples/msg/async-waitall/async-waitall.c
284 @example examples/msg/async-waitany/async-waitany.c
285 @example examples/msg/async-yield/async-yield.c
286
287 @example examples/msg/process-create/process-create.c
288 @example examples/msg/process-suspend/process-suspend.c
289 @example examples/msg/process-kill/process-kill.c
290 @example examples/msg/process-migration/process-migration.c
291 @example examples/msg/process-startkilltime/process-startkilltime.c
292
293 @example examples/msg/trace-platform/trace-platform.c
294 @example examples/msg/trace-categories/trace-categories.c
295 @example examples/msg/trace-masterworker/trace-masterworker.c
296 @example examples/msg/trace-process-migration/trace-process-migration.c
297 @example examples/msg/trace-host-user-variables/trace-host-user-variables.c
298 @example examples/msg/trace-link-user-variables/trace-link-user-variables.c
299 @example examples/msg/trace-route-user-variables/trace-route-user-variables.c
300
301 @example examples/msg/network-ns3/network-ns3.c
302
303 @example examples/msg/io-storage/io-storage.c
304 @example examples/msg/io-file/io-file.c
305 @example examples/msg/io-remote/io-remote.c
306
307 @example examples/msg/actions-comm/actions-comm.c
308 @example examples/msg/actions-storage/actions-storage.c
309
310 @example examples/msg/app-pmm/app-pmm.c
311 @example examples/msg/dht-chord/dht-chord.c
312
313 @example examples/msg/task-priority/task-priority.c
314 @example examples/msg/platform-properties/platform-properties.c
315                          
316 */
317