Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
5583e38df38218b1f1cc817bf3f4b72c237f54d0
[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 its 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_async
18   - @ref s4u_ex_actors
19   - @ref s4u_ex_synchro
20   - @ref s4u_ex_actions
21
22 @section s4u_ex_basics Basics of SimGrid simulation
23
24   - <b>Creating actors:</b> @ref examples/s4u/actor-create/s4u-actor-create.cpp and 
25     @ref examples/s4u/actor-create/s4u-actor-create_d.xml \n
26     Shows how to start your actors to populate your simulation.
27
28   - <b>Ping Pong</b>: @ref examples/s4u/app-pingpong/s4u-app-pingpong.cpp\n
29     This simple example just sends one message back and forth.
30     The tesh file laying in the directory show how to start the simulator binary, highlighting how to pass options to 
31     the simulators (as detailed in Section \ref options). 
32
33   - <b>Token ring:</b> @ref examples/s4u/app-token-ring/s4u-app-token-ring.cpp \n
34     Shows how to implement a classical communication pattern, where a token is exchanged along a ring to reach every
35     participant.
36
37   - <b>Master Workers:</b> @ref examples/s4u/app-masterworker/s4u-app-masterworker.cpp \n
38     Another good old example, where one Master process has a bunch of task to dispatch to a set of several Worker 
39     processes. 
40     
41 @section s4u_ex_async Asynchronous communications
42
43  - <b>Basic asynchronous communications</b>. 
44    @ref examples/s4u/async-wait/s4u-async-wait.cpp \n
45    Illustrates how to have non-blocking communications, that are
46    communications running in the background leaving the process free
47    to do something else during their completion. The main functions
48    involved are @ref simgrid::s4u::Comm::put_async and 
49    @ref simgrid::s4u::Comm::wait().
50
51  - <b>Waiting for all communications in a set</b>.
52    @ref examples/s4u/async-waitall/s4u-async-waitall.cpp\n
53    The @ref simgrid::s4u::Comm::wait_all() function is useful when you want to block
54    until all activities in a given set have completed.
55
56  - <b>Waiting for the first completed communication in a set</b>.
57    @ref examples/s4u/async-waitany/s4u-async-waitany.cpp\n
58    The @ref simgrid::s4u::Comm::wait_any() function is useful when you want to block
59    until one activity of the set completes, no matter which terminates
60    first.    
61
62 @section s4u_ex_actors Acting on Actors
63
64   - <b>Creating actors</b>. 
65     @ref examples/s4u/actor-create/s4u-actor-create.cpp \n
66     Most actors are started from the deployment XML file, but they exist other methods.
67
68   - <b>Actors using CPU time</b>.
69     @ref examples/s4u/actor-execute/s4u-actor-execute.cpp \n
70     The computations done in your program are not reported to the
71     simulated world, unless you explicitely request the simulator to pause
72     the actor until a given amount of flops gets computed on its simulated
73     host.
74
75   - <b>Daemonize actors</b>
76     @ref examples/s4u/actor-daemon/s4u-actor-daemon.cpp \n
77     Some actors may be intended to simulate daemons that run in background. This example show how to transform a regular
78     actor into a daemon that will be automatically killed once the simulation is over. 
79
80   - <b>Suspend and Resume actors</b>.
81     @ref examples/s4u/actor-suspend/s4u-actor-suspend.cpp \n
82     Actors can be suspended and resumed during their executions
83     thanks to the @ref suspend and @ref resume methods.
84
85     - <b>Priority actors</b>.
86     @ref examples/s4u/actor-priority/s4u-actor-priority.cpp \n
87     Actors can be launched according their priorities thanks to the @ref
88      execution method.
89
90   - <b>Kill actors</b>.
91     @ref examples/s4u/actor-kill/s4u-actor-kill.cpp \n
92     Actors can forcefully stop other actors with the @ref kill method.
93
94   - <b>Controling the actor life cycle from the XML</b>.
95     @ref examples/s4u/actor-lifetime/s4u-actor-lifetime.cpp 
96     @ref examples/s4u/actor-lifetime/s4u-actor-lifetime_d.xml 
97     \n
98     You can specify a start time and a kill time in the deployment file.
99
100   - <b>Migrating Actors</b>.
101     @ref examples/s4u/actor-migration/s4u-actor-migration.cpp \n
102     Actors can move or be moved from a host to another with the @ref migrate method.
103
104   - <b>Using Pstates on a host</b>
105     @ref examples/s4u/energy-pstate/s4u-energy-pstate.c\n
106     Show how define a set of pstates for a host and how the current
107     pstate can be accessed/changed with @ref getPstateSpeed and @ref  sg_host_set_pstate.
108     See also the platform XML file for have a details on how to declare the CPU capacity for each pstate.
109
110   - <b>Yielding to other actor</b>.
111     @ref examples/s4u/actor-yield/s4u-actor-yield.c\n
112     The simgrid::s4u::this_actor::yield() function interrupts the
113     execution of the current actor, leaving a chance to the other actors
114     that are ready to run at this timestamp.
115
116 @section s4u_ex_synchro Inter-Actor Synchronization 
117
118  - <b>Mutex: </b> @ref examples/s4u/mutex/s4u-mutex.cpp \n
119    Shows how to use simgrid::s4u::Mutex synchronization objects.
120
121 @section s4u_ex_actions Following Workload Traces
122
123 This section details how to run trace-driven simulations. It is very
124 handy when you want to test an algorithm or protocol that only react
125 to external events. For example, many P2P protocols react to user
126 requests, but do nothing if there is no such event.
127
128 In such situations, you should write your protocol in C++, and separate
129 the workload that you want to play onto your protocol in a separate
130 text file. Declare a function handling each type of the events in your
131 trace, register them using @ref xbt_replay_action_register in your
132 main, and then run the simulation.
133
134 Then, you can either have one trace file containing all your events,
135 or a file per simulated process: the former may be easier to work
136 with, but the second is more efficient on very large traces. Check
137 also the tesh files in the example directories for details.
138
139   - <b>Communication replay</b>.
140     @ref examples/s4u/actions-comm/s4u-actions-comm.cpp \n
141     Presents a set of event handlers reproducing classical communication
142     primitives (asynchronous send/receive at the moment).
143
144   - <b>I/O replay</b>.
145     @ref examples/s4u/actions-storage/s4u-actions-storage.cpp \n
146     Presents a set of event handlers reproducing classical I/O
147     primitives (open, read, close).
148
149 @subsection s4u_ex_io Simulating disks and files
150
151 The examples of this section demonstrate how to interact with the
152 simulated storages.
153
154   - <b>Access to raw storage devices </b>.
155     @ref examples/s4u/io-raw-storage/s4u-io-raw-storage.cpp \n
156     This example illustrates how to simply read and write data on a
157     simulated storage resource.
158
159   - <b>Remote I/O</b>. 
160     @ref examples/s4u/io-file-remote/s4u-io-file-remote.cpp \n
161     I/O operations on files can also be done in a remote fashion, 
162     i.e. when the accessed disk is not mounted on the caller's host.
163
164 */
165
166 /**
167 @example examples/s4u/actions-comm/s4u-actions-comm.cpp
168 @example examples/s4u/actions-storage/s4u-actions-storage.cpp
169 @example examples/s4u/actor-create/s4u-actor-create.cpp
170 @example examples/s4u/actor-create/s4u-actor-create_d.xml
171 @example examples/s4u/actor-daemon/s4u-actor-daemon.cpp
172 @example examples/s4u/actor-execute/s4u-actor-execute.cpp
173 @example examples/s4u/actor-kill/s4u-actor-kill.cpp
174 @example examples/s4u/actor-lifetime/s4u-actor-lifetime.cpp 
175 @example examples/s4u/actor-lifetime/s4u-actor-lifetime_d.xml 
176 @example examples/s4u/actor-migration/s4u-actor-migration.cpp
177 @example examples/s4u/actor-suspend/s4u-actor-suspend.cpp
178 @example examples/s4u/app-token-ring/s4u-app-token-ring.cpp
179 @example examples/s4u/app-masterworker/s4u-app-masterworker.cpp
180 @example examples/s4u/app-pingpong/s4u-app-pingpong.cpp
181 @example examples/s4u/io-file-remote/s4u-io-file-remote.cpp
182 @example examples/s4u/io-raw-storage/s4u-io-raw-storage.cpp
183 @example examples/s4u/mutex/s4u-mutex.cpp
184
185 */