Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Initial commit for split doc (in order to let Pierre play with it). Please do not...
[simgrid.git] / doc / shared / doxygen / msg-examples.doc
1 /**
2 @defgroup MSG_examples MSG Examples
3 @ingroup MSG_User_Guide
4
5
6 MSG comes with an extensive set of examples. It is sometimes difficult
7 to find the one you need. This list aims at helping you finding the
8 example from which you can learn what you want to.
9
10 @section MSG_ex_basics Basic examples and features
11
12 */
13
14 /**
15 @defgroup MSG_ex_asynchronous_communications Asynchronous communications
16 @ingroup MSG_examples
17
18 Simulation of asynchronous communications between a sender and a receiver using a realistic platform and
19 an external description of the deployment.
20
21 \section MSG_ex_ms_TOC Table of contents:
22  - \ref MSG_ext_icomms_code
23    - \ref MSG_ext_icomms_preliminary
24    - \ref MSG_ext_icomms_Sender
25    - \ref MSG_ext_icomms_Receiver
26    - \ref MSG_ext_icomms_core
27    - \ref MSG_ext_icomms_Main
28  - \ref MSG_ext_icomms_fct_Waitall
29  - \ref MSG_ext_icomms_fct_Waitany
30
31 <hr>
32
33 \dontinclude msg/icomms/peer.c
34
35 \section MSG_ext_icomms_code Code of the application
36
37 \subsection MSG_ext_icomms_preliminary Preliminary declarations
38 \skip include
39 \until Sender function
40
41 \subsection MSG_ext_icomms_Sender Sender function
42
43 The sender send to a receiver an asynchronous message with the function "MSG_task_isend()". Cause this function is non-blocking
44 we have to make "MSG_comm_test()" to know   if the communication is finished for finally destroy it with function "MSG_comm_destroy()".
45 It also available to "make MSG_comm_wait()" which make both of them.
46
47   C style arguments (argc/argv) are interpreted as:
48    - the number of tasks to distribute
49    - the computation size of each task
50    - the size of the files associated to each task
51    - a list of host that will accept those tasks.
52    - the time to sleep at the beginning of the function
53    - This time defined the process sleep time
54                         if time = 0 use of MSG_comm_wait()
55                         if time > 0 use of MSG_comm_test()
56
57
58 \until Receiver function
59
60 \subsection MSG_ext_icomms_Receiver Receiver function
61
62 This function executes tasks when it receives them. As the receiving is asynchronous we have to test the communication to know
63 if it is completed or not with "MSG_comm_test()" or wait for the completion "MSG_comm_wait()".
64
65   C style arguments (argc/argv) are interpreted as:
66    - the id to use for received the communication.
67    - the time to sleep at the beginning of the function
68    - This time defined the process sleep time
69                         if time = 0 use of MSG_comm_wait()
70                         if time > 0 use of MSG_comm_test()
71
72 \until Test function
73
74 \subsection MSG_ext_icomms_core Simulation core
75
76   This function is the core of the simulation and is divided only into 3 parts
77   thanks to MSG_create_environment() and MSG_launch_application().
78      -# Simulation settings : MSG_create_environment() creates a realistic
79         environment
80      -# Application deployment : create the processes on the right locations with
81         MSG_launch_application()
82      -# The simulation is run with #MSG_main()
83
84   Its arguments are:
85         - <i>platform_file</i>: the name of a file containing an valid surfxml platform description.
86         - <i>application_file</i>: the name of a file containing a valid surfxml application description
87
88 \until Main function
89
90 \subsection MSG_ext_icomms_Main Main function
91
92 This initializes MSG, runs a simulation, and free all data-structures created by MSG.
93
94 \until end_of_main
95
96 \dontinclude msg/icomms/peer2.c
97
98 \section MSG_ext_icomms_fct_Waitall Waitall function for sender
99
100 The use of this function permit to send all messages and wait for the completion of all in one time.
101
102 \skipline Sender function
103 \until end_of_sender
104
105 \section MSG_ext_icomms_fct_Waitany Waitany function
106
107 The MSG_comm_waitany() function return the place of the first message send or receive from a xbt_dynar_t table.
108
109 \subsection MSG_ext_icomms_fct_Waitany_sender From a sender
110 We can use this function to wait all sent messages.
111 \dontinclude msg/icomms/peer3.c
112 \skipline Sender function
113 \until end_of_sender
114
115 \subsection MSG_ext_icomms_fct_Waitany_receiver From a receiver
116 We can also wait for the arrival of all messages.
117 \dontinclude msg/icomms/peer3.c
118 \skipline Receiver function
119 \until end_of_receiver
120
121 */
122
123
124 /**
125 @defgroup MSG_ex_master_slave Basic Master/Slaves
126 @ingroup MSG_examples
127
128 Simulation of a master-slave application using a realistic platform
129 and an external description of the deployment.
130
131 \section MSG_ex_ms_TOC Table of contents:
132
133  - \ref MSG_ext_ms_code
134    - \ref MSG_ext_ms_preliminary
135    - \ref MSG_ext_ms_master
136    - \ref MSG_ext_ms_slave
137    - \ref MSG_ext_ms_forwarder
138    - \ref MSG_ext_ms_core
139    - \ref MSG_ext_ms_main
140  - \ref MSG_ext_ms_helping
141    - \ref MSG_ext_ms_application
142    - \ref MSG_ext_ms_platform
143
144 <hr>
145
146 \dontinclude msg/masterslave/masterslave_forwarder.c
147
148 \section MSG_ext_ms_code Code of the application
149
150 \subsection MSG_ext_ms_preliminary Preliminary declarations
151
152 \skip include
153 \until printf
154 \until }
155
156 \subsection MSG_ext_ms_master Master code
157
158 This function has to be assigned to a m_process_t that will behave as
159 the master. It should not be called directly but either given as a
160 parameter to #MSG_process_create() or registered as a public function
161 through #MSG_function_register() and then automatically assigned to a
162 process through #MSG_launch_application().
163
164 C style arguments (argc/argv) are interpreted as:
165    - the number of tasks to distribute
166    - the computation size of each task
167    - the size of the files associated to each task
168    - a list of host that will accept those tasks.
169
170 Tasks are dumbly sent in a round-robin style.
171
172 \until end_of_master
173
174 \subsection MSG_ext_ms_slave Slave code
175
176 This function has to be assigned to a #m_process_t that has to behave
177 as a slave. Just like the master fuction (described in \ref
178 MSG_ext_ms_master), it should not be called directly.
179
180 This function keeps waiting for tasks and executes them as it receives them.
181
182 \until end_of_slave
183
184 \subsection MSG_ext_ms_forwarder Forwarder code
185
186 This function has to be assigned to a #m_process_t that has to behave
187 as a forwarder. Just like the master function (described in \ref
188 MSG_ext_ms_master), it should not be called directly.
189
190 C style arguments (argc/argv) are interpreted as a list of host that
191 will accept those tasks.
192
193 This function keeps waiting for tasks and dispathes them to its slaves.
194
195 \until end_of_forwarder
196
197 \subsection MSG_ext_ms_core Simulation core
198
199 This function is the core of the simulation and is divided only into 3 parts
200 thanks to MSG_create_environment() and MSG_launch_application().
201    -# Simulation settings : MSG_create_environment() creates a realistic
202       environment
203    -# Application deployment : create the processes on the right locations with
204       MSG_launch_application()
205    -# The simulation is run with #MSG_main()
206
207 Its arguments are:
208         - <i>platform_file</i>: the name of a file containing an valid surfxml platform description.
209         - <i>application_file</i>: the name of a file containing a valid surfxml application description
210
211 \until end_of_test_all
212
213 \subsection MSG_ext_ms_main Main() function
214
215 This initializes MSG, runs a simulation, and free all data-structures created by MSG.
216
217 \until end_of_main
218
219 \section MSG_ext_ms_helping Helping files
220
221 \subsection MSG_ext_ms_application Example of application file
222
223 \include msg/masterslave/deployment_masterslave.xml
224
225 \subsection MSG_ext_ms_platform Example of platform file
226
227 \include msg/small_platform.xml
228
229 */
230
231 /** \page MSG_ex_master_slave_lua Master/slave Lua application
232
233     Simulation of a master-slave application using lua bindings
234        - \ref MSG_ext_ms_code_lua
235        - \ref MSG_ext_ms_master_lua
236        - \ref MSG_ext_ms_slave_lua
237        - \ref MSG_ext_ms_core_lua
238
239      - \ref MSG_ext_ms_helping
240        - \ref MSG_ext_ms_application
241        - \ref MSG_ext_ms_platform
242
243
244       \dontinclude lua/masterslave/master_slave.lua
245
246       \section MSG_ext_ms_code_lua Code of the application
247
248       \subsection MSG_ext_ms_master_lua Master code
249
250             as described ine the C native master/Slave exmaple , this function has to be assigned to a m_process_t that will behave as the master.
251
252       Lua style arguments (...) in for the master are interpreted as:
253        - the number of tasks to distribute
254        - the computation size of each task
255        - the size of the files associated to each task
256        - a list of host that will accept those tasks.
257
258       Tasks are dumbly sent in a round-robin style.
259
260       \until end_of_master
261
262
263       \subsection MSG_ext_ms_slave_lua Slave code
264
265       This function has to be assigned to a #m_process_t that has to behave as a slave.
266       This function keeps waiting for tasks and executes them as it receives them.
267
268       \until end_of_slave
269          \subsection MSG_ext_ms_core_lua Simulation core
270
271       in this section the core of the simulation which start by including the simgrid lib for bindings
272       : <i>require "simgrid" </i>
273
274          -# Simulation settings : <i>simgrid.platform</i> creates a realistic
275             environment
276          -# Application deployment : create the processes on the right locations with
277             <i>simgrid.application</i>
278          -# The simulation is run with <i>simgrid.run</i>
279
280       Its arguments are:
281         - <i>platform_file</i>: the name of a file containing an valid surfxml platform description.( first command line argument)
282         - <i>application_file</i>: the name of a file containing a valid surfxml application description ( second commande line argument )
283
284       \until simgrid.clean()
285
286 */
287
288 /** \page MSG_ex_master_slave_lua_bypass Master/slave Bypass Lua application
289
290     Simulation of a master-slave application using lua bindings, Bypassing the XML parser
291        - \ref MSG_ext_ms_code_lua
292        - \ref MSG_ext_ms_master_lua
293        - \ref MSG_ext_ms_slave_lua
294        - \ref MSG_ext_ms_core_lua
295
296
297       \dontinclude lua/console/master_slave_bypass.lua
298
299       \section MSG_ext_ms_code_lua Code of the application
300
301       \subsection MSG_ext_ms_master_lua Master code
302
303             as described ine the C native master/Slave exmaple , this function has to be assigned to a m_process_t that will behave as the master.
304
305       Lua style arguments (...) in for the master are interpreted as:
306        - the number of tasks to distribute
307        - the computation size of each task
308        - the size of the files associated to each task
309        - a list of host that will accept those tasks.
310
311       Tasks are dumbly sent in a round-robin style.
312
313       \until end_of_master
314
315
316       \subsection MSG_ext_ms_slave_lua Slave code
317
318       This function has to be assigned to a #m_process_t that has to behave as a slave.
319       This function keeps waiting for tasks and executes them as it receives them.
320
321       \until end_of_slave
322          \subsection MSG_ext_ms_core_lua Simulation core
323
324       in this section the core of the simulation which start by including the simgrid lib for bindings, then create the resources we need to set up our environment bypassing the XML parser.
325       : <i>require "simgrid" </i>
326
327          -# Hosts : <i>simgrid.Host.new</i> instanciate a new host with an id, and power.
328          -# Links : <i>simgrid.Link.new</i> instanictae a new link that will require an id, bandwith and latency values.
329          -# Route : <i>simgrid.Route.new</i> define a route between two hosts specifying the links to use.
330          -# Simulation settings : <i>simgrid.register_platform();</i> register own platform without using the XML SURF parser.
331
332          we can also bypass the XML deployment file, and associate functions for each of defined hosts.
333         - <i>simgrid.Host.setFunction</i>: associate a function to a host, specifying arguments if needed.
334         - <i>simgrid.register_application()</i>: saving the deployment settings before running the simualtion.
335
336       \until simgrid.clean()
337
338 */
339