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 Also make sure to visit the page @ref MSG_examples.
28 /** @defgroup m_datatypes_management MSG Data Types
30 @brief This section describes the different datatypes provided by MSG.
32 \htmlonly <!-- DOXYGEN_NAVBAR_LABEL="Data types" --> \endhtmlonly
35 /** @defgroup m_process_management Management Functions of Agents
37 * @brief This section describes the agent structure of MSG
38 * (#m_process_t) and the functions for managing it.
41 /** @defgroup m_host_management Management functions of Hosts
43 * @brief This section describes the host structure of MSG
46 /** @defgroup m_task_management Managing functions of Tasks
48 * @brief This section describes the task structure of MSG
49 * (#m_task_t) and the functions for managing it.
52 /** @defgroup msg_gos_functions MSG Operating System Functions
54 * @brief This section describes the functions that can be used
55 * by an agent for handling some task.
58 /** @defgroup msg_easier_life Platform and Application management
60 * @brief This section describes functions to manage the platform creation
61 * and the application deployment. Please check @ref
62 * MSG_examples for an overview of their usage.
66 @defgroup msg_simulation MSG simulation Functions
68 @brief This section describes the functions you need to know to
69 set up a simulation. You should have a look at \ref MSG_examples
70 to have an overview of their usage.
72 @htmlonly <!-- DOXYGEN_NAVBAR_LABEL="Simulation functions" --> @endhtmlonly
77 @defgroup MSG_examples MSG Examples
80 MSG comes with an extensive set of examples. It is sometimes difficult
81 to find the one you need.
83 @section MSG_ex_basics Basic examples and features
88 @defgroup MSG_LUA Lua bindings
90 @brief Lua bindings to MSG (\ref MSG_API)
92 @htmlonly <!-- DOXYGEN_NAVBAR_LABEL="LUA bindings" --> @endhtmlonly
94 This is the lua bindings of the \ref MSG_API interface.
96 \section lMSG_who Who should use this (and who shouldn't)
98 If you want to use MSG to study your algorithm, but you don't
99 want to use the C language (using \ref MSG_API), then you should
100 use some bindings such as this one. The advantage of the lua
101 bindings is that they are distributed directly with the main
102 archive (in contrary to Java and Ruby bindings, for example,
103 that are distributed separately). Another advantage of lua is
104 that there is almost no performance loss with regard to the C
105 version (at least there shouln't be any -- it is still to be
108 \section MSG_Lua_funct Lua offered functionnalities in MSG
109 Almost all important features of the MSG interface are available
110 from the lua bindings. Unfortunately, since doxygen does not support
111 the lua modules implemented directly in C as we are using, there is
112 no ready to use reference documentation for this module. Even more
113 than for the other modules, you will have to dig into the source
114 code of the examples to learn how to use it.
116 \section Lua_examples Examples of lua MSG
118 - \ref MSG_ex_master_slave_lua
119 - \ref MSG_ex_master_slave_lua_bypass
120 - Also, the lua version of the Chord example (in the source tree)
121 is a working non-trivial example of use of the lua bindings
125 /** \defgroup MSG_ex_asynchronous_communications Asynchronous communications
126 \ingroup MSG_examples
128 Simulation of asynchronous communications between a sender and a receiver using a realistic platform and
129 an external description of the deployment.
131 \section MSG_ex_ms_TOC Table of contents:
132 - \ref MSG_ext_icomms_code
133 - \ref MSG_ext_icomms_preliminary
134 - \ref MSG_ext_icomms_Sender
135 - \ref MSG_ext_icomms_Receiver
136 - \ref MSG_ext_icomms_core
137 - \ref MSG_ext_icomms_Main
138 - \ref MSG_ext_icomms_fct_Waitall
139 - \ref MSG_ext_icomms_fct_Waitany
143 \dontinclude msg/icomms/peer.c
145 \section MSG_ext_icomms_code Code of the application
147 \subsection MSG_ext_icomms_preliminary Preliminary declarations
149 \until Sender function
151 \subsection MSG_ext_icomms_Sender Sender function
153 The sender send to a receiver an asynchronous message with the function "MSG_task_isend()". Cause this function is non-blocking
154 we have to make "MSG_comm_test()" to know if the communication is finished for finally destroy it with function "MSG_comm_destroy()".
155 It also available to "make MSG_comm_wait()" which make both of them.
157 C style arguments (argc/argv) are interpreted as:
158 - the number of tasks to distribute
159 - the computation size of each task
160 - the size of the files associated to each task
161 - a list of host that will accept those tasks.
162 - the time to sleep at the beginning of the function
163 - This time defined the process sleep time
164 if time = 0 use of MSG_comm_wait()
165 if time > 0 use of MSG_comm_test()
168 \until Receiver function
170 \subsection MSG_ext_icomms_Receiver Receiver function
172 This function executes tasks when it receives them. As the receiving is asynchronous we have to test the communication to know
173 if it is completed or not with "MSG_comm_test()" or wait for the completion "MSG_comm_wait()".
175 C style arguments (argc/argv) are interpreted as:
176 - the id to use for received the communication.
177 - the time to sleep at the beginning of the function
178 - This time defined the process sleep time
179 if time = 0 use of MSG_comm_wait()
180 if time > 0 use of MSG_comm_test()
184 \subsection MSG_ext_icomms_core Simulation core
186 This function is the core of the simulation and is divided only into 3 parts
187 thanks to MSG_create_environment() and MSG_launch_application().
188 -# Simulation settings : MSG_create_environment() creates a realistic
190 -# Application deployment : create the agents on the right locations with
191 MSG_launch_application()
192 -# The simulation is run with #MSG_main()
195 - <i>platform_file</i>: the name of a file containing an valid surfxml platform description.
196 - <i>application_file</i>: the name of a file containing a valid surfxml application description
200 \subsection MSG_ext_icomms_Main Main function
202 This initializes MSG, runs a simulation, and free all data-structures created by MSG.
206 \dontinclude msg/icomms/peer2.c
208 \section MSG_ext_icomms_fct_Waitall Waitall function for sender
210 The use of this function permit to send all messages and wait for the completion of all in one time.
212 \skipline Sender function
215 \section MSG_ext_icomms_fct_Waitany Waitany function
217 The MSG_comm_waitany() function return the place of the first message send or receive from a xbt_dynar_t table.
219 \subsection MSG_ext_icomms_fct_Waitany_sender From a sender
220 We can use this function to wait all sended messages.
221 \dontinclude msg/icomms/peer3.c
222 \skipline Sender function
225 \subsection MSG_ext_icomms_fct_Waitany_receiver From a receiver
226 We can also wait for the receiving of all messages.
227 \dontinclude msg/icomms/peer3.c
228 \skipline Receiver function
229 \until end_of_receiver
233 /** @defgroup MSG_ex_master_slave Basic Master/Slaves
234 @ingroup MSG_examples
236 Simulation of a master-slave application using a realistic platform and
237 an external description of the deployment.
239 \section MSG_ex_ms_TOC Table of contents:
241 - \ref MSG_ext_ms_code
242 - \ref MSG_ext_ms_preliminary
243 - \ref MSG_ext_ms_master
244 - \ref MSG_ext_ms_slave
245 - \ref MSG_ext_ms_forwarder
246 - \ref MSG_ext_ms_core
247 - \ref MSG_ext_ms_main
248 - \ref MSG_ext_ms_helping
249 - \ref MSG_ext_ms_application
250 - \ref MSG_ext_ms_platform
254 \dontinclude msg/masterslave/masterslave_forwarder.c
256 \section MSG_ext_ms_code Code of the application
258 \subsection MSG_ext_ms_preliminary Preliminary declarations
264 \subsection MSG_ext_ms_master Master code
266 This function has to be assigned to a m_process_t that will behave as the master.
267 It should not be called directly but either given as a parameter to
268 #MSG_process_create() or registered as a public function through
269 #MSG_function_register() and then automatically assigned to a process through
270 #MSG_launch_application().
272 C style arguments (argc/argv) are interpreted as:
273 - the number of tasks to distribute
274 - the computation size of each task
275 - the size of the files associated to each task
276 - a list of host that will accept those tasks.
278 Tasks are dumbly sent in a round-robin style.
282 \subsection MSG_ext_ms_slave Slave code
284 This function has to be assigned to a #m_process_t that has to behave as a slave.
285 Just like the master fuction (described in \ref MSG_ext_ms_master), it should not be called directly.
287 This function keeps waiting for tasks and executes them as it receives them.
291 \subsection MSG_ext_ms_forwarder Forwarder code
293 This function has to be assigned to a #m_process_t that has to behave as a forwarder.
294 Just like the master function (described in \ref MSG_ext_ms_master), it should not be called directly.
296 C style arguments (argc/argv) are interpreted as a list of host
297 that will accept those tasks.
299 This function keeps waiting for tasks and dispathes them to its slaves.
301 \until end_of_forwarder
303 \subsection MSG_ext_ms_core Simulation core
305 This function is the core of the simulation and is divided only into 3 parts
306 thanks to MSG_create_environment() and MSG_launch_application().
307 -# Simulation settings : MSG_create_environment() creates a realistic
309 -# Application deployment : create the agents on the right locations with
310 MSG_launch_application()
311 -# The simulation is run with #MSG_main()
314 - <i>platform_file</i>: the name of a file containing an valid surfxml platform description.
315 - <i>application_file</i>: the name of a file containing a valid surfxml application description
317 \until end_of_test_all
319 \subsection MSG_ext_ms_main Main() function
321 This initializes MSG, runs a simulation, and free all data-structures created by MSG.
325 \section MSG_ext_ms_helping Helping files
327 \subsection MSG_ext_ms_application Example of application file
329 \include msg/masterslave/deployment_masterslave.xml
331 \subsection MSG_ext_ms_platform Example of platform file
333 \include msg/small_platform.xml
337 /** \page MSG_ex_master_slave_lua Master/slave Lua application
339 Simulation of a master-slave application using lua bindings
340 - \ref MSG_ext_ms_code_lua
341 - \ref MSG_ext_ms_master_lua
342 - \ref MSG_ext_ms_slave_lua
343 - \ref MSG_ext_ms_core_lua
345 - \ref MSG_ext_ms_helping
346 - \ref MSG_ext_ms_application
347 - \ref MSG_ext_ms_platform
350 \dontinclude lua/masterslave/master_slave.lua
352 \section MSG_ext_ms_code_lua Code of the application
354 \subsection MSG_ext_ms_master_lua Master code
356 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.
358 Lua style arguments (...) in for the master are interpreted as:
359 - the number of tasks to distribute
360 - the computation size of each task
361 - the size of the files associated to each task
362 - a list of host that will accept those tasks.
364 Tasks are dumbly sent in a round-robin style.
369 \subsection MSG_ext_ms_slave_lua Slave code
371 This function has to be assigned to a #m_process_t that has to behave as a slave.
372 This function keeps waiting for tasks and executes them as it receives them.
375 \subsection MSG_ext_ms_core_lua Simulation core
377 in this section the core of the simulation which start by including the simgrid lib for bindings
378 : <i>require "simgrid" </i>
380 -# Simulation settings : <i>simgrid.platform</i> creates a realistic
382 -# Application deployment : create the agents on the right locations with
383 <i>simgrid.application</i>
384 -# The simulation is run with <i>simgrid.run</i>
387 - <i>platform_file</i>: the name of a file containing an valid surfxml platform description.( first command line argument)
388 - <i>application_file</i>: the name of a file containing a valid surfxml application description ( second commande line argument )
390 \until simgrid.clean()
394 /** \page MSG_ex_master_slave_lua_bypass Master/slave Bypass Lua application
396 Simulation of a master-slave application using lua bindings, Bypassing the XML parser
397 - \ref MSG_ext_ms_code_lua
398 - \ref MSG_ext_ms_master_lua
399 - \ref MSG_ext_ms_slave_lua
400 - \ref MSG_ext_ms_core_lua
403 \dontinclude lua/console/master_slave_bypass.lua
405 \section MSG_ext_ms_code_lua Code of the application
407 \subsection MSG_ext_ms_master_lua Master code
409 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.
411 Lua style arguments (...) in for the master are interpreted as:
412 - the number of tasks to distribute
413 - the computation size of each task
414 - the size of the files associated to each task
415 - a list of host that will accept those tasks.
417 Tasks are dumbly sent in a round-robin style.
422 \subsection MSG_ext_ms_slave_lua Slave code
424 This function has to be assigned to a #m_process_t that has to behave as a slave.
425 This function keeps waiting for tasks and executes them as it receives them.
428 \subsection MSG_ext_ms_core_lua Simulation core
430 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.
431 : <i>require "simgrid" </i>
433 -# Hosts : <i>simgrid.Host.new</i> instanciate a new host with an id, and power.
434 -# Links : <i>simgrid.Link.new</i> instanictae a new link that will require an id, bandwith and latency values.
435 -# Route : <i>simgrid.Route.new</i> define a route between two hosts specifying the links to use.
436 -# Simulation settings : <i>simgrid.register_platform();</i> register own platform without using the XML SURF parser.
438 we can also bypass the XML deployment file, and associate functions for each of defined hosts.
439 - <i>simgrid.Host.setFunction</i>: associate a function to a host, specifying arguments if needed.
440 - <i>simgrid.register_application()</i>: saving the deployment settings before running the simualtion.
442 \until simgrid.clean()