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
26 Also make sure to visit the page @ref MSG_examples.
30 @defgroup MSG_examples MSG Examples
33 MSG comes with an extensive set of examples. It is sometimes difficult
34 to find the one you need. This list aims at helping you finding the
35 example from which you can learn what you want to.
37 @section MSG_ex_basics Basic examples and features
42 @defgroup msg_simulation Main MSG simulation Functions
44 @brief Describes how to setup and control your simulation.
46 The basic workflow is the following (check the \ref MSG_examples for
49 -# Initialize the library with #MSG_global_init
50 -# Create a platform (usually by parsing a file with
51 #MSG_create_environment)
52 -# Register the functions that your processes are supposed to run with
53 #MSG_function_register (and maybe #MSG_function_register_default)
54 -# Launch your processes from a deployment file with #MSG_launch_application
55 -# Run the simulation with #MSG_main
56 -# Cleanup the library with #MSG_clean before ending your program
59 @htmlonly <!-- DOXYGEN_NAVBAR_LABEL="Simulation control" --> @endhtmlonly
63 /** @defgroup m_datatypes_management MSG Data Types
65 @brief This section describes the different datatypes provided by MSG.
67 \htmlonly <!-- DOXYGEN_NAVBAR_LABEL="Data types" --> \endhtmlonly
70 /** @defgroup m_process_management Process Management Functions
72 * @brief This section describes the process structure of MSG
73 * (#m_process_t) and the functions for managing it.
76 /** @defgroup m_host_management Host Management Functions
78 * @brief This section describes the host structure of MSG
81 /** @defgroup m_task_management Task Management Functions
83 * @brief This section describes the task structure of MSG
84 * (#m_task_t) and the functions for managing it.
87 /** @defgroup m_file_management File Management Functions
89 * @brief This section describes the file structure of MSG
90 * (#m_file_t) and the functions for managing it. It
91 * is based on POSIX functions.
94 /** @defgroup msg_actions_functions Managing actions
96 * @brief This section describes functions for managing actions.
99 /** @defgroup msg_gos_functions MSG Operating System Functions
101 * @brief This section describes the functions that can be used
102 * by a process for handling some task.
107 @defgroup MSG_LUA Lua bindings
109 @brief Lua bindings to MSG (\ref MSG_API)
111 @htmlonly <!-- DOXYGEN_NAVBAR_LABEL="LUA bindings" --> @endhtmlonly
113 This is the lua bindings of the \ref MSG_API interface.
115 \section lMSG_who Who should use this (and who shouldn't)
117 If you want to use MSG to study your algorithm, but you don't want to
118 use the C language (using \ref MSG_API), then you should use some
119 bindings such as this one. The advantage of the lua bindings is that
120 they are distributed directly with the main archive (in contrary to
121 Java and Ruby bindings, for example, that are distributed separately).
122 Another advantage of lua is that there is almost no performance loss
123 with regard to the C version (at least there shouln't be any -- it is
124 still to be precisely assessed).
126 \section MSG_Lua_funct Lua offered functionnalities in MSG
128 Almost all important features of the MSG interface are available from
129 the lua bindings. Unfortunately, since doxygen does not support the
130 lua modules implemented directly in C as we are using, there is no
131 ready to use reference documentation for this module. Even more than
132 for the other modules, you will have to dig into the source code of
133 the examples to learn how to use it.
135 \section Lua_examples Examples of lua MSG
137 - \ref MSG_ex_master_slave_lua
138 - \ref MSG_ex_master_slave_lua_bypass
139 - Also, the lua version of the Chord example (in the source tree)
140 is a working non-trivial example of use of the lua bindings
144 @defgroup msg_deprecated_functions MSG Deprecated
146 @brief This section describes the deprecated functions. PLEASE STOP USING THEM.
148 We don't remove them because the ability to run old scientific
149 code is something important to us. But these functionalities are
150 not actively supported anymore.
152 To access these functions, you should define the relevant option
153 at configuration time in ccmake.
158 @defgroup MSG_ex_asynchronous_communications Asynchronous communications
159 @ingroup MSG_examples
161 Simulation of asynchronous communications between a sender and a receiver using a realistic platform and
162 an external description of the deployment.
164 \section MSG_ex_ms_TOC Table of contents:
165 - \ref MSG_ext_icomms_code
166 - \ref MSG_ext_icomms_preliminary
167 - \ref MSG_ext_icomms_Sender
168 - \ref MSG_ext_icomms_Receiver
169 - \ref MSG_ext_icomms_core
170 - \ref MSG_ext_icomms_Main
171 - \ref MSG_ext_icomms_fct_Waitall
172 - \ref MSG_ext_icomms_fct_Waitany
176 \dontinclude msg/icomms/peer.c
178 \section MSG_ext_icomms_code Code of the application
180 \subsection MSG_ext_icomms_preliminary Preliminary declarations
182 \until Sender function
184 \subsection MSG_ext_icomms_Sender Sender function
186 The sender send to a receiver an asynchronous message with the function "MSG_task_isend()". Cause this function is non-blocking
187 we have to make "MSG_comm_test()" to know if the communication is finished for finally destroy it with function "MSG_comm_destroy()".
188 It also available to "make MSG_comm_wait()" which make both of them.
190 C style arguments (argc/argv) are interpreted as:
191 - the number of tasks to distribute
192 - the computation size of each task
193 - the size of the files associated to each task
194 - a list of host that will accept those tasks.
195 - the time to sleep at the beginning of the function
196 - This time defined the process sleep time
197 if time = 0 use of MSG_comm_wait()
198 if time > 0 use of MSG_comm_test()
201 \until Receiver function
203 \subsection MSG_ext_icomms_Receiver Receiver function
205 This function executes tasks when it receives them. As the receiving is asynchronous we have to test the communication to know
206 if it is completed or not with "MSG_comm_test()" or wait for the completion "MSG_comm_wait()".
208 C style arguments (argc/argv) are interpreted as:
209 - the id to use for received the communication.
210 - the time to sleep at the beginning of the function
211 - This time defined the process sleep time
212 if time = 0 use of MSG_comm_wait()
213 if time > 0 use of MSG_comm_test()
217 \subsection MSG_ext_icomms_core Simulation core
219 This function is the core of the simulation and is divided only into 3 parts
220 thanks to MSG_create_environment() and MSG_launch_application().
221 -# Simulation settings : MSG_create_environment() creates a realistic
223 -# Application deployment : create the processes on the right locations with
224 MSG_launch_application()
225 -# The simulation is run with #MSG_main()
228 - <i>platform_file</i>: the name of a file containing an valid surfxml platform description.
229 - <i>application_file</i>: the name of a file containing a valid surfxml application description
233 \subsection MSG_ext_icomms_Main Main function
235 This initializes MSG, runs a simulation, and free all data-structures created by MSG.
239 \dontinclude msg/icomms/peer2.c
241 \section MSG_ext_icomms_fct_Waitall Waitall function for sender
243 The use of this function permit to send all messages and wait for the completion of all in one time.
245 \skipline Sender function
248 \section MSG_ext_icomms_fct_Waitany Waitany function
250 The MSG_comm_waitany() function return the place of the first message send or receive from a xbt_dynar_t table.
252 \subsection MSG_ext_icomms_fct_Waitany_sender From a sender
253 We can use this function to wait all sent messages.
254 \dontinclude msg/icomms/peer3.c
255 \skipline Sender function
258 \subsection MSG_ext_icomms_fct_Waitany_receiver From a receiver
259 We can also wait for the arrival of all messages.
260 \dontinclude msg/icomms/peer3.c
261 \skipline Receiver function
262 \until end_of_receiver
267 @defgroup MSG_ex_master_slave Basic Master/Slaves
268 @ingroup MSG_examples
270 Simulation of a master-slave application using a realistic platform
271 and an external description of the deployment.
273 \section MSG_ex_ms_TOC Table of contents:
275 - \ref MSG_ext_ms_code
276 - \ref MSG_ext_ms_preliminary
277 - \ref MSG_ext_ms_master
278 - \ref MSG_ext_ms_slave
279 - \ref MSG_ext_ms_forwarder
280 - \ref MSG_ext_ms_core
281 - \ref MSG_ext_ms_main
282 - \ref MSG_ext_ms_helping
283 - \ref MSG_ext_ms_application
284 - \ref MSG_ext_ms_platform
288 \dontinclude msg/masterslave/masterslave_forwarder.c
290 \section MSG_ext_ms_code Code of the application
292 \subsection MSG_ext_ms_preliminary Preliminary declarations
298 \subsection MSG_ext_ms_master Master code
300 This function has to be assigned to a m_process_t that will behave as
301 the master. It should not be called directly but either given as a
302 parameter to #MSG_process_create() or registered as a public function
303 through #MSG_function_register() and then automatically assigned to a
304 process through #MSG_launch_application().
306 C style arguments (argc/argv) are interpreted as:
307 - the number of tasks to distribute
308 - the computation size of each task
309 - the size of the files associated to each task
310 - a list of host that will accept those tasks.
312 Tasks are dumbly sent in a round-robin style.
316 \subsection MSG_ext_ms_slave Slave code
318 This function has to be assigned to a #m_process_t that has to behave
319 as a slave. Just like the master fuction (described in \ref
320 MSG_ext_ms_master), it should not be called directly.
322 This function keeps waiting for tasks and executes them as it receives them.
326 \subsection MSG_ext_ms_forwarder Forwarder code
328 This function has to be assigned to a #m_process_t that has to behave
329 as a forwarder. Just like the master function (described in \ref
330 MSG_ext_ms_master), it should not be called directly.
332 C style arguments (argc/argv) are interpreted as a list of host that
333 will accept those tasks.
335 This function keeps waiting for tasks and dispathes them to its slaves.
337 \until end_of_forwarder
339 \subsection MSG_ext_ms_core Simulation core
341 This function is the core of the simulation and is divided only into 3 parts
342 thanks to MSG_create_environment() and MSG_launch_application().
343 -# Simulation settings : MSG_create_environment() creates a realistic
345 -# Application deployment : create the processes on the right locations with
346 MSG_launch_application()
347 -# The simulation is run with #MSG_main()
350 - <i>platform_file</i>: the name of a file containing an valid surfxml platform description.
351 - <i>application_file</i>: the name of a file containing a valid surfxml application description
353 \until end_of_test_all
355 \subsection MSG_ext_ms_main Main() function
357 This initializes MSG, runs a simulation, and free all data-structures created by MSG.
361 \section MSG_ext_ms_helping Helping files
363 \subsection MSG_ext_ms_application Example of application file
365 \include msg/masterslave/deployment_masterslave.xml
367 \subsection MSG_ext_ms_platform Example of platform file
369 \include msg/small_platform.xml
373 /** \page MSG_ex_master_slave_lua Master/slave Lua application
375 Simulation of a master-slave application using lua bindings
376 - \ref MSG_ext_ms_code_lua
377 - \ref MSG_ext_ms_master_lua
378 - \ref MSG_ext_ms_slave_lua
379 - \ref MSG_ext_ms_core_lua
381 - \ref MSG_ext_ms_helping
382 - \ref MSG_ext_ms_application
383 - \ref MSG_ext_ms_platform
386 \dontinclude lua/masterslave/master_slave.lua
388 \section MSG_ext_ms_code_lua Code of the application
390 \subsection MSG_ext_ms_master_lua Master code
392 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.
394 Lua style arguments (...) in for the master are interpreted as:
395 - the number of tasks to distribute
396 - the computation size of each task
397 - the size of the files associated to each task
398 - a list of host that will accept those tasks.
400 Tasks are dumbly sent in a round-robin style.
405 \subsection MSG_ext_ms_slave_lua Slave code
407 This function has to be assigned to a #m_process_t that has to behave as a slave.
408 This function keeps waiting for tasks and executes them as it receives them.
411 \subsection MSG_ext_ms_core_lua Simulation core
413 in this section the core of the simulation which start by including the simgrid lib for bindings
414 : <i>require "simgrid" </i>
416 -# Simulation settings : <i>simgrid.platform</i> creates a realistic
418 -# Application deployment : create the processes on the right locations with
419 <i>simgrid.application</i>
420 -# The simulation is run with <i>simgrid.run</i>
423 - <i>platform_file</i>: the name of a file containing an valid surfxml platform description.( first command line argument)
424 - <i>application_file</i>: the name of a file containing a valid surfxml application description ( second commande line argument )
426 \until simgrid.clean()
430 /** \page MSG_ex_master_slave_lua_bypass Master/slave Bypass Lua application
432 Simulation of a master-slave application using lua bindings, Bypassing the XML parser
433 - \ref MSG_ext_ms_code_lua
434 - \ref MSG_ext_ms_master_lua
435 - \ref MSG_ext_ms_slave_lua
436 - \ref MSG_ext_ms_core_lua
439 \dontinclude lua/console/master_slave_bypass.lua
441 \section MSG_ext_ms_code_lua Code of the application
443 \subsection MSG_ext_ms_master_lua Master code
445 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.
447 Lua style arguments (...) in for the master are interpreted as:
448 - the number of tasks to distribute
449 - the computation size of each task
450 - the size of the files associated to each task
451 - a list of host that will accept those tasks.
453 Tasks are dumbly sent in a round-robin style.
458 \subsection MSG_ext_ms_slave_lua Slave code
460 This function has to be assigned to a #m_process_t that has to behave as a slave.
461 This function keeps waiting for tasks and executes them as it receives them.
464 \subsection MSG_ext_ms_core_lua Simulation core
466 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.
467 : <i>require "simgrid" </i>
469 -# Hosts : <i>simgrid.Host.new</i> instanciate a new host with an id, and power.
470 -# Links : <i>simgrid.Link.new</i> instanictae a new link that will require an id, bandwith and latency values.
471 -# Route : <i>simgrid.Route.new</i> define a route between two hosts specifying the links to use.
472 -# Simulation settings : <i>simgrid.register_platform();</i> register own platform without using the XML SURF parser.
474 we can also bypass the XML deployment file, and associate functions for each of defined hosts.
475 - <i>simgrid.Host.setFunction</i>: associate a function to a host, specifying arguments if needed.
476 - <i>simgrid.register_application()</i>: saving the deployment settings before running the simualtion.
478 \until simgrid.clean()