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 m_file_management
21 - \ref msg_actions_functions
22 - \ref msg_gos_functions
23 - \ref msg_deprecated_functions
24 - \ref msg_easier_life
27 Also make sure to visit the page @ref MSG_examples.
31 /** @defgroup m_datatypes_management MSG Data Types
33 @brief This section describes the different datatypes provided by MSG.
35 \htmlonly <!-- DOXYGEN_NAVBAR_LABEL="Data types" --> \endhtmlonly
38 /** @defgroup m_process_management Management Functions of Agents
40 * @brief This section describes the agent structure of MSG
41 * (#m_process_t) and the functions for managing it.
44 /** @defgroup m_host_management Management functions of Hosts
46 * @brief This section describes the host structure of MSG
49 /** @defgroup m_task_management Managing functions of Tasks
51 * @brief This section describes the task structure of MSG
52 * (#m_task_t) and the functions for managing it.
55 /** @defgroup m_file_management Managing functions of Files
57 * @brief This section describes the file structure of MSG
58 * (#m_file_t) and the functions for managing it. It
59 * is based on POSIX functions.
62 /** @defgroup msg_actions_functions Managing actions
64 * @brief This section describes functions for managing actions.
67 /** @defgroup msg_gos_functions MSG Operating System Functions
69 * @brief This section describes the functions that can be used
70 * by an agent for handling some task.
73 /** @defgroup msg_deprecated_functions MSG Deprecated
75 * @brief This section describes the deprecated functions and. They
76 * should be remove on next release.
79 /** @defgroup msg_easier_life Platform and Application management
81 * @brief This section describes functions to manage the platform creation
82 * and the application deployment. Please check @ref
83 * MSG_examples for an overview of their usage.
86 /** @defgroup msg_simulation MSG simulation Functions
88 * @brief This section describes the functions you need to know to
89 * set up a simulation. You should have a look at \ref MSG_examples
90 * to have an overview of their usage.
92 * @htmlonly <!-- DOXYGEN_NAVBAR_LABEL="Simulation functions" --> @endhtmlonly
96 @defgroup MSG_examples MSG Examples
99 MSG comes with an extensive set of examples. It is sometimes difficult
100 to find the one you need. This list aims at helping you finding the
101 example from which you can learn what you want to.
103 @section MSG_ex_basics Basic examples and features
108 @defgroup MSG_LUA Lua bindings
110 @brief Lua bindings to MSG (\ref MSG_API)
112 @htmlonly <!-- DOXYGEN_NAVBAR_LABEL="LUA bindings" --> @endhtmlonly
114 This is the lua bindings of the \ref MSG_API interface.
116 \section lMSG_who Who should use this (and who shouldn't)
118 If you want to use MSG to study your algorithm, but you don't
119 want to use the C language (using \ref MSG_API), then you should
120 use some bindings such as this one. The advantage of the lua
121 bindings is that they are distributed directly with the main
122 archive (in contrary to Java and Ruby bindings, for example,
123 that are distributed separately). Another advantage of lua is
124 that there is almost no performance loss with regard to the C
125 version (at least there shouln't be any -- it is still to be
128 \section MSG_Lua_funct Lua offered functionnalities in MSG
129 Almost all important features of the MSG interface are available
130 from the lua bindings. Unfortunately, since doxygen does not support
131 the lua modules implemented directly in C as we are using, there is
132 no ready to use reference documentation for this module. Even more
133 than for the other modules, you will have to dig into the source
134 code of the examples to learn how to use it.
136 \section Lua_examples Examples of lua MSG
138 - \ref MSG_ex_master_slave_lua
139 - \ref MSG_ex_master_slave_lua_bypass
140 - Also, the lua version of the Chord example (in the source tree)
141 is a working non-trivial example of use of the lua bindings
145 /** \defgroup MSG_ex_asynchronous_communications Asynchronous communications
146 \ingroup MSG_examples
148 Simulation of asynchronous communications between a sender and a receiver using a realistic platform and
149 an external description of the deployment.
151 \section MSG_ex_ms_TOC Table of contents:
152 - \ref MSG_ext_icomms_code
153 - \ref MSG_ext_icomms_preliminary
154 - \ref MSG_ext_icomms_Sender
155 - \ref MSG_ext_icomms_Receiver
156 - \ref MSG_ext_icomms_core
157 - \ref MSG_ext_icomms_Main
158 - \ref MSG_ext_icomms_fct_Waitall
159 - \ref MSG_ext_icomms_fct_Waitany
163 \dontinclude msg/icomms/peer.c
165 \section MSG_ext_icomms_code Code of the application
167 \subsection MSG_ext_icomms_preliminary Preliminary declarations
169 \until Sender function
171 \subsection MSG_ext_icomms_Sender Sender function
173 The sender send to a receiver an asynchronous message with the function "MSG_task_isend()". Cause this function is non-blocking
174 we have to make "MSG_comm_test()" to know if the communication is finished for finally destroy it with function "MSG_comm_destroy()".
175 It also available to "make MSG_comm_wait()" which make both of them.
177 C style arguments (argc/argv) are interpreted as:
178 - the number of tasks to distribute
179 - the computation size of each task
180 - the size of the files associated to each task
181 - a list of host that will accept those tasks.
182 - the time to sleep at the beginning of the function
183 - This time defined the process sleep time
184 if time = 0 use of MSG_comm_wait()
185 if time > 0 use of MSG_comm_test()
188 \until Receiver function
190 \subsection MSG_ext_icomms_Receiver Receiver function
192 This function executes tasks when it receives them. As the receiving is asynchronous we have to test the communication to know
193 if it is completed or not with "MSG_comm_test()" or wait for the completion "MSG_comm_wait()".
195 C style arguments (argc/argv) are interpreted as:
196 - the id to use for received the communication.
197 - the time to sleep at the beginning of the function
198 - This time defined the process sleep time
199 if time = 0 use of MSG_comm_wait()
200 if time > 0 use of MSG_comm_test()
204 \subsection MSG_ext_icomms_core Simulation core
206 This function is the core of the simulation and is divided only into 3 parts
207 thanks to MSG_create_environment() and MSG_launch_application().
208 -# Simulation settings : MSG_create_environment() creates a realistic
210 -# Application deployment : create the agents on the right locations with
211 MSG_launch_application()
212 -# The simulation is run with #MSG_main()
215 - <i>platform_file</i>: the name of a file containing an valid surfxml platform description.
216 - <i>application_file</i>: the name of a file containing a valid surfxml application description
220 \subsection MSG_ext_icomms_Main Main function
222 This initializes MSG, runs a simulation, and free all data-structures created by MSG.
226 \dontinclude msg/icomms/peer2.c
228 \section MSG_ext_icomms_fct_Waitall Waitall function for sender
230 The use of this function permit to send all messages and wait for the completion of all in one time.
232 \skipline Sender function
235 \section MSG_ext_icomms_fct_Waitany Waitany function
237 The MSG_comm_waitany() function return the place of the first message send or receive from a xbt_dynar_t table.
239 \subsection MSG_ext_icomms_fct_Waitany_sender From a sender
240 We can use this function to wait all sended messages.
241 \dontinclude msg/icomms/peer3.c
242 \skipline Sender function
245 \subsection MSG_ext_icomms_fct_Waitany_receiver From a receiver
246 We can also wait for the receiving of all messages.
247 \dontinclude msg/icomms/peer3.c
248 \skipline Receiver function
249 \until end_of_receiver
253 /** @defgroup MSG_ex_master_slave Basic Master/Slaves
254 @ingroup MSG_examples
256 Simulation of a master-slave application using a realistic platform and
257 an external description of the deployment.
259 \section MSG_ex_ms_TOC Table of contents:
261 - \ref MSG_ext_ms_code
262 - \ref MSG_ext_ms_preliminary
263 - \ref MSG_ext_ms_master
264 - \ref MSG_ext_ms_slave
265 - \ref MSG_ext_ms_forwarder
266 - \ref MSG_ext_ms_core
267 - \ref MSG_ext_ms_main
268 - \ref MSG_ext_ms_helping
269 - \ref MSG_ext_ms_application
270 - \ref MSG_ext_ms_platform
274 \dontinclude msg/masterslave/masterslave_forwarder.c
276 \section MSG_ext_ms_code Code of the application
278 \subsection MSG_ext_ms_preliminary Preliminary declarations
284 \subsection MSG_ext_ms_master Master code
286 This function has to be assigned to a m_process_t that will behave as the master.
287 It should not be called directly but either given as a parameter to
288 #MSG_process_create() or registered as a public function through
289 #MSG_function_register() and then automatically assigned to a process through
290 #MSG_launch_application().
292 C style arguments (argc/argv) are interpreted as:
293 - the number of tasks to distribute
294 - the computation size of each task
295 - the size of the files associated to each task
296 - a list of host that will accept those tasks.
298 Tasks are dumbly sent in a round-robin style.
302 \subsection MSG_ext_ms_slave Slave code
304 This function has to be assigned to a #m_process_t that has to behave as a slave.
305 Just like the master fuction (described in \ref MSG_ext_ms_master), it should not be called directly.
307 This function keeps waiting for tasks and executes them as it receives them.
311 \subsection MSG_ext_ms_forwarder Forwarder code
313 This function has to be assigned to a #m_process_t that has to behave as a forwarder.
314 Just like the master function (described in \ref MSG_ext_ms_master), it should not be called directly.
316 C style arguments (argc/argv) are interpreted as a list of host
317 that will accept those tasks.
319 This function keeps waiting for tasks and dispathes them to its slaves.
321 \until end_of_forwarder
323 \subsection MSG_ext_ms_core Simulation core
325 This function is the core of the simulation and is divided only into 3 parts
326 thanks to MSG_create_environment() and MSG_launch_application().
327 -# Simulation settings : MSG_create_environment() creates a realistic
329 -# Application deployment : create the agents on the right locations with
330 MSG_launch_application()
331 -# The simulation is run with #MSG_main()
334 - <i>platform_file</i>: the name of a file containing an valid surfxml platform description.
335 - <i>application_file</i>: the name of a file containing a valid surfxml application description
337 \until end_of_test_all
339 \subsection MSG_ext_ms_main Main() function
341 This initializes MSG, runs a simulation, and free all data-structures created by MSG.
345 \section MSG_ext_ms_helping Helping files
347 \subsection MSG_ext_ms_application Example of application file
349 \include msg/masterslave/deployment_masterslave.xml
351 \subsection MSG_ext_ms_platform Example of platform file
353 \include msg/small_platform.xml
357 /** \page MSG_ex_master_slave_lua Master/slave Lua application
359 Simulation of a master-slave application using lua bindings
360 - \ref MSG_ext_ms_code_lua
361 - \ref MSG_ext_ms_master_lua
362 - \ref MSG_ext_ms_slave_lua
363 - \ref MSG_ext_ms_core_lua
365 - \ref MSG_ext_ms_helping
366 - \ref MSG_ext_ms_application
367 - \ref MSG_ext_ms_platform
370 \dontinclude lua/masterslave/master_slave.lua
372 \section MSG_ext_ms_code_lua Code of the application
374 \subsection MSG_ext_ms_master_lua Master code
376 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.
378 Lua style arguments (...) in for the master are interpreted as:
379 - the number of tasks to distribute
380 - the computation size of each task
381 - the size of the files associated to each task
382 - a list of host that will accept those tasks.
384 Tasks are dumbly sent in a round-robin style.
389 \subsection MSG_ext_ms_slave_lua Slave code
391 This function has to be assigned to a #m_process_t that has to behave as a slave.
392 This function keeps waiting for tasks and executes them as it receives them.
395 \subsection MSG_ext_ms_core_lua Simulation core
397 in this section the core of the simulation which start by including the simgrid lib for bindings
398 : <i>require "simgrid" </i>
400 -# Simulation settings : <i>simgrid.platform</i> creates a realistic
402 -# Application deployment : create the agents on the right locations with
403 <i>simgrid.application</i>
404 -# The simulation is run with <i>simgrid.run</i>
407 - <i>platform_file</i>: the name of a file containing an valid surfxml platform description.( first command line argument)
408 - <i>application_file</i>: the name of a file containing a valid surfxml application description ( second commande line argument )
410 \until simgrid.clean()
414 /** \page MSG_ex_master_slave_lua_bypass Master/slave Bypass Lua application
416 Simulation of a master-slave application using lua bindings, Bypassing the XML parser
417 - \ref MSG_ext_ms_code_lua
418 - \ref MSG_ext_ms_master_lua
419 - \ref MSG_ext_ms_slave_lua
420 - \ref MSG_ext_ms_core_lua
423 \dontinclude lua/console/master_slave_bypass.lua
425 \section MSG_ext_ms_code_lua Code of the application
427 \subsection MSG_ext_ms_master_lua Master code
429 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.
431 Lua style arguments (...) in for the master are interpreted as:
432 - the number of tasks to distribute
433 - the computation size of each task
434 - the size of the files associated to each task
435 - a list of host that will accept those tasks.
437 Tasks are dumbly sent in a round-robin style.
442 \subsection MSG_ext_ms_slave_lua Slave code
444 This function has to be assigned to a #m_process_t that has to behave as a slave.
445 This function keeps waiting for tasks and executes them as it receives them.
448 \subsection MSG_ext_ms_core_lua Simulation core
450 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.
451 : <i>require "simgrid" </i>
453 -# Hosts : <i>simgrid.Host.new</i> instanciate a new host with an id, and power.
454 -# Links : <i>simgrid.Link.new</i> instanictae a new link that will require an id, bandwith and latency values.
455 -# Route : <i>simgrid.Route.new</i> define a route between two hosts specifying the links to use.
456 -# Simulation settings : <i>simgrid.register_platform();</i> register own platform without using the XML SURF parser.
458 we can also bypass the XML deployment file, and associate functions for each of defined hosts.
459 - <i>simgrid.Host.setFunction</i>: associate a function to a host, specifying arguments if needed.
460 - <i>simgrid.register_application()</i>: saving the deployment settings before running the simualtion.
462 \until simgrid.clean()