Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
New test for the remote exec
[simgrid.git] / examples / s4u / README.doc
1 S4U (Simgrid for you) is the next interface of SimGrid, expected to be released with SimGrid 4.0.
2
3 Even if it is not completely rock stable yet, it may well already fit
4 your needs. You are welcome to try it and report any interface
5 glitches that you see. Be however warned that the interface may change
6 until the final release.  You will have to adapt your code on the way.
7
8 This file follows the Doxygen syntax to be included in the
9 documentation, but it should remain readable directly.
10
11 /** 
12  @defgroup s4u_examples S4U examples
13  @ingroup s4u_api
14  @brief Find the S4U example fitting your needs in the archive.
15
16   - @ref s4u_ex_basics
17   - @ref s4u_ex_activities
18   - @ref s4u_ex_actors
19   - @ref s4u_ex_synchro
20   - @ref s4u_ex_actions
21   - @ref s4u_ex_platf
22   - @ref s4u_ex_io
23   - @ref s4u_ex_energy
24
25 TODO: document here the examples about plugins
26
27 @section s4u_ex_basics Basics of SimGrid simulation
28
29   - <b>Creating actors:</b> @ref examples/s4u/actor-create/s4u-actor-create.cpp and 
30     @ref examples/s4u/actor-create/s4u-actor-create_d.xml \n
31     Shows how to start your actors to populate your simulation.
32
33   - <b>Ping Pong</b>: @ref examples/s4u/app-pingpong/s4u-app-pingpong.cpp\n
34     This simple example just sends one message back and forth.
35     The tesh file laying in the directory show how to start the simulator binary, highlighting how to pass options to 
36     the simulators (as detailed in Section \ref options). 
37
38   - <b>Token ring:</b> @ref examples/s4u/app-token-ring/s4u-app-token-ring.cpp \n
39     Shows how to implement a classical communication pattern, where a token is exchanged along a ring to reach every
40     participant.
41
42   - <b>Master Workers:</b> @ref examples/s4u/app-masterworker/s4u-app-masterworker.cpp \n
43     Another good old example, where one Master process has a bunch of task to dispatch to a set of several Worker 
44     processes. 
45     
46 @section s4u_ex_activities Activities on Resources (communications and executions)
47
48 @subsection s4u_ex_activity_comm Communications (using the network)
49
50  - <b>Basic asynchronous communications</b>. 
51    @ref examples/s4u/async-wait/s4u-async-wait.cpp \n
52    Illustrates how to have non-blocking communications, that are
53    communications running in the background leaving the process free
54    to do something else during their completion. The main functions
55    involved are @ref simgrid::s4u::Mailbox::put_async and 
56    @ref simgrid::s4u::Comm::wait().
57
58  - <b>Waiting for all communications in a set</b>.
59    @ref examples/s4u/async-waitall/s4u-async-waitall.cpp\n
60    The @ref simgrid::s4u::Comm::wait_all() function is useful when you want to block
61    until all activities in a given set have completed.
62
63  - <b>Waiting for the first completed communication in a set</b>.
64    @ref examples/s4u/async-waitany/s4u-async-waitany.cpp\n
65    The @ref simgrid::s4u::Comm::wait_any() function is useful when you want to block
66    until one activity of the set completes, no matter which terminates
67    first.    
68
69 @subsection s4u_ex_activity_exec Executions (using the CPU)
70
71   - <b>Basic execution</b>.
72     @ref examples/s4u/exec-basic/s4u-exec-basic.cpp \n
73     The computations done in your program are not reported to the
74     simulated world, unless you explicitely request the simulator to pause
75     the actor until a given amount of flops gets computed on its simulated
76     host. Some executions can be given an higher priority so that they
77     get more resources.
78
79   - <b>Asynchronous execution</b>.
80     @ref examples/s4u/exec-async/s4u-exec-async.cpp \n
81     You can start asynchronous executions, in a way that is very
82     similar to asynchronous communications.
83     
84   - <b>Monitoring asynchronous executions</b>.
85     @ref examples/s4u/exec-monitor/s4u-exec-monitor.cpp \n
86     This example shows how to start an asynchronous execution, and
87     monitor its status.
88     
89   - <b>Remote execution</b>.
90     @ref examples/s4u/exec-remote/s4u-exec-remote.cpp \n
91     Before its start, you can change the host on which a given execution will occur.
92
93   TODO: add an example about parallel executions.
94
95 @section s4u_ex_actors Acting on Actors
96
97   - <b>Creating actors</b>. 
98     @ref examples/s4u/actor-create/s4u-actor-create.cpp \n
99     Most actors are started from the deployment XML file, but there is other methods.
100     This example show them all.
101
102   - <b>Daemonize actors</b>
103     @ref examples/s4u/actor-daemon/s4u-actor-daemon.cpp \n
104     Some actors may be intended to simulate daemons that run in background. This example show how to transform a regular
105     actor into a daemon that will be automatically killed once the simulation is over. 
106
107   - <b>Suspend and Resume actors</b>.
108     @ref examples/s4u/actor-suspend/s4u-actor-suspend.cpp \n
109     Actors can be suspended and resumed during their executions
110     thanks to the @ref simgrid::s4u::Actor::suspend and @ref simgrid::s4u::Actor::resume methods.
111
112   - <b>Kill actors</b>.
113     @ref examples/s4u/actor-kill/s4u-actor-kill.cpp \n
114     Actors can forcefully stop other actors with the @ref
115     simgrid::s4u::Actor::kill() method.
116
117   - <b>Controling the actor life cycle from the XML</b>.
118     @ref examples/s4u/actor-lifetime/s4u-actor-lifetime.cpp 
119     @ref examples/s4u/actor-lifetime/s4u-actor-lifetime_d.xml 
120     \n
121     You can specify a start time and a kill time in the deployment file.
122
123   - <b>Migrating Actors</b>.
124     @ref examples/s4u/actor-migration/s4u-actor-migration.cpp \n
125     Actors can move or be moved from a host to another with the @ref
126     simgrid::s4u::this_actor::migrate() method.
127
128   - <b>Yielding to other actor</b>.
129     @ref examples/s4u/actor-yield/s4u-actor-yield.cpp\n
130     The simgrid::s4u::this_actor::yield() function interrupts the
131     execution of the current actor, leaving a chance to the other actors
132     that are ready to run at this timestamp.
133
134 @section s4u_ex_synchro Inter-Actor Synchronization 
135
136  - <b>Waiting for the termination of an actor</b> (joining on it)
137    @ref examples/s4u/actor-join/s4u-actor-join.cpp \n
138    The simgrid::s4u::Actor::join() method allows to block the current
139    actor until the end of the receiving actor.
140
141  - <b>Mutex: </b> @ref examples/s4u/mutex/s4u-mutex.cpp \n
142    Shows how to use simgrid::s4u::Mutex synchronization objects.
143
144 @section s4u_ex_actions Following Workload Traces
145
146 This section details how to run trace-driven simulations. It is very
147 handy when you want to test an algorithm or protocol that only react
148 to external events. For example, many P2P protocols react to user
149 requests, but do nothing if there is no such event.
150
151 In such situations, you should write your protocol in C++, and separate
152 the workload that you want to play onto your protocol in a separate
153 text file. Declare a function handling each type of the events in your
154 trace, register them using @ref xbt_replay_action_register in your
155 main, and then run the simulation.
156
157 Then, you can either have one trace file containing all your events,
158 or a file per simulated process: the former may be easier to work
159 with, but the second is more efficient on very large traces. Check
160 also the tesh files in the example directories for details.
161
162   - <b>Communication replay</b>.
163     @ref examples/s4u/actions-comm/s4u-actions-comm.cpp \n
164     Presents a set of event handlers reproducing classical communication
165     primitives (asynchronous send/receive at the moment).
166
167   - <b>I/O replay</b>.
168     @ref examples/s4u/actions-storage/s4u-actions-storage.cpp \n
169     Presents a set of event handlers reproducing classical I/O
170     primitives (open, read, close).
171
172 @section s4u_ex_platf Interacting with the platform
173
174  - <b>User-defined properties</b>.
175    @ref examples/s4u/platform-properties/s4u-platform-properties.cpp and 
176    @ref examples/s4u/platform-properties/s4u-platform-properties_d.xml and
177    @ref examples/platforms/prop.xml \n
178    You can attach arbitrary information to most platform elements from
179    the XML file, and then interact with these values from your
180    program. Note that the changes are not written into the XML file: they
181    will only last until the end of your simulation.
182    - simgrid::s4u::Actor::getProperty() and simgrid::s4u::Actor::setProperty()
183    - simgrid::s4u::Host::getProperty() and simgrid::s4u::Host::setProperty()
184    - simgrid::s4u::Link::getProperty() and simgrid::s4u::Link::setProperty()
185    - simgrid::s4u::NetZone::getProperty() and simgrid::s4u::NetZone::setProperty()
186
187 @section s4u_ex_io Simulating disks and files
188
189 The examples of this section demonstrate how to interact with the
190 simulated storages. 
191
192 SimGrid provides two levels of abstraction. You can either use the 
193 FileSystem plugin, or interact directly with the disks. At the file
194 system level, you can open files and interact with them. A write
195 operation may fail if the disk is already full. Using the direct (low
196 level) interface, you just specify the amount of data that is written
197 or read, and this is done unconditionnally. Both levels have
198 respective advantages, depending on what you want to model.
199
200   - <b>Access to raw storage devices</b>.
201     @ref examples/s4u/io-storage-raw/s4u-io-storage-raw.cpp \n
202     This example illustrates how to simply read and write data on a
203     simulated storage resource.
204
205   - <b>File Management</b>. @ref examples/s4u/io-file-system/s4u-io-file-system.cpp \n
206     This example illustrates the use of operations on files
207     (read, write, seek, tell, unlink, ...).
208
209   - <b>Remote I/O</b>. 
210     @ref examples/s4u/io-file-remote/s4u-io-file-remote.cpp \n
211     I/O operations on files can also be done in a remote fashion, 
212     i.e. when the accessed disk is not mounted on the caller's host.
213
214 @section s4u_ex_energy Simulating the energy consumption
215
216   - <b>Using Pstates on a host</b>
217     @ref examples/s4u/energy-pstate/s4u-energy-pstate.cpp and 
218     @ref examples/platforms/energy_platform.xml \n
219     Show how define a set of pstates for a host and how the current
220     pstate can be accessed/changed with @ref simgrid::s4u::Host::getPstateSpeed and @ref simgrid::s4u::Host::setPstate.
221     See also the platform XML file for have a details on how to declare the CPU capacity for each pstate.
222
223 */
224
225 /**
226 @example examples/s4u/actions-comm/s4u-actions-comm.cpp
227 @example examples/s4u/actions-storage/s4u-actions-storage.cpp
228 @example examples/s4u/actor-create/s4u-actor-create.cpp
229 @example examples/s4u/actor-create/s4u-actor-create_d.xml
230 @example examples/s4u/actor-daemon/s4u-actor-daemon.cpp
231 @example examples/s4u/actor-join/s4u-actor-join.cpp
232 @example examples/s4u/actor-kill/s4u-actor-kill.cpp
233 @example examples/s4u/actor-lifetime/s4u-actor-lifetime.cpp 
234 @example examples/s4u/actor-lifetime/s4u-actor-lifetime_d.xml 
235 @example examples/s4u/actor-migration/s4u-actor-migration.cpp
236 @example examples/s4u/actor-suspend/s4u-actor-suspend.cpp
237 @example examples/s4u/actor-yield/s4u-actor-yield.cpp
238 @example examples/s4u/async-wait/s4u-async-wait.cpp
239 @example examples/s4u/async-waitall/s4u-async-waitall.cpp
240 @example examples/s4u/async-waitany/s4u-async-waitany.cpp
241 @example examples/s4u/exec-basic/s4u-exec-basic.cpp
242 @example examples/s4u/exec-async/s4u-exec-async.cpp
243 @example examples/s4u/exec-monitor/s4u-exec-monitor.cpp
244 @example examples/s4u/exec-remote/s4u-exec-remote.cpp 
245 @example examples/s4u/app-token-ring/s4u-app-token-ring.cpp
246 @example examples/s4u/app-masterworker/s4u-app-masterworker.cpp
247 @example examples/s4u/app-pingpong/s4u-app-pingpong.cpp
248 @example examples/s4u/energy-pstate/s4u-energy-pstate.cpp
249 @example examples/s4u/io-file-system/s4u-io-file-system.cpp
250 @example examples/s4u/io-file-remote/s4u-io-file-remote.cpp
251 @example examples/s4u/io-storage-raw/s4u-io-storage-raw.cpp
252 @example examples/s4u/mutex/s4u-mutex.cpp
253 @example examples/s4u/platform-properties/s4u-platform-properties.cpp
254 @example examples/s4u/platform-properties/s4u-platform-properties_d.xml
255 @example examples/platforms/energy_platform.xml
256 @example examples/platforms/prop.xml
257
258 */