1 S4U (Simgrid for you) is the next interface of SimGrid, expected to be released with SimGrid 4.0.
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.
8 This file follows the Doxygen syntax to be included in the
9 documentation, but it should remain readable directly.
12 @defgroup s4u_examples S4U examples
14 @brief Find the S4U example fitting your needs in the archive.
22 @section s4u_ex_basics Basics of SimGrid simulation
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.
28 - <b>Excute actors</b>.
29 @ref examples/s4u/process-create/s4u-process-create.cpp \n
30 Most processes are started from the deployment XML file.
32 - <b>Ping Pong</b>: @ref examples/s4u/app-pingpong/s4u-app-pingpong.c\n
33 It's hard to think of a simpler example: it is just sending one message back and forth.
34 The tesh file laying in the directory show how to start the simulator binary, highlighting how to pass options to
35 the simulators (as detailed in Section \ref options).
37 - <b>Token ring:</b> @ref examples/s4u/app-token-ring/s4u-app-token-ring.cpp \n
38 Shows how to implement a classical communication pattern, where a token is exchanged along a ring to reach every
41 - <b>Master Workers:</b> @ref examples/s4u/app-masterworker/s4u-app-masterworker.cpp \n
42 Another good old example, where one Master process has a bunch of task to dispatch to a set of several Worker
45 @section msg_ex_async Asynchronous communications
47 - <b>Basic asynchronous communications</b>.
48 @ref examples/s4u/async-wait/s4u-async-wait.cpp \n
49 Illustrates how to have non-blocking communications, that are
50 communications running in the background leaving the process free
51 to do something else during their completion. The main functions
52 involved are @ref simgrid::s4u::Comm::put_async and
53 @ref simgrid::s4u::Comm::wait().
55 - <b>Waiting for all communications in a set</b>.
56 @ref examples/s4u/async-waitall/s4u-async-waitall.cpp\n
57 The @ref simgrid::s4u::Comm::wait_all() function is useful when you want to block
58 until all activities in a given set have completed.
60 - <b>Waiting for the first completed communication in a set</b>.
61 @ref examples/s4u/async-waitany/s4u-async-waitany.cpp\n
62 The @ref simgrid::s4u::Comm::wait_any() function is useful when you want to block
63 until one activity of the set completes, no matter which terminates
66 @section s4u_ex_actors Acting on Actors
68 - <b>Creating actors</b>.
69 @ref examples/s4u/actor-create/s4u-actor-create.cpp \n
70 Most actors are started from the deployment XML file, but they exist other methods.
72 - <b>Daemonize actors</b>
73 @ref examples/s4u/actor-daemon/s4u-actor-daemon.cpp \n
74 Some actors may be intended to simulate daemons that run in background. This example show how to transform a regular
75 actor into a daemon that will be automatically killed once the simulation is over.
77 - <b>Suspend and Resume actors</b>.
78 @ref examples/s4u/actor-suspend/s4u-actor-suspend.cpp \n
79 Actors can be suspended and resumed during their executions
80 thanks to the @ref suspend and @ref resume methods.
83 @ref examples/s4u/actor-kill/s4u-actor-kill.cpp \n
84 Actors can forcefully stop other actors with the @ref kill method.
86 - <b>Migrating Actors</b>.
87 @ref examples/s4u/actor-migration/s4u-actor-migration.cpp \n
88 Actors can move or be moved from a host to another with the @ref migrate method.
90 @section s4u_ex_synchro Inter-Actor Synchronization
92 - <b>Mutex: </b> @ref examples/s4u/mutex/s4u-mutex.cpp \n
93 Shows how to use simgrid::s4u::Mutex synchronization objects.
95 @section s4u_ex_actions Following Workload Traces
97 This section details how to run trace-driven simulations. It is very
98 handy when you want to test an algorithm or protocol that only react
99 to external events. For example, many P2P protocols react to user
100 requests, but do nothing if there is no such event.
102 In such situations, you should write your protocol in C++, and separate
103 the workload that you want to play onto your protocol in a separate
104 text file. Declare a function handling each type of the events in your
105 trace, register them using @ref xbt_replay_action_register in your
106 main, and then run the simulation.
108 Then, you can either have one trace file containing all your events,
109 or a file per simulated process: the former may be easier to work
110 with, but the second is more efficient on very large traces. Check
111 also the tesh files in the example directories for details.
113 - <b>Communication replay</b>.
114 @ref examples/s4u/actions-comm/s4u-actions-comm.cpp \n
115 Presents a set of event handlers reproducing classical communication
116 primitives (asynchronous send/receive at the moment).
119 @ref examples/s4u/actions-storage/s4u-actions-storage.cpp \n
120 Presents a set of event handlers reproducing classical I/O
121 primitives (open, read, close).
126 @example examples/s4u/actions-comm/s4u-actions-comm.cpp
127 @example examples/s4u/actions-storage/s4u-actions-storage.cpp
128 @example examples/s4u/actor-create/s4u-actor-create.cpp
129 @example examples/s4u/actor-create/s4u-actor-create_d.xml
130 @example examples/s4u/actor-daemon/s4u-actor-daemon.cpp
131 @example examples/s4u/actor-kill/s4u-actor-kill.cpp
132 @example examples/s4u/actor-migration/s4u-actor-migration.cpp
133 @example examples/s4u/actor-suspend/s4u-actor-suspend.cpp
134 @example examples/s4u/app-token-ring/s4u-app-token-ring.cpp
135 @example examples/s4u/app-masterworker/s4u-app-masterworker.cpp
136 @example examples/s4u/app-pingpong/s4u-app-pingpong.cpp
138 @example examples/s4u/mutex/s4u-mutex.cpp