1 /** \addtogroup MSG_API
3 MSG was the first distributed programming environment provided within
4 SimGrid. While almost realistic, it remains quite simple (simplistic?).
5 This describes the native to MSG.
7 \section jMSG_who Who should use this (and who shouldn't)
9 You should use MSG if you want to study some heuristics for a
10 given problem you don't really want to implement. If you want to
11 use the C programming language, your are in the right
12 section. To use the Java or Ruby programming interfaces, please refer to
13 the documentation provided in the relevant packages.
15 \section MSG_funct Offered functionnalities
16 - \ref m_process_management
17 - \ref m_datatypes_management
18 - \ref m_host_management
19 - \ref m_task_management
20 - \ref msg_gos_functions
21 - \ref msg_easier_life
24 \section MSG_examples Examples of MSG
26 - \ref MSG_ex_master_slave
27 - \ref MSG_ex_asynchronous_communications
28 - \ref MSG_ex_master_slave_scrip_lua
32 /** @defgroup m_datatypes_management MSG Data Types
34 @brief This section describes the different datatypes provided by MSG.
36 \htmlonly <!-- DOXYGEN_NAVBAR_LABEL="Data types" --> \endhtmlonly
39 /** @defgroup m_process_management Management Functions of Agents
41 * @brief This section describes the agent structure of MSG
42 * (#m_process_t) and the functions for managing it.
45 /** @defgroup m_host_management Management functions of Hosts
47 * @brief This section describes the host structure of MSG
50 /** @defgroup m_task_management Managing functions of Tasks
52 * @brief This section describes the task structure of MSG
53 * (#m_task_t) and the functions for managing it.
56 /** @defgroup msg_gos_functions MSG Operating System Functions
58 * @brief This section describes the functions that can be used
59 * by an agent for handling some task.
62 /** @defgroup msg_easier_life Platform and Application management
64 * @brief This section describes functions to manage the platform creation
65 * and the application deployment. Please check @ref
66 * MSG_examples for an overview of their usage.
70 @defgroup msg_simulation MSG simulation Functions
72 @brief This section describes the functions you need to know to
73 set up a simulation. You should have a look at \ref MSG_examples
74 to have an overview of their usage.
76 @htmlonly <!-- DOXYGEN_NAVBAR_LABEL="Simulation functions" --> @endhtmlonly
80 @defgroup MSG_LUA Lua bindings
82 @brief Lua bindings to MSG (\ref MSG_API)
84 @htmlonly <!-- DOXYGEN_NAVBAR_LABEL="LUA bindings" --> @endhtmlonly
86 This is the lua bindings of the \ref MSG_API interface.
88 \section lMSG_who Who should use this (and who shouldn't)
90 If you want to use MSG to study your algorithm, but you don't
91 want to use the C language (using \ref MSG_API), then you should
92 use some bindings such as this one. The advantage of the lua
93 bindings is that they are distributed directly with the main
94 archive (in contrary to Java and Ruby bindings, for example,
95 that are distributed separately). Another advantage of lua is
96 that there is almost no performance loss with regard to the C
97 version (at least there shouln't be any -- it is still to be
100 \section MSG_Lua_funct Lua offered functionnalities in MSG
101 Almost all important features of the MSG interface are available
102 from the lua bindings. Unfortunately, since doxygen does not support
103 the lua modules implemented directly in C as we are using, there is
104 no ready to use reference documentation for this module. Even more
105 than for the other modules, you will have to dig into the source
106 code of the examples to learn how to use it.
108 \section Lua_examples Examples of lua MSG
110 - \ref MSG_ex_master_slave_lua
111 - \ref MSG_ex_master_slave_lua_bypass
112 - Also, the Chord example (in the source tree) is a working
113 non-trivial example of use of the lua bindings
117 /** \page MSG_ex_asynchronous_communications Asynchronous communication applications
119 Simulation of asynchronous communications between a sender and a receiver using a realistic platform and
120 an external description of the deployment.
122 \section MSG_ex_ms_TOC Table of contents:
123 - \ref MSG_ext_icomms_code
124 - \ref MSG_ext_icomms_preliminary
125 - \ref MSG_ext_icomms_Sender
126 - \ref MSG_ext_icomms_Receiver
127 - \ref MSG_ext_icomms_core
128 - \ref MSG_ext_icomms_Main
129 - \ref MSG_ext_icomms_fct_Waitall
130 - \ref MSG_ext_icomms_fct_Waitany
134 \dontinclude msg/icomms/peer.c
136 \section MSG_ext_icomms_code Code of the application
138 \subsection MSG_ext_icomms_preliminary Preliminary declarations
140 \until Sender function
142 \subsection MSG_ext_icomms_Sender Sender function
144 The sender send to a receiver an asynchronous message with the function "MSG_task_isend()". Cause this function is non-blocking
145 we have to make "MSG_comm_test()" to know if the communication is finished for finally destroy it with function "MSG_comm_destroy()".
146 It also available to "make MSG_comm_wait()" which make both of them.
148 C style arguments (argc/argv) are interpreted as:
149 - the number of tasks to distribute
150 - the computation size of each task
151 - the size of the files associated to each task
152 - a list of host that will accept those tasks.
153 - the time to sleep at the beginning of the function
154 - This time defined the process sleep time
155 if time = 0 use of MSG_comm_wait()
156 if time > 0 use of MSG_comm_test()
159 \until Receiver function
161 \subsection MSG_ext_icomms_Receiver Receiver function
163 This function executes tasks when it receives them. As the receiving is asynchronous we have to test the communication to know
164 if it is completed or not with "MSG_comm_test()" or wait for the completion "MSG_comm_wait()".
166 C style arguments (argc/argv) are interpreted as:
167 - the id to use for received the communication.
168 - the time to sleep at the beginning of the function
169 - This time defined the process sleep time
170 if time = 0 use of MSG_comm_wait()
171 if time > 0 use of MSG_comm_test()
175 \subsection MSG_ext_icomms_core Simulation core
177 This function is the core of the simulation and is divided only into 3 parts
178 thanks to MSG_create_environment() and MSG_launch_application().
179 -# Simulation settings : MSG_create_environment() creates a realistic
181 -# Application deployment : create the agents on the right locations with
182 MSG_launch_application()
183 -# The simulation is run with #MSG_main()
186 - <i>platform_file</i>: the name of a file containing an valid surfxml platform description.
187 - <i>application_file</i>: the name of a file containing a valid surfxml application description
191 \subsection MSG_ext_icomms_Main Main function
193 This initializes MSG, runs a simulation, and free all data-structures created by MSG.
197 \dontinclude msg/icomms/peer2.c
199 \section MSG_ext_icomms_fct_Waitall Waitall function for sender
201 The use of this function permit to send all messages and wait for the completion of all in one time.
203 \skipline Sender function
206 \section MSG_ext_icomms_fct_Waitany Waitany function
208 The MSG_comm_waitany() function return the place of the first message send or receive from a xbt_dynar_t table.
210 \subsection MSG_ext_icomms_fct_Waitany_sender From a sender
211 We can use this function to wait all sended messages.
212 \dontinclude msg/icomms/peer3.c
213 \skipline Sender function
216 \subsection MSG_ext_icomms_fct_Waitany_receiver From a receiver
217 We can also wait for the receiving of all messages.
218 \dontinclude msg/icomms/peer3.c
219 \skipline Receiver function
220 \until end_of_receiver
224 /** \page MSG_ex_master_slave_scrip_lua Master/slave application using lua console
226 Simulation of a master-slave application using a realistic platform and
227 an external description of the deployment via a lua script.
229 \section MSG_ex_msl_TOC Table of contents:
231 - \ref MSG_ext_msl_code
232 - \ref MSG_ext_msl_preliminary
233 - \ref MSG_ext_msl_master
234 - \ref MSG_ext_msl_slave
235 - \ref MSG_ext_msl_core
236 - \ref MSG_ext_msl_main
237 - \ref MSG_ext_msl_helping
238 - \ref MSG_ext_msl_platform
242 \dontinclude msg/masterslave/masterslave_console.c
244 \section MSG_ext_msl_code Code of the application
246 \subsection MSG_ext_msl_preliminary Preliminary declarations
251 \subsection MSG_ext_msl_master Master code
253 This function has to be assigned to a m_process_t that will behave as the master.
254 It should not be called directly but either given as a parameter to
255 #MSG_process_create() or registered as a public function through
256 #MSG_function_register() and then automatically assigned to a process through
257 #MSG_load_platform_script().
259 C style arguments (argc/argv) are interpreted as:
260 - the number of tasks to distribute
261 - the computation size of each task
262 - the size of the files associated to each task
263 - number of hosts that will accept those tasks.
265 Tasks are dumbly sent in a round-robin style.
268 \subsection MSG_ext_msl_slave Slave code
270 This function has to be assigned to a #m_process_t that has to behave as a slave.
271 Just like the master fuction (described in \ref MSG_ext_ms_master), it should not be called directly.
273 This function keeps waiting for tasks and executes them as it receives them.
277 \subsection MSG_ext_msl_core Simulation core
279 This function is the core of the simulation and is divided now only into 2 parts
280 thanks to MSG_load_platform_script().
281 -# Simulation settings and application deployment : MSG_load_platform_script() loads and creates a realistic
282 environment and the agents on the right locations, described in the lua script file (see example below).
283 Note that the use of this function require a lua installation on your machine.
284 -# The simulation is run with #MSG_main().
287 - <i>platform_script_file</i>: the name of the script file containing a valid platform and application description, using bound lua methods to bypass the surfxml parser.
289 \until end_of_test_all
291 \subsection MSG_ext_msl_main Main() function
293 This initializes MSG, runs a simulation, and free all data-structures created by MSG.
297 \section MSG_ext_msl_helping Helping files
299 \subsection MSG_ext_msl_platform Example of platform script file
301 \include msg/masterslave/platform_script.lua
306 /** \page MSG_ex_master_slave Master/slave application
308 Simulation of a master-slave application using a realistic platform and
309 an external description of the deployment.
311 \section MSG_ex_ms_TOC Table of contents:
313 - \ref MSG_ext_ms_code
314 - \ref MSG_ext_ms_preliminary
315 - \ref MSG_ext_ms_master
316 - \ref MSG_ext_ms_slave
317 - \ref MSG_ext_ms_forwarder
318 - \ref MSG_ext_ms_core
319 - \ref MSG_ext_ms_main
320 - \ref MSG_ext_ms_helping
321 - \ref MSG_ext_ms_application
322 - \ref MSG_ext_ms_platform
326 \dontinclude msg/masterslave/masterslave_forwarder.c
328 \section MSG_ext_ms_code Code of the application
330 \subsection MSG_ext_ms_preliminary Preliminary declarations
336 \subsection MSG_ext_ms_master Master code
338 This function has to be assigned to a m_process_t that will behave as the master.
339 It should not be called directly but either given as a parameter to
340 #MSG_process_create() or registered as a public function through
341 #MSG_function_register() and then automatically assigned to a process through
342 #MSG_launch_application().
344 C style arguments (argc/argv) are interpreted as:
345 - the number of tasks to distribute
346 - the computation size of each task
347 - the size of the files associated to each task
348 - a list of host that will accept those tasks.
350 Tasks are dumbly sent in a round-robin style.
354 \subsection MSG_ext_ms_slave Slave code
356 This function has to be assigned to a #m_process_t that has to behave as a slave.
357 Just like the master fuction (described in \ref MSG_ext_ms_master), it should not be called directly.
359 This function keeps waiting for tasks and executes them as it receives them.
363 \subsection MSG_ext_ms_forwarder Forwarder code
365 This function has to be assigned to a #m_process_t that has to behave as a forwarder.
366 Just like the master function (described in \ref MSG_ext_ms_master), it should not be called directly.
368 C style arguments (argc/argv) are interpreted as a list of host
369 that will accept those tasks.
371 This function keeps waiting for tasks and dispathes them to its slaves.
373 \until end_of_forwarder
375 \subsection MSG_ext_ms_core Simulation core
377 This function is the core of the simulation and is divided only into 3 parts
378 thanks to MSG_create_environment() and MSG_launch_application().
379 -# Simulation settings : MSG_create_environment() creates a realistic
381 -# Application deployment : create the agents on the right locations with
382 MSG_launch_application()
383 -# The simulation is run with #MSG_main()
386 - <i>platform_file</i>: the name of a file containing an valid surfxml platform description.
387 - <i>application_file</i>: the name of a file containing a valid surfxml application description
389 \until end_of_test_all
391 \subsection MSG_ext_ms_main Main() function
393 This initializes MSG, runs a simulation, and free all data-structures created by MSG.
397 \section MSG_ext_ms_helping Helping files
399 \subsection MSG_ext_ms_application Example of application file
401 \include msg/masterslave/deployment_masterslave.xml
403 \subsection MSG_ext_ms_platform Example of platform file
405 \include msg/small_platform.xml
409 /** \page MSG_ex_master_slave_lua Master/slave Lua application
411 Simulation of a master-slave application using lua bindings
412 - \ref MSG_ext_ms_code_lua
413 - \ref MSG_ext_ms_master_lua
414 - \ref MSG_ext_ms_slave_lua
415 - \ref MSG_ext_ms_core_lua
417 - \ref MSG_ext_ms_helping
418 - \ref MSG_ext_ms_application
419 - \ref MSG_ext_ms_platform
422 \dontinclude lua/masterslave/master_slave.lua
424 \section MSG_ext_ms_code_lua Code of the application
426 \subsection MSG_ext_ms_master_lua Master code
428 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.
430 Lua style arguments (...) in for the master are interpreted as:
431 - the number of tasks to distribute
432 - the computation size of each task
433 - the size of the files associated to each task
434 - a list of host that will accept those tasks.
436 Tasks are dumbly sent in a round-robin style.
441 \subsection MSG_ext_ms_slave_lua Slave code
443 This function has to be assigned to a #m_process_t that has to behave as a slave.
444 This function keeps waiting for tasks and executes them as it receives them.
447 \subsection MSG_ext_ms_core_lua Simulation core
449 in this section the core of the simulation which start by including the simgrid lib for bindings
450 : <i>require "simgrid" </i>
452 -# Simulation settings : <i>simgrid.platform</i> creates a realistic
454 -# Application deployment : create the agents on the right locations with
455 <i>simgrid.application</i>
456 -# The simulation is run with <i>simgrid.run</i>
459 - <i>platform_file</i>: the name of a file containing an valid surfxml platform description.( first command line argument)
460 - <i>application_file</i>: the name of a file containing a valid surfxml application description ( second commande line argument )
462 \until simgrid.clean()
466 /** \page MSG_ex_master_slave_lua_bypass Master/slave Bypass Lua application
468 Simulation of a master-slave application using lua bindings, Bypassing the XML parser
469 - \ref MSG_ext_ms_code_lua
470 - \ref MSG_ext_ms_master_lua
471 - \ref MSG_ext_ms_slave_lua
472 - \ref MSG_ext_ms_core_lua
475 \dontinclude lua/console/master_slave_bypass.lua
477 \section MSG_ext_ms_code_lua Code of the application
479 \subsection MSG_ext_ms_master_lua Master code
481 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.
483 Lua style arguments (...) in for the master are interpreted as:
484 - the number of tasks to distribute
485 - the computation size of each task
486 - the size of the files associated to each task
487 - a list of host that will accept those tasks.
489 Tasks are dumbly sent in a round-robin style.
494 \subsection MSG_ext_ms_slave_lua Slave code
496 This function has to be assigned to a #m_process_t that has to behave as a slave.
497 This function keeps waiting for tasks and executes them as it receives them.
500 \subsection MSG_ext_ms_core_lua Simulation core
502 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.
503 : <i>require "simgrid" </i>
505 -# Hosts : <i>simgrid.Host.new</i> instanciate a new host with an id, and power.
506 -# Links : <i>simgrid.Link.new</i> instanictae a new link that will require an id, bandwith and latency values.
507 -# Route : <i>simgrid.Route.new</i> define a route between two hosts specifying the links to use.
508 -# Simulation settings : <i>simgrid.register_platform();</i> register own platform without using the XML SURF parser.
510 we can also bypass the XML deployment file, and associate functions for each of defined hosts.
511 - <i>simgrid.Host.setFunction</i>: associate a function to a host, specifying arguments if needed.
512 - <i>simgrid.register_application()</i>: saving the deployment settings before running the simualtion.
514 \until simgrid.clean()