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_gos_functions
22 - \ref msg_easier_life
25 Also make sure to visit the page @ref MSG_examples.
29 /** @defgroup m_datatypes_management MSG Data Types
31 @brief This section describes the different datatypes provided by MSG.
33 \htmlonly <!-- DOXYGEN_NAVBAR_LABEL="Data types" --> \endhtmlonly
36 /** @defgroup m_process_management Management Functions of Agents
38 * @brief This section describes the agent structure of MSG
39 * (#m_process_t) and the functions for managing it.
42 /** @defgroup m_host_management Management functions of Hosts
44 * @brief This section describes the host structure of MSG
47 /** @defgroup m_task_management Managing functions of Tasks
49 * @brief This section describes the task structure of MSG
50 * (#m_task_t) and the functions for managing it.
53 /** @defgroup m_file_management Managing functions of Files
55 * @brief This section describes the file structure of MSG
56 * (#m_file_t) and the functions for managing it. It
57 * is based on POSIX functions.
60 /** @defgroup msg_gos_functions MSG Operating System Functions
62 * @brief This section describes the functions that can be used
63 * by an agent for handling some task.
66 /** @defgroup msg_easier_life Platform and Application management
68 * @brief This section describes functions to manage the platform creation
69 * and the application deployment. Please check @ref
70 * MSG_examples for an overview of their usage.
74 @defgroup msg_simulation MSG simulation Functions
76 @brief This section describes the functions you need to know to
77 set up a simulation. You should have a look at \ref MSG_examples
78 to have an overview of their usage.
80 @htmlonly <!-- DOXYGEN_NAVBAR_LABEL="Simulation functions" --> @endhtmlonly
85 @defgroup MSG_examples MSG Examples
88 MSG comes with an extensive set of examples. It is sometimes difficult
89 to find the one you need. This list aims at helping you finding the
90 example from which you can learn what you want to.
92 @section MSG_ex_basics Basic examples and features
97 @defgroup MSG_LUA Lua bindings
99 @brief Lua bindings to MSG (\ref MSG_API)
101 @htmlonly <!-- DOXYGEN_NAVBAR_LABEL="LUA bindings" --> @endhtmlonly
103 This is the lua bindings of the \ref MSG_API interface.
105 \section lMSG_who Who should use this (and who shouldn't)
107 If you want to use MSG to study your algorithm, but you don't
108 want to use the C language (using \ref MSG_API), then you should
109 use some bindings such as this one. The advantage of the lua
110 bindings is that they are distributed directly with the main
111 archive (in contrary to Java and Ruby bindings, for example,
112 that are distributed separately). Another advantage of lua is
113 that there is almost no performance loss with regard to the C
114 version (at least there shouln't be any -- it is still to be
117 \section MSG_Lua_funct Lua offered functionnalities in MSG
118 Almost all important features of the MSG interface are available
119 from the lua bindings. Unfortunately, since doxygen does not support
120 the lua modules implemented directly in C as we are using, there is
121 no ready to use reference documentation for this module. Even more
122 than for the other modules, you will have to dig into the source
123 code of the examples to learn how to use it.
125 \section Lua_examples Examples of lua MSG
127 - \ref MSG_ex_master_slave_lua
128 - \ref MSG_ex_master_slave_lua_bypass
129 - Also, the lua version of the Chord example (in the source tree)
130 is a working non-trivial example of use of the lua bindings
134 /** \defgroup MSG_ex_asynchronous_communications Asynchronous communications
135 \ingroup MSG_examples
137 Simulation of asynchronous communications between a sender and a receiver using a realistic platform and
138 an external description of the deployment.
140 \section MSG_ex_ms_TOC Table of contents:
141 - \ref MSG_ext_icomms_code
142 - \ref MSG_ext_icomms_preliminary
143 - \ref MSG_ext_icomms_Sender
144 - \ref MSG_ext_icomms_Receiver
145 - \ref MSG_ext_icomms_core
146 - \ref MSG_ext_icomms_Main
147 - \ref MSG_ext_icomms_fct_Waitall
148 - \ref MSG_ext_icomms_fct_Waitany
152 \dontinclude msg/icomms/peer.c
154 \section MSG_ext_icomms_code Code of the application
156 \subsection MSG_ext_icomms_preliminary Preliminary declarations
158 \until Sender function
160 \subsection MSG_ext_icomms_Sender Sender function
162 The sender send to a receiver an asynchronous message with the function "MSG_task_isend()". Cause this function is non-blocking
163 we have to make "MSG_comm_test()" to know if the communication is finished for finally destroy it with function "MSG_comm_destroy()".
164 It also available to "make MSG_comm_wait()" which make both of them.
166 C style arguments (argc/argv) are interpreted as:
167 - the number of tasks to distribute
168 - the computation size of each task
169 - the size of the files associated to each task
170 - a list of host that will accept those tasks.
171 - the time to sleep at the beginning of the function
172 - This time defined the process sleep time
173 if time = 0 use of MSG_comm_wait()
174 if time > 0 use of MSG_comm_test()
177 \until Receiver function
179 \subsection MSG_ext_icomms_Receiver Receiver function
181 This function executes tasks when it receives them. As the receiving is asynchronous we have to test the communication to know
182 if it is completed or not with "MSG_comm_test()" or wait for the completion "MSG_comm_wait()".
184 C style arguments (argc/argv) are interpreted as:
185 - the id to use for received the communication.
186 - the time to sleep at the beginning of the function
187 - This time defined the process sleep time
188 if time = 0 use of MSG_comm_wait()
189 if time > 0 use of MSG_comm_test()
193 \subsection MSG_ext_icomms_core Simulation core
195 This function is the core of the simulation and is divided only into 3 parts
196 thanks to MSG_create_environment() and MSG_launch_application().
197 -# Simulation settings : MSG_create_environment() creates a realistic
199 -# Application deployment : create the agents on the right locations with
200 MSG_launch_application()
201 -# The simulation is run with #MSG_main()
204 - <i>platform_file</i>: the name of a file containing an valid surfxml platform description.
205 - <i>application_file</i>: the name of a file containing a valid surfxml application description
209 \subsection MSG_ext_icomms_Main Main function
211 This initializes MSG, runs a simulation, and free all data-structures created by MSG.
215 \dontinclude msg/icomms/peer2.c
217 \section MSG_ext_icomms_fct_Waitall Waitall function for sender
219 The use of this function permit to send all messages and wait for the completion of all in one time.
221 \skipline Sender function
224 \section MSG_ext_icomms_fct_Waitany Waitany function
226 The MSG_comm_waitany() function return the place of the first message send or receive from a xbt_dynar_t table.
228 \subsection MSG_ext_icomms_fct_Waitany_sender From a sender
229 We can use this function to wait all sended messages.
230 \dontinclude msg/icomms/peer3.c
231 \skipline Sender function
234 \subsection MSG_ext_icomms_fct_Waitany_receiver From a receiver
235 We can also wait for the receiving of all messages.
236 \dontinclude msg/icomms/peer3.c
237 \skipline Receiver function
238 \until end_of_receiver
242 /** @defgroup MSG_ex_master_slave Basic Master/Slaves
243 @ingroup MSG_examples
245 Simulation of a master-slave application using a realistic platform and
246 an external description of the deployment.
248 \section MSG_ex_ms_TOC Table of contents:
250 - \ref MSG_ext_ms_code
251 - \ref MSG_ext_ms_preliminary
252 - \ref MSG_ext_ms_master
253 - \ref MSG_ext_ms_slave
254 - \ref MSG_ext_ms_forwarder
255 - \ref MSG_ext_ms_core
256 - \ref MSG_ext_ms_main
257 - \ref MSG_ext_ms_helping
258 - \ref MSG_ext_ms_application
259 - \ref MSG_ext_ms_platform
263 \dontinclude msg/masterslave/masterslave_forwarder.c
265 \section MSG_ext_ms_code Code of the application
267 \subsection MSG_ext_ms_preliminary Preliminary declarations
273 \subsection MSG_ext_ms_master Master code
275 This function has to be assigned to a m_process_t that will behave as the master.
276 It should not be called directly but either given as a parameter to
277 #MSG_process_create() or registered as a public function through
278 #MSG_function_register() and then automatically assigned to a process through
279 #MSG_launch_application().
281 C style arguments (argc/argv) are interpreted as:
282 - the number of tasks to distribute
283 - the computation size of each task
284 - the size of the files associated to each task
285 - a list of host that will accept those tasks.
287 Tasks are dumbly sent in a round-robin style.
291 \subsection MSG_ext_ms_slave Slave code
293 This function has to be assigned to a #m_process_t that has to behave as a slave.
294 Just like the master fuction (described in \ref MSG_ext_ms_master), it should not be called directly.
296 This function keeps waiting for tasks and executes them as it receives them.
300 \subsection MSG_ext_ms_forwarder Forwarder code
302 This function has to be assigned to a #m_process_t that has to behave as a forwarder.
303 Just like the master function (described in \ref MSG_ext_ms_master), it should not be called directly.
305 C style arguments (argc/argv) are interpreted as a list of host
306 that will accept those tasks.
308 This function keeps waiting for tasks and dispathes them to its slaves.
310 \until end_of_forwarder
312 \subsection MSG_ext_ms_core Simulation core
314 This function is the core of the simulation and is divided only into 3 parts
315 thanks to MSG_create_environment() and MSG_launch_application().
316 -# Simulation settings : MSG_create_environment() creates a realistic
318 -# Application deployment : create the agents on the right locations with
319 MSG_launch_application()
320 -# The simulation is run with #MSG_main()
323 - <i>platform_file</i>: the name of a file containing an valid surfxml platform description.
324 - <i>application_file</i>: the name of a file containing a valid surfxml application description
326 \until end_of_test_all
328 \subsection MSG_ext_ms_main Main() function
330 This initializes MSG, runs a simulation, and free all data-structures created by MSG.
334 \section MSG_ext_ms_helping Helping files
336 \subsection MSG_ext_ms_application Example of application file
338 \include msg/masterslave/deployment_masterslave.xml
340 \subsection MSG_ext_ms_platform Example of platform file
342 \include msg/small_platform.xml
346 /** \page MSG_ex_master_slave_lua Master/slave Lua application
348 Simulation of a master-slave application using lua bindings
349 - \ref MSG_ext_ms_code_lua
350 - \ref MSG_ext_ms_master_lua
351 - \ref MSG_ext_ms_slave_lua
352 - \ref MSG_ext_ms_core_lua
354 - \ref MSG_ext_ms_helping
355 - \ref MSG_ext_ms_application
356 - \ref MSG_ext_ms_platform
359 \dontinclude lua/masterslave/master_slave.lua
361 \section MSG_ext_ms_code_lua Code of the application
363 \subsection MSG_ext_ms_master_lua Master code
365 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.
367 Lua style arguments (...) in for the master are interpreted as:
368 - the number of tasks to distribute
369 - the computation size of each task
370 - the size of the files associated to each task
371 - a list of host that will accept those tasks.
373 Tasks are dumbly sent in a round-robin style.
378 \subsection MSG_ext_ms_slave_lua Slave code
380 This function has to be assigned to a #m_process_t that has to behave as a slave.
381 This function keeps waiting for tasks and executes them as it receives them.
384 \subsection MSG_ext_ms_core_lua Simulation core
386 in this section the core of the simulation which start by including the simgrid lib for bindings
387 : <i>require "simgrid" </i>
389 -# Simulation settings : <i>simgrid.platform</i> creates a realistic
391 -# Application deployment : create the agents on the right locations with
392 <i>simgrid.application</i>
393 -# The simulation is run with <i>simgrid.run</i>
396 - <i>platform_file</i>: the name of a file containing an valid surfxml platform description.( first command line argument)
397 - <i>application_file</i>: the name of a file containing a valid surfxml application description ( second commande line argument )
399 \until simgrid.clean()
403 /** \page MSG_ex_master_slave_lua_bypass Master/slave Bypass Lua application
405 Simulation of a master-slave application using lua bindings, Bypassing the XML parser
406 - \ref MSG_ext_ms_code_lua
407 - \ref MSG_ext_ms_master_lua
408 - \ref MSG_ext_ms_slave_lua
409 - \ref MSG_ext_ms_core_lua
412 \dontinclude lua/console/master_slave_bypass.lua
414 \section MSG_ext_ms_code_lua Code of the application
416 \subsection MSG_ext_ms_master_lua Master code
418 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.
420 Lua style arguments (...) in for the master are interpreted as:
421 - the number of tasks to distribute
422 - the computation size of each task
423 - the size of the files associated to each task
424 - a list of host that will accept those tasks.
426 Tasks are dumbly sent in a round-robin style.
431 \subsection MSG_ext_ms_slave_lua Slave code
433 This function has to be assigned to a #m_process_t that has to behave as a slave.
434 This function keeps waiting for tasks and executes them as it receives them.
437 \subsection MSG_ext_ms_core_lua Simulation core
439 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.
440 : <i>require "simgrid" </i>
442 -# Hosts : <i>simgrid.Host.new</i> instanciate a new host with an id, and power.
443 -# Links : <i>simgrid.Link.new</i> instanictae a new link that will require an id, bandwith and latency values.
444 -# Route : <i>simgrid.Route.new</i> define a route between two hosts specifying the links to use.
445 -# Simulation settings : <i>simgrid.register_platform();</i> register own platform without using the XML SURF parser.
447 we can also bypass the XML deployment file, and associate functions for each of defined hosts.
448 - <i>simgrid.Host.setFunction</i>: associate a function to a host, specifying arguments if needed.
449 - <i>simgrid.register_application()</i>: saving the deployment settings before running the simualtion.
451 \until simgrid.clean()