Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of framagit.org:simgrid/simgrid
[simgrid.git] / docs / source / app_s4u.rst
1 .. _S4U_doc:
2
3 The S4U Interface
4 #################
5
6 .. raw:: html
7
8    <object id="TOC" data="graphical-toc.svg" type="image/svg+xml"></object>
9    <script>
10    window.onload=function() { // Wait for the SVG to be loaded before changing it
11      var elem=document.querySelector("#TOC").contentDocument.getElementById("ActorBox")
12      elem.style="opacity:0.93999999;fill:#ff0000;fill-opacity:0.1;stroke:#000000;stroke-width:0.35277778;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1";
13    }
14    </script>
15    <br/>
16    <br/>
17
18 The S4U interface (SimGrid for you) mixes the full power of SimGrid
19 with the full power of C++. This is the preferred interface to describe
20 abstract algorithms in the domains of Cloud, P2P, HPC, IoT, and similar
21 settings.
22
23 Since v3.33 (Spring 2023), S4U is the main interface of SimGrid for algorithms.
24 It is feature complete, but may still evolve slightly in future releases.
25 When this happens, compiling your code will produce deprecation warnings for 4
26 releases (one year) before the removal of the old symbols.
27
28 .. _S4U_main_concepts:
29
30 Main Concepts
31 *************
32
33 A typical SimGrid simulation is composed of several |API_s4u_Actors|_, that
34 execute user-provided functions. The actors have to explicitly use the
35 S4U interface to express their :ref:`computation <API_s4u_Exec>`,
36 :ref:`communication <API_s4u_Comm>`, :ref:`disk usage <API_s4u_Io>`,
37 and other |API_s4u_Activities|_, so that they get reflected within the
38 simulator. These activities take place on resources such as |API_s4u_Hosts|_,
39 |API_s4u_Links|_, and |API_s4u_Disks|_. SimGrid predicts the time taken by each
40 activity and orchestrates the actors accordingly, waiting for the
41 completion of these activities.
42
43
44 When **communicating**, data is not directly sent to other actors but
45 posted onto a |API_s4u_Mailbox|_ that serves as a rendezvous point between
46 communicating actors. This means that you don't need to know who you
47 are talking to, you just put your communication `Put` request in a
48 mailbox, and it will be matched with a complementary `Get`
49 request.  Alternatively, actors can interact through **classical
50 synchronization mechanisms** such as |API_s4u_Barrier|_, |API_s4u_Semaphore|_,
51 |API_s4u_Mutex|_, and |API_s4u_ConditionVariable|_.
52
53 Each actor is located on a simulated |API_s4u_Host|_. Each host is located
54 in a |API_s4u_NetZone|_, that knows the networking path between one
55 resource to another. Each NetZone is included in another one, forming
56 a tree of NetZones which root zone contains the whole platform. The
57 actors can also be located on a |API_s4U_VirtualMachine|_ that may
58 restrict the activities it contains to a limited amount of cores.
59 Virtual machines can also be migrated between hosts.
60
61 The :ref:`simgrid::s4u::this_actor <API_s4u_this_actor>` namespace
62 provides many helper functions to simplify the code of actors.
63
64 .. rst-class:: compact-list
65
66    - **Simulation Elements**
67
68       - :ref:`class Actor <API_s4u_Actor>`: Active entities executing your application.
69       - :ref:`class Engine <API_s4u_Engine>`: Simulation engine (singleton).
70       - :ref:`class Mailbox <API_s4u_Mailbox>`: Communication rendezvous, with which actors meet each other.
71
72    - **Resources**
73
74       - :ref:`class Disk <API_s4u_Disk>`: Resource on which actors can write and read data.
75       - :ref:`class Host <API_s4u_Host>`: Actor location, providing computational power.
76       - :ref:`class Link <API_s4u_Link>`: Interconnecting hosts.
77       - :ref:`class NetZone <API_s4u_NetZone>`: Sub-region of the platform, containing resources (Hosts, Links, etc).
78       - :ref:`class VirtualMachine <API_s4u_VirtualMachine>`: Execution containers that can be moved between Hosts.
79
80    - **Activities** (:ref:`class Activity <API_s4u_Activity>`): The things that actors can do on resources.
81
82       - :ref:`class Comm <API_s4u_Comm>`: Communication activity, started on Mailboxes and consuming links.
83       - :ref:`class Exec <API_s4u_Exec>`: Computation activity, started on Host and consuming CPU resources.
84       - :ref:`class Io <API_s4u_Io>`: I/O activity, started on and consuming disks.
85
86    - **Synchronization Objects**: Classical IPC that actors can use
87
88       - :ref:`class Barrier <API_s4u_Barrier>`
89       - :ref:`class ConditionVariable <API_s4u_ConditionVariable>`
90       - :ref:`class Mutex <API_s4u_Mutex>`
91       - :ref:`class Semaphore <API_s4u_Semaphore>`
92
93 .. |API_s4u_Actors| replace:: **Actors**
94 .. _API_s4u_Actors: #api-s4u-actor
95
96 .. |API_s4u_Activities| replace:: **Activities**
97 .. _API_s4u_Activities: #api-s4u-activity
98
99 .. |API_s4u_Tasks| replace:: **Tasks**
100 .. _API_s4u_Tasks: #api-s4u-task
101
102 .. |API_s4u_Hosts| replace:: **Hosts**
103 .. _API_s4u_Hosts: #api-s4u-host
104
105 .. |API_s4u_Links| replace:: **Links**
106 .. _API_s4u_Links: #api-s4u-link
107
108 .. |API_s4u_Disks| replace:: **Disks**
109 .. _API_s4u_Disks: #api-s4u-disk
110
111 .. |API_s4u_VirtualMachine| replace:: **VirtualMachines**
112
113 .. |API_s4u_Host| replace:: **Host**
114
115 .. |API_s4u_Mailbox| replace:: **Mailbox**
116
117 .. |API_s4u_Mailboxes| replace:: **Mailboxes**
118 .. _API_s4u_Mailboxes: #s4u-mailbox
119
120 .. |API_s4u_NetZone| replace:: **NetZone**
121
122 .. |API_s4u_Barrier| replace:: **Barrier**
123
124 .. |API_s4u_Semaphore| replace:: **Semaphore**
125
126 .. |API_s4u_ConditionVariable| replace:: **ConditionVariable**
127
128 .. |API_s4u_Mutex| replace:: **Mutex**
129
130 .. _s4u_Activities:
131
132 Activities
133 **********
134
135 Activities represent the actions that consume a resource, such as a
136 :ref:`Comm <API_s4u_Comm>` that consumes the *transmitting power* of
137 :ref:`Link <API_s4u_Link>` resources, or an :ref:`Exec <API_s4u_Exec>`
138 that consumes the *computing power* of :ref:`Host <API_s4u_Host>` resources.
139 See also the :ref:`full API <API_s4u_Activity>` below.
140
141 =======================
142 Asynchronous Activities
143 =======================
144
145 Every activity can be either **blocking** or **asynchronous**. For
146 example, :cpp:func:`s4u::Mailbox::put() <simgrid::s4u::Mailbox::put>`
147 and :cpp:func:`s4u::Mailbox::get() <simgrid::s4u::Mailbox::get>`
148 create blocking communications: the actor is blocked until the
149 completion of that communication. Asynchronous communications do not
150 block the actor during their execution but progress on their own.
151
152 Once your asynchronous activity is started, you can test for its
153 completion using :cpp:func:`s4u::Activity::test() <simgrid::s4u::Activity::test>`.
154 This function returns ``true`` if the activity is completed already.
155 You can also use :cpp:func:`s4u::Activity::wait() <simgrid::s4u::Activity::wait>`
156 to block until the completion of the activity. To wait for at most a given amount of time,
157 use  :cpp:func:`s4u::Activity::wait_for() <simgrid::s4u::Activity::wait_for>`.
158 Finally, to wait at most until a specified time limit, use
159 :cpp:func:`s4u::Activity::wait_until() <simgrid::s4u::Activity::wait_until>`.
160
161 Every kind of activity can be asynchronous.
162 :ref:`s4u::CommPtr <API_s4u_Comm>` are created with :cpp:func:`s4u::Mailbox::put_async() <simgrid::s4u::Mailbox::put_async>` and
163 :cpp:func:`s4u::Mailbox::get_async() <simgrid::s4u::Mailbox::get_async>`;
164 :ref:`s4u::IoPtr <API_s4u_Io>` are created with :cpp:func:`s4u::Disk::read_async() <simgrid::s4u::Disk::read_async>` and
165 :cpp:func:`s4u::Disk::write_async() <simgrid::s4u::Disk::write_async>`; and
166 :ref:`s4u::ExecPtr <API_s4u_Exec>` are created with
167 :cpp:func:`s4u::Host::exec_async() <simgrid::s4u::Host::exec_async>`.
168 In the future, it will become possible to have asynchronous IPC such as asynchronous mutex lock requests.
169
170 The following example shows how to have several concurrent
171 communications ongoing.  First, you have to declare a vector in which
172 we will store the ongoing communications. It is also useful to have a
173 vector of mailboxes.
174
175 .. literalinclude:: ../../examples/cpp/comm-waitall/s4u-comm-waitall.cpp
176    :language: c++
177    :start-after: init-begin
178    :end-before: init-end
179    :dedent: 2
180
181 Then, you start all the communications that should occur concurrently with
182 :cpp:func:`s4u::Mailbox::put_async() <simgrid::s4u::Mailbox::put_async>`.
183 Finally, the actor waits for the completion of all of them at once
184 with :cpp:func:`s4u::Comm::wait_all() <simgrid::s4u::Comm::wait_all>`.
185
186 .. literalinclude:: ../../examples/cpp/comm-waitall/s4u-comm-waitall.cpp
187    :language: c++
188    :start-after: put-begin
189    :end-before: put-end
190    :dedent: 2
191
192 =====================
193 Activities Life Cycle
194 =====================
195
196 Sometimes, you want to change the setting of an activity before it even starts.
197
198 .. todo:: write this section
199
200 =====================
201 Repeatable Activities
202 =====================
203
204 In order to simulate the execution of Dataflow applications, we introduced the
205 concept of |API_s4u_Tasks|, that can be seen as repeatable activities. A Dataflow
206 is defined as a graph of |API_s4u_Tasks| through which circulate Tokens. Tokens
207 can carry any user-defined data, using the same internal mechanisms as for the
208 other simulated objects. Each Task has to receive a token from each of its
209 predecessor to fire a new instance of a |API_s4u_Comm|, |API_s4u_Exec|, or
210 |API_s4u_Io| activity. On completion of this activity, the Task propagates tokens
211 to its successors, and waits for the next set of tokens to arrive.
212
213 To initiate the execution of a Dataflow, it is possible to some make
214 |API_s4u_Tasks| fire one or more activities without waiting for any token with the
215 :cpp:func:`s4u::Task::enqueue_firings() <simgrid::s4u::Task::enqueue_firings>`
216 function.
217
218 The parameters and successors of a Task can be redefined at runtime by attaching
219 callbacks to the
220 :cpp:func:`s4u::Task::on_this_start <simgrid::s4u::Task::on_this_start>`
221 and
222 :cpp:func:`s4u::Task::on_this_completion <simgrid::s4u::Task::on_this_completion>`
223 signals.
224
225
226 .. _s4u_mailbox:
227
228 Mailboxes
229 *********
230
231 Please also refer to the :ref:`API reference for s4u::Mailbox
232 <API_s4u_Mailbox>`.
233
234 ===================
235 What are Mailboxes?
236 ===================
237
238 |API_s4u_Mailboxes|_ are rendezvous points for network communications,
239 similar to URLs on which you could post and retrieve data. Actually,
240 the mailboxes are not involved in the communication once it starts,
241 but only to find the contact with which you want to communicate.
242
243 They are similar to many common things: The phone number, which allows
244 the caller to find the receiver. The Twitter hashtag, which helps
245 senders and receivers to find each other. In TCP, the pair
246 ``{host name, host port}`` to which you can connect to find your peer.
247 In HTTP, URLs through which the clients can connect to the servers.
248 In ZeroMQ, the queues are used to match senders and receivers.
249
250 One big difference with most of these systems is that no actor is the
251 exclusive owner of a mailbox, neither in sending nor in receiving.
252 Many actors can send into and/or receive from the same mailbox.  TCP
253 socket ports for example are shared on the sender side but exclusive
254 on the receiver side (only one process can receive from a given socket
255 at a given point of time).
256
257 A big difference with TCP sockets or MPI communications is that
258 communications do not start right away after a
259 :cpp:func:`Mailbox::put() <simgrid::s4u::Mailbox::put>`, but wait
260 for the corresponding :cpp:func:`Mailbox::get() <simgrid::s4u::Mailbox::get>`.
261 You can change this by :ref:`declaring a receiving actor <s4u_receiving_actor>`.
262
263 A big difference with Twitter hashtags is that SimGrid does not
264 offer easy support to broadcast a given message to many
265 receivers. So that would be like a Twitter tag where each message
266 is consumed by the first receiver.
267
268 A big difference with the ZeroMQ queues is that you cannot filter
269 on the data you want to get from the mailbox. To model such settings
270 in SimGrid, you'd have one mailbox per potential topic, and subscribe
271 to each topic individually with a
272 :cpp:func:`get_async() <simgrid::s4u::Mailbox::get_async>` on each mailbox.
273 Then, use :cpp:func:`Comm::wait_any() <simgrid::s4u::Comm::wait_any>`
274 to get the first message on any of the mailboxes you are subscribed to.
275
276 The mailboxes are not located on the network, and you can access
277 them without any latency. The network delays are only related to the
278 location of the sender and receiver once the match between them is
279 done on the mailbox. This is just like the phone number that you
280 can use locally, and the geographical distance only comes into play
281 once you start the communication by dialing this number.
282
283 =====================
284 How to use Mailboxes?
285 =====================
286
287 You can retrieve any existing mailbox from its name (which is a
288 unique string, just like a Twitter tag). This results in a
289 versatile tool that can be used to build many different
290 situations.
291
292 To model classical socket communications, use "hostname:port" as
293 mailbox names, and make sure that only one actor reads into a given
294 mailbox. This does not make it easy to build a perfectly realistic
295 model of the TCP sockets, but in most cases, this system is too
296 cumbersome for your simulations anyway. You probably want something
297 simpler, that turns out to be easy to build with the mailboxes.
298
299 Many SimGrid examples use a sort of yellow page system where the
300 mailbox names are the name of the service (such as "worker",
301 "master", or "reducer"). That way, you don't have to know where your
302 peer is located to contact it. You don't even need its name. Its
303 function is enough for that. This also gives you some sort of load
304 balancing for free if more than one actor pulls from the mailbox:
305 the first actor that can deal with the request will handle it.
306
307 =========================================
308 How are put() and get() requests matched?
309 =========================================
310
311 The matching algorithm simple: first come, first serve. When a new
312 send arrives, it matches the oldest enqueued receive. If no receive is
313 currently enqueued, then the incoming send is enqueued. As you can
314 see, the mailbox cannot contain both send and receive requests: all
315 enqueued requests must be of the same sort.
316
317 .. _s4u_receiving_actor:
318
319 ===========================
320 Declaring a Receiving Actor
321 ===========================
322
323 The last twist is that by default in the simulator, the data starts
324 to be exchanged only when both the sender and the receiver are
325 announced (it waits until both :cpp:func:`put() <simgrid::s4u::Mailbox::put()>`
326 and :cpp:func:`get() <simgrid::s4u::Mailbox::get()>` are posted).
327 In TCP, since you establish connections beforehand, the data starts to
328 flow as soon as the sender posts it, even if the receiver did not post
329 its :cpp:func:`put() <simgrid::s4u::Mailbox::put()>` yet.
330
331 To model this in SimGrid, you can declare a specific receiver to a
332 given mailbox (with the function
333 :cpp:func:`set_receiver() <simgrid::s4u::Mailbox::set_receiver()>`).
334 That way, any :cpp:func:`put() <simgrid::s4u::Mailbox::put()>`
335 posted to that mailbox will start as soon as possible, and the data
336 will already be there on the receiver host when the receiver actor
337 posts its :cpp:func:`get() <simgrid::s4u::Mailbox::get()>`
338
339 Note that being permanent receivers of a mailbox prevents actors to be
340 garbage-collected. If your simulation creates many short-lived actors
341 that are marked as permanent receiver, you should call
342 ``mailbox->set_receiver(nullptr)`` by the end of the actors so that their
343 memory gets properly reclaimed. This call should be at the end of the
344 actor's function, not in an on_exit callback.
345
346 ===============================
347 Communicating without Mailboxes
348 ===============================
349
350 Sometimes you don't want to simulate communications between actors as
351 allowed by mailboxes, but you want to create a direct communication
352 between two arbitrary hosts. This can arise when you write a
353 high-level model of a centralized scheduler, or when you model direct
354 communications such as one-sided communications in MPI or remote
355 memory direct access in PGAS.
356
357 For that, :cpp:func:`Comm::sendto() <simgrid::s4u::Comm::sendto()>`
358 simulates a direct communication between the two specified hosts. No
359 mailbox is used, and there is no rendezvous between actors. You can
360 freely mix such direct communications and rendezvous-based
361 communications. Alternatively, :cpp:func:`Comm::sendto_init()
362 <simgrid::s4u::Comm::sendto_init()>` and
363 :cpp:func:`Comm::sendto_async() <simgrid::s4u::Comm::sendto_async()>`
364 create asynchronous direct communications.
365
366 .. _s4u_raii:
367
368 Memory Management
369 *****************
370
371 For sake of simplicity, we use `RAII
372 <https://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization>`_
373 for many classes in S4U. This is an idiom where resources are automatically
374 managed through the context. Provided that you never manipulate
375 objects of type Foo directly but always FooPtr references (which are
376 defined as `boost::intrusive_ptr
377 <http://www.boost.org/doc/libs/1_61_0/libs/smart_ptr/intrusive_ptr.html>`_
378 <Foo>), you will never have to explicitly release the resource that
379 you use nor to free the memory of unused objects.
380 Here is a little example:
381
382 .. code-block:: cpp
383
384    void myFunc()
385    {
386      simgrid::s4u::MutexPtr mutex = simgrid::s4u::Mutex::create(); // Too bad we cannot use `new`
387
388      mutex->lock();   // use the mutex as a simple reference
389      //  bla bla
390      mutex->unlock();
391
392    } // The mutex gets automatically freed because the only existing reference gets out of scope
393
394 Note that Mailboxes, Hosts, and Links are not handled through smart
395 pointers (yet?). This means that it is currently impossible to destroy a
396 mailbox or a link. You can still destroy a host (but probably
397 shouldn't), using :cpp:func:`simgrid::s4u::Host::destroy`.
398
399 API Reference
400 *************
401
402 .. _API_s4u_simulation_object:
403
404 ==================
405 Simulation objects
406 ==================
407
408 .. _API_s4u_Actor:
409
410 ==============
411 ⁣  class Actor
412 ==============
413
414 .. tabs::
415
416    .. group-tab:: C++
417
418       .. doxygenclass:: simgrid::s4u::Actor
419
420       .. doxygentypedef:: aid_t
421
422
423    .. group-tab:: Python
424
425       .. autoclass:: simgrid.Actor
426
427 Basic management
428 ----------------
429
430 .. tabs::
431
432    .. group-tab:: C++
433
434       .. code:: C++
435
436          #include <simgrid/s4u/Actor.hpp>
437
438       .. doxygentypedef:: ActorPtr
439
440    .. group-tab:: Python
441
442       .. code:: Python
443
444          from simgrid import Actor
445
446    .. group-tab:: C
447
448       .. code:: C
449
450          #include <simgrid/actor.h>
451
452       .. doxygentypedef:: sg_actor_t
453       .. doxygentypedef:: const_sg_actor_t
454       .. doxygenfunction:: sg_actor_ref
455       .. doxygenfunction:: sg_actor_unref
456
457
458 Creating actors
459 ---------------
460
461 See also :ref:`the relevant example <s4u_ex_actors_create>`.
462
463 .. tabs::
464
465    .. group-tab:: C++
466
467       .. doxygenfunction:: simgrid::s4u::Actor::create(const std::string &name, s4u::Host *host, const std::function< void()> &code)
468       .. doxygenfunction:: simgrid::s4u::Actor::create(const std::string &name, s4u::Host *host, F code)
469       .. doxygenfunction:: simgrid::s4u::Actor::create(const std::string &name, s4u::Host *host, F code, Args... args)
470       .. doxygenfunction:: simgrid::s4u::Actor::create(const std::string &name, s4u::Host *host, const std::string &function, std::vector< std::string > args)
471
472       .. doxygenfunction:: simgrid::s4u::Actor::init(const std::string &name, s4u::Host *host)
473       .. doxygenfunction:: simgrid::s4u::Actor::start(const std::function< void()> &code)
474       .. doxygenfunction:: simgrid::s4u::Actor::set_stacksize
475
476    .. group-tab:: Python
477
478       .. automethod:: simgrid.Actor.create
479
480    .. group-tab:: C
481
482       .. doxygenfunction:: sg_actor_create(const char *name, sg_host_t host, xbt_main_func_t code, int argc, char *const *argv)
483       .. doxygenfunction:: sg_actor_init(const char *name, sg_host_t host)
484       .. doxygenfunction:: sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, char *const *argv)
485       .. doxygenfunction:: sg_actor_set_stacksize
486
487       .. doxygenfunction:: sg_actor_attach(const char *name, void *data, sg_host_t host, xbt_dict_t properties)
488       .. doxygenfunction:: sg_actor_detach()
489
490 Retrieving actors
491 -----------------
492
493 .. tabs::
494
495    .. group-tab:: C++
496
497       .. doxygenfunction:: simgrid::s4u::Actor::by_pid(aid_t pid)
498       .. doxygenfunction:: simgrid::s4u::Actor::self()
499
500    .. group-tab:: Python
501
502       .. automethod:: simgrid.Actor.by_pid
503       .. automethod:: simgrid.Actor.self
504
505    .. group-tab:: C
506
507       .. doxygenfunction:: sg_actor_by_pid(aid_t pid)
508       .. doxygenfunction:: sg_actor_self()
509       .. doxygenfunction:: sg_actor_list()
510
511 Querying info
512 -------------
513
514 .. tabs::
515
516    .. group-tab:: C++
517
518       .. doxygenfunction:: simgrid::s4u::Actor::get_cname
519       .. doxygenfunction:: simgrid::s4u::Actor::get_name
520       .. doxygenfunction:: simgrid::s4u::Actor::get_pid
521       .. doxygenfunction:: simgrid::s4u::Actor::get_ppid
522       .. doxygenfunction:: simgrid::s4u::Actor::get_properties() const
523       .. doxygenfunction:: simgrid::s4u::Actor::get_property(const std::string &key) const
524       .. doxygenfunction:: simgrid::s4u::Actor::set_property(const std::string &key, const std::string &value)
525
526       .. doxygenfunction:: simgrid::s4u::Actor::get_host
527       .. doxygenfunction:: simgrid::s4u::Actor::set_host
528
529       .. doxygenfunction:: simgrid::s4u::Actor::get_refcount
530       .. doxygenfunction:: simgrid::s4u::Actor::get_impl
531
532    .. group-tab:: Python
533
534       .. autoattribute:: simgrid.Actor.name
535       .. autoattribute:: simgrid.Actor.host
536       .. autoattribute:: simgrid.Actor.pid
537       .. autoattribute:: simgrid.Actor.ppid
538
539    .. group-tab:: C
540
541       .. doxygenfunction:: sg_actor_get_name(const_sg_actor_t actor)
542       .. doxygenfunction:: sg_actor_get_pid(const_sg_actor_t actor)
543       .. doxygenfunction:: sg_actor_get_ppid(const_sg_actor_t actor)
544       .. doxygenfunction:: sg_actor_get_properties(const_sg_actor_t actor)
545       .. doxygenfunction:: sg_actor_get_property_value(const_sg_actor_t actor, const char *name)
546
547       .. doxygenfunction:: sg_actor_get_host(const_sg_actor_t actor)
548       .. doxygenfunction:: sg_actor_set_host(sg_actor_t actor, sg_host_t host)
549
550       .. doxygenfunction:: sg_actor_get_data(const_sg_actor_t actor)
551       .. doxygenfunction:: sg_actor_set_data(sg_actor_t actor, void *userdata)
552
553 Suspending and resuming actors
554 ------------------------------
555
556 .. tabs::
557
558    .. group-tab:: C++
559
560       .. doxygenfunction:: simgrid::s4u::Actor::suspend()
561       .. doxygenfunction:: simgrid::s4u::Actor::resume()
562       .. doxygenfunction:: simgrid::s4u::Actor::is_suspended
563
564    .. group-tab:: Python
565
566       .. automethod:: simgrid.Actor.resume
567       .. automethod:: simgrid.Actor.suspend
568       .. automethod:: simgrid.Actor.is_suspended
569
570    .. group-tab:: C
571
572       .. doxygenfunction:: sg_actor_suspend(sg_actor_t actor)
573       .. doxygenfunction:: sg_actor_resume(sg_actor_t actor)
574       .. doxygenfunction:: sg_actor_is_suspended(const_sg_actor_t actor)
575
576 Specifying when actors should terminate
577 ---------------------------------------
578
579 .. tabs::
580
581    .. group-tab:: C++
582
583       .. doxygenfunction:: simgrid::s4u::Actor::kill()
584       .. doxygenfunction:: simgrid::s4u::Actor::kill_all()
585       .. doxygenfunction:: simgrid::s4u::Actor::set_kill_time(double time)
586       .. doxygenfunction:: simgrid::s4u::Actor::get_kill_time
587
588       .. doxygenfunction:: simgrid::s4u::Actor::restart()
589       .. doxygenfunction:: simgrid::s4u::Actor::daemonize()
590       .. doxygenfunction:: simgrid::s4u::Actor::is_daemon
591
592    .. group-tab:: Python
593
594       .. automethod:: simgrid.Actor.kill
595       .. automethod:: simgrid.Actor.kill_all
596
597       .. automethod:: simgrid.Actor.daemonize
598       .. automethod:: simgrid.Actor.is_daemon
599
600    .. group-tab:: C
601
602       .. doxygenfunction:: sg_actor_kill(sg_actor_t actor)
603       .. doxygenfunction:: sg_actor_kill_all()
604       .. doxygenfunction:: sg_actor_set_kill_time(sg_actor_t actor, double kill_time)
605
606       .. doxygenfunction:: sg_actor_restart(sg_actor_t actor)
607       .. doxygenfunction:: sg_actor_daemonize(sg_actor_t actor)
608       .. doxygenfunction:: sg_actor_is_daemon
609
610 .. _API_s4u_Actor_end:
611
612 Reacting to the end of actors
613 -----------------------------
614
615 .. tabs::
616
617    .. group-tab:: C++
618
619       .. doxygenfunction:: simgrid::s4u::Actor::on_exit
620       .. doxygenfunction:: simgrid::s4u::Actor::join() const
621       .. doxygenfunction:: simgrid::s4u::Actor::join(double timeout) const
622       .. doxygenfunction:: simgrid::s4u::Actor::set_auto_restart(bool autorestart)
623       .. doxygenfunction:: simgrid::s4u::Actor::get_restart_count
624
625    .. group-tab:: Python
626
627       .. automethod:: simgrid.Actor.join
628
629    .. group-tab:: C
630
631       .. doxygenfunction:: sg_actor_on_exit
632       .. doxygenfunction:: sg_actor_join(const_sg_actor_t actor, double timeout)
633       .. doxygenfunction:: sg_actor_set_auto_restart(sg_actor_t actor, int auto_restart)
634
635 Signals
636 -------
637
638 .. tabs::
639
640    .. group-tab:: C++
641
642       .. doxygenfunction:: simgrid::s4u::Actor::on_creation_cb
643       .. doxygenfunction:: simgrid::s4u::Actor::on_suspend_cb
644       .. doxygenfunction:: simgrid::s4u::Actor::on_this_suspend_cb
645       .. doxygenfunction:: simgrid::s4u::Actor::on_host_change_cb
646       .. doxygenfunction:: simgrid::s4u::Actor::on_this_host_change_cb
647       .. doxygenfunction:: simgrid::s4u::Actor::on_resume_cb
648       .. doxygenfunction:: simgrid::s4u::Actor::on_this_resume_cb
649       .. doxygenfunction:: simgrid::s4u::Actor::on_sleep_cb
650       .. doxygenfunction:: simgrid::s4u::Actor::on_this_sleep_cb
651       .. doxygenfunction:: simgrid::s4u::Actor::on_wake_up_cb
652       .. doxygenfunction:: simgrid::s4u::Actor::on_this_wake_up_cb
653       .. doxygenfunction:: simgrid::s4u::Actor::on_termination_cb
654       .. doxygenfunction:: simgrid::s4u::Actor::on_this_termination_cb
655       .. doxygenfunction:: simgrid::s4u::Actor::on_destruction_cb
656       .. doxygenfunction:: simgrid::s4u::Actor::on_this_destruction_cb
657
658 .. _API_s4u_this_actor:
659
660 ====================
661 ⁣  The current actor
662 ====================
663
664 These functions can be used in your user code to interact with the actor
665 currently running (the one retrieved with :cpp:func:`simgrid::s4u::Actor::self`).
666 Using these functions can greatly improve the code readability.
667
668 Querying info
669 -------------
670
671 .. tabs::
672
673    .. group-tab:: C++
674
675       .. doxygenfunction:: simgrid::s4u::this_actor::get_cname()
676       .. doxygenfunction:: simgrid::s4u::this_actor::get_name()
677       .. doxygenfunction:: simgrid::s4u::this_actor::get_pid()
678       .. doxygenfunction:: simgrid::s4u::this_actor::get_ppid()
679       .. doxygenfunction:: simgrid::s4u::this_actor::is_maestro()
680
681       .. doxygenfunction:: simgrid::s4u::this_actor::get_host()
682       .. doxygenfunction:: simgrid::s4u::this_actor::set_host(Host *new_host)
683
684    .. group-tab:: Python
685
686       .. autofunction:: simgrid.this_actor.get_host
687       .. autofunction:: simgrid.this_actor.set_host
688
689       .. autofunction:: simgrid.this_actor.get_pid
690       .. autofunction:: simgrid.this_actor.get_ppid
691
692    .. group-tab:: C
693
694       .. doxygenfunction:: sg_actor_self_get_data()
695       .. doxygenfunction:: sg_actor_self_set_data(void *data)
696       .. doxygenfunction:: sg_actor_self_get_name()
697       .. doxygenfunction:: sg_actor_self_get_pid()
698       .. doxygenfunction:: sg_actor_self_get_ppid()
699       .. doxygenfunction:: sg_host_self()
700       .. doxygenfunction:: sg_host_self_get_name()
701
702 Suspending and resuming
703 -----------------------
704
705 .. tabs::
706
707    .. group-tab:: C++
708
709       .. doxygenfunction:: simgrid::s4u::this_actor::suspend()
710       .. doxygenfunction:: simgrid::s4u::this_actor::yield()
711
712    .. group-tab:: Python
713
714       .. autofunction:: simgrid.this_actor.suspend
715       .. autofunction:: simgrid.this_actor.yield_
716
717    .. group-tab:: C
718
719       .. doxygenfunction:: sg_actor_yield()
720
721 Logging messages
722 ----------------
723
724 .. tabs::
725
726    .. group-tab:: C++
727
728       Please refer to :ref:`the relevant documentation <logging_prog>`.
729
730    .. group-tab:: Python
731
732        .. autofunction:: simgrid.this_actor.debug
733        .. autofunction:: simgrid.this_actor.info
734        .. autofunction:: simgrid.this_actor.warning
735        .. autofunction:: simgrid.this_actor.error
736
737 Sleeping
738 --------
739
740 .. tabs::
741
742    .. group-tab:: C++
743
744       .. doxygenfunction:: simgrid::s4u::this_actor::sleep_for(double duration)
745       .. doxygenfunction:: simgrid::s4u::this_actor::sleep_for(std::chrono::duration< Rep, Period > duration)
746       .. doxygenfunction:: simgrid::s4u::this_actor::sleep_until(const SimulationTimePoint< Duration > &wakeup_time)
747       .. doxygenfunction:: simgrid::s4u::this_actor::sleep_until(double wakeup_time)
748
749    .. group-tab:: Python
750
751       .. autofunction:: simgrid.this_actor.sleep_for
752       .. autofunction:: simgrid.this_actor.sleep_until
753
754    .. group-tab:: C
755
756       .. doxygenfunction:: sg_actor_sleep_for(double duration)
757
758 Simulating executions
759 ---------------------
760
761 Simulate the execution of some code on this actor. You can either simulate
762 parallel or sequential code and you can either block upon the termination of
763 the execution, or start an asynchronous activity.
764
765 .. tabs::
766
767    .. group-tab:: C++
768
769       .. doxygenfunction:: simgrid::s4u::this_actor::exec_async
770       .. doxygenfunction:: simgrid::s4u::this_actor::exec_init(const std::vector< s4u::Host * > &hosts, const std::vector< double > &flops_amounts, const std::vector< double > &bytes_amounts)
771       .. doxygenfunction:: simgrid::s4u::this_actor::exec_init(double flops_amounts)
772       .. doxygenfunction:: simgrid::s4u::this_actor::execute(double flop)
773       .. doxygenfunction:: simgrid::s4u::this_actor::execute(double flop, double priority)
774       .. doxygenfunction:: simgrid::s4u::this_actor::parallel_execute(const std::vector< s4u::Host * > &hosts, const std::vector< double > &flops_amounts, const std::vector< double > &bytes_amounts)
775       .. doxygenfunction:: simgrid::s4u::this_actor::thread_execute
776
777    .. group-tab:: Python
778
779       .. autofunction:: simgrid.this_actor.exec_async
780       .. autofunction:: simgrid.this_actor.exec_init
781       .. autofunction:: simgrid.this_actor.execute
782
783    .. group-tab:: C
784
785       .. doxygenfunction:: sg_actor_execute(double flops)
786       .. doxygenfunction:: sg_actor_execute_with_priority(double flops, double priority)
787       .. doxygenfunction:: sg_actor_exec_init(double computation_amount)
788       .. doxygenfunction:: sg_actor_exec_async(double computation_amount)
789       .. doxygenfunction:: sg_actor_parallel_exec_init(int host_nb, const sg_host_t* host_list, double* flops_amount, double* bytes_amount);
790
791 Exiting
792 -------
793
794 .. tabs::
795
796    .. group-tab:: C++
797
798       .. doxygenfunction:: simgrid::s4u::this_actor::exit()
799       .. doxygenfunction:: simgrid::s4u::this_actor::on_exit(const std::function< void(bool)> &fun)
800
801    .. group-tab:: Python
802
803       .. autofunction:: simgrid.this_actor.exit
804       .. autofunction:: simgrid.this_actor.on_exit
805
806    .. group-tab:: c
807
808       See also :cpp:func:`sg_actor_on_exit`.
809
810       .. doxygenfunction:: sg_actor_exit
811
812 .. _API_s4u_Engine:
813
814 ====================
815 ⁣  Simulation Engine
816 ====================
817
818 .. tabs::
819
820    .. group-tab:: C++
821
822       .. doxygenclass:: simgrid::s4u::Engine
823
824    .. group-tab:: Python
825
826       .. autoclass:: simgrid.Engine
827
828 Engin initialization
829 --------------------
830
831 .. tabs::
832
833    .. group-tab:: C++
834
835       .. doxygenfunction:: simgrid::s4u::Engine::Engine(int *argc, char **argv)
836       .. doxygenfunction:: simgrid::s4u::Engine::is_initialized()
837       .. doxygenfunction:: simgrid::s4u::Engine::shutdown()
838       .. doxygenfunction:: simgrid::s4u::Engine::get_instance()
839
840    .. group-tab:: Python
841
842        .. automethod:: simgrid.Engine.__init__
843        .. autoattribute:: simgrid.Engine.instance
844
845    .. group-tab:: C
846
847       .. doxygenfunction:: simgrid_init
848
849 Simulation setup
850 ----------------
851
852 .. tabs::
853
854    .. group-tab:: C++
855
856       .. doxygenfunction:: simgrid::s4u::Engine::set_config(const std::string &str)
857       .. doxygenfunction:: simgrid::s4u::Engine::set_config(const std::string &name, bool value)
858       .. doxygenfunction:: simgrid::s4u::Engine::set_config(const std::string &name, double value)
859       .. doxygenfunction:: simgrid::s4u::Engine::set_config(const std::string &name, int value)
860       .. doxygenfunction:: simgrid::s4u::Engine::set_config(const std::string &name, const std::string &value)
861
862       .. doxygenfunction:: simgrid::s4u::Engine::load_deployment
863       .. doxygenfunction:: simgrid::s4u::Engine::load_platform
864       .. doxygenfunction:: simgrid::s4u::Engine::flatify_platform
865       .. doxygenfunction:: simgrid::s4u::Engine::register_actor(const std::string &name)
866       .. doxygenfunction:: simgrid::s4u::Engine::register_actor(const std::string &name, F code)
867       .. doxygenfunction:: simgrid::s4u::Engine::register_default(const std::function< void(int, char **)> &code)
868       .. doxygenfunction:: simgrid::s4u::Engine::register_default(const kernel::actor::ActorCodeFactory &factory)
869
870       .. doxygenfunction:: simgrid::s4u::Engine::register_function(const std::string &name, const std::function< void(int, char **)> &code)
871       .. doxygenfunction:: simgrid::s4u::Engine::register_function(const std::string &name, const std::function< void(std::vector< std::string >)> &code)
872       .. doxygenfunction:: simgrid::s4u::Engine::register_function(const std::string &name, const kernel::actor::ActorCodeFactory &factory)
873
874    .. group-tab:: Python
875
876        .. automethod:: simgrid.Engine.load_deployment
877        .. automethod:: simgrid.Engine.load_platform
878        .. automethod:: simgrid.Engine.register_actor
879
880    .. group-tab:: C
881
882       .. doxygenfunction:: simgrid_load_deployment
883       .. doxygenfunction:: simgrid_load_platform
884       .. doxygenfunction:: simgrid_register_default
885       .. doxygenfunction:: simgrid_register_function
886
887
888 Run the simulation
889 ------------------
890
891 .. tabs::
892
893    .. group-tab:: C++
894
895       .. doxygenfunction:: simgrid::s4u::Engine::get_clock()
896       .. doxygenfunction:: simgrid::s4u::Engine::run
897       .. doxygenfunction:: simgrid::s4u::Engine::run_until
898
899    .. group-tab:: Python
900
901       .. autoattribute:: simgrid.Engine.clock
902       .. automethod:: simgrid.Engine.run
903       .. automethod:: simgrid.Engine.run_until
904
905    .. group-tab:: C
906
907       .. doxygenfunction:: simgrid_get_clock
908       .. doxygenfunction:: simgrid_run
909       .. doxygenfunction:: simgrid_run_until
910
911 Retrieving actors
912 -----------------
913
914 .. tabs::
915
916    .. group-tab:: C++
917
918       .. doxygenfunction:: simgrid::s4u::Engine::get_actor_count
919       .. doxygenfunction:: simgrid::s4u::Engine::get_all_actors
920       .. doxygenfunction:: simgrid::s4u::Engine::get_filtered_actors
921
922    .. group-tab:: C
923
924       .. doxygenfunction:: sg_actor_count()
925
926 Retrieving hosts
927 ----------------
928
929 .. tabs::
930
931    .. group-tab:: C++
932
933       .. doxygenfunction:: simgrid::s4u::Engine::get_all_hosts
934       .. doxygenfunction:: simgrid::s4u::Engine::get_host_count
935       .. doxygenfunction:: simgrid::s4u::Engine::get_filtered_hosts
936       .. doxygenfunction:: simgrid::s4u::Engine::host_by_name
937       .. doxygenfunction:: simgrid::s4u::Engine::host_by_name_or_null
938
939    .. group-tab:: Python
940
941       .. autoattribute:: simgrid.Engine.all_hosts
942       .. automethod:: simgrid.Engine.host_by_name
943
944    .. group-tab:: C
945
946       See also :cpp:func:`sg_host_list` and :cpp:func:`sg_host_count`.
947
948 Retrieving links
949 ----------------
950
951 .. tabs::
952
953    .. group-tab:: C++
954
955       .. doxygenfunction:: simgrid::s4u::Engine::get_all_links
956       .. doxygenfunction:: simgrid::s4u::Engine::get_link_count
957       .. doxygenfunction:: simgrid::s4u::Engine::get_filtered_links
958       .. doxygenfunction:: simgrid::s4u::Engine::link_by_name
959       .. doxygenfunction:: simgrid::s4u::Engine::link_by_name_or_null
960
961    .. group-tab:: Python
962
963       .. autoattribute:: simgrid.Engine.all_links
964
965 Interacting with the routing
966 ----------------------------
967
968 .. tabs::
969
970    .. group-tab:: C++
971
972       .. doxygenfunction:: simgrid::s4u::Engine::get_all_netpoints
973       .. doxygenfunction:: simgrid::s4u::Engine::get_filtered_netzones
974       .. doxygenfunction:: simgrid::s4u::Engine::get_netzone_root
975       .. doxygenfunction:: simgrid::s4u::Engine::netpoint_by_name_or_null
976       .. doxygenfunction:: simgrid::s4u::Engine::netzone_by_name_or_null
977
978    .. group-tab:: Python
979
980       .. autoattribute:: simgrid.Engine.all_netpoints
981       .. autoattribute:: simgrid.Engine.netzone_root
982       .. automethod:: simgrid.Engine.netpoint_by_name
983       .. automethod:: simgrid.Engine.netzone_by_name
984
985 Signals
986 -------
987
988 .. tabs::
989
990    .. group-tab:: C++
991
992       .. doxygenfunction:: simgrid::s4u::Engine::on_deadlock_cb
993       .. doxygenfunction:: simgrid::s4u::Engine::on_platform_created_cb
994       .. doxygenfunction:: simgrid::s4u::Engine::on_platform_creation_cb
995       .. doxygenfunction:: simgrid::s4u::Engine::on_simulation_start_cb
996       .. doxygenfunction:: simgrid::s4u::Engine::on_simulation_end_cb
997       .. doxygenfunction:: simgrid::s4u::Engine::on_time_advance_cb
998
999 .. _API_s4u_Mailbox:
1000
1001 ================
1002 ⁣  class Mailbox
1003 ================
1004
1005 .. tabs::
1006
1007    .. group-tab:: C++
1008
1009       .. doxygenclass:: simgrid::s4u::Mailbox
1010
1011    .. group-tab:: Python
1012
1013       .. autoclass:: simgrid.Mailbox
1014
1015 Please also refer to the :ref:`full doc on s4u::Mailbox <s4u_mailbox>`.
1016
1017 Basic management
1018 ----------------
1019
1020 .. tabs::
1021
1022    .. group-tab:: C++
1023
1024       .. code-block:: C++
1025
1026          #include <simgrid/s4u/Mailbox.hpp>
1027
1028       Note that there is no MailboxPtr type and that you cannot use the RAII
1029       idiom on mailboxes because they are internal objects to the simulation
1030       engine. Once created, there is no way to destroy a mailbox before the end
1031       of the simulation.
1032
1033       .. doxygenfunction:: simgrid::s4u::Mailbox::by_name(const std::string &name)
1034
1035    .. group-tab:: Python
1036
1037       .. code-block:: C++
1038
1039          #include <simgrid/mailbox.h>
1040
1041       .. automethod:: simgrid.Mailbox.by_name
1042
1043    .. group-tab:: C
1044
1045       .. code-block:: C
1046
1047          #include <simgrid/s4u/mailbox.h>
1048
1049       .. doxygentypedef:: sg_mailbox_t
1050       .. doxygentypedef:: const_sg_mailbox_t
1051
1052       .. doxygenfunction:: sg_mailbox_by_name(const char *alias)
1053
1054 Querying info
1055 -------------
1056
1057 .. tabs::
1058
1059    .. group-tab:: C++
1060
1061       .. doxygenfunction:: simgrid::s4u::Mailbox::get_cname
1062       .. doxygenfunction:: simgrid::s4u::Mailbox::get_name
1063
1064    .. group-tab:: Python
1065
1066       .. autoattribute:: simgrid.Mailbox.name
1067
1068 Sending data
1069 ------------
1070
1071 .. tabs::
1072
1073    .. group-tab:: C++
1074
1075       .. doxygenfunction:: simgrid::s4u::Mailbox::put(void *payload, uint64_t simulated_size_in_bytes)
1076       .. doxygenfunction:: simgrid::s4u::Mailbox::put(void *payload, uint64_t simulated_size_in_bytes, double timeout)
1077       .. doxygenfunction:: simgrid::s4u::Mailbox::put_async(void *data, uint64_t simulated_size_in_bytes)
1078       .. doxygenfunction:: simgrid::s4u::Mailbox::put_init()
1079       .. doxygenfunction:: simgrid::s4u::Mailbox::put_init(void *data, uint64_t simulated_size_in_bytes)
1080
1081    .. group-tab:: Python
1082
1083       .. automethod:: simgrid.Mailbox.put
1084       .. automethod:: simgrid.Mailbox.put_async
1085       .. automethod:: simgrid.Mailbox.put_init
1086
1087    .. group-tab:: C
1088
1089       .. doxygenfunction:: sg_mailbox_put(sg_mailbox_t mailbox, void *payload, long simulated_size_in_bytes)
1090       .. doxygenfunction:: sg_mailbox_put_init(sg_mailbox_t mailbox, void *payload, long simulated_size_in_bytes)
1091       .. doxygenfunction:: sg_mailbox_put_async(sg_mailbox_t mailbox, void *payload, long simulated_size_in_bytes)
1092
1093
1094 Receiving data
1095 --------------
1096
1097 .. tabs::
1098
1099    .. group-tab:: C++
1100
1101       .. doxygenfunction:: simgrid::s4u::Mailbox::empty
1102       .. doxygenfunction:: simgrid::s4u::Mailbox::front
1103       .. doxygenfunction:: simgrid::s4u::Mailbox::get()
1104       .. doxygenfunction:: simgrid::s4u::Mailbox::get(double timeout)
1105       .. doxygenfunction:: simgrid::s4u::Mailbox::get_async(T **data)
1106       .. doxygenfunction:: simgrid::s4u::Mailbox::get_init()
1107       .. doxygenfunction:: simgrid::s4u::Mailbox::iprobe(int type, const std::function<bool(void *, void *, kernel::activity::CommImpl *)>& match_fun, void *data)
1108       .. doxygenfunction:: simgrid::s4u::Mailbox::listen
1109       .. doxygenfunction:: simgrid::s4u::Mailbox::ready
1110
1111    .. group-tab:: Python
1112
1113        .. automethod:: simgrid.Mailbox.get
1114        .. automethod:: simgrid.Mailbox.get_async
1115        .. autoattribute:: simgrid.Mailbox.ready
1116
1117    .. group-tab:: C
1118
1119       .. doxygenfunction:: sg_mailbox_get(sg_mailbox_t mailbox)
1120       .. doxygenfunction:: sg_mailbox_get_async(sg_mailbox_t mailbox, void **data)
1121       .. doxygenfunction:: sg_mailbox_get_name(const_sg_mailbox_t mailbox)
1122       .. doxygenfunction:: sg_mailbox_listen(const char *alias)
1123
1124 Receiving actor
1125 ---------------
1126
1127 See :ref:`s4u_receiving_actor`.
1128
1129 .. tabs::
1130
1131    .. group-tab:: C++
1132
1133       .. doxygenfunction:: simgrid::s4u::Mailbox::get_receiver
1134       .. doxygenfunction:: simgrid::s4u::Mailbox::set_receiver(ActorPtr actor)
1135
1136    .. group-tab:: C
1137
1138       .. doxygenfunction:: sg_mailbox_set_receiver(const char *alias)
1139
1140 .. _API_s4u_Resource:
1141
1142 =========
1143 Resources
1144 =========
1145
1146 .. _API_s4u_Disk:
1147
1148 =============
1149 ⁣  class Disk
1150 =============
1151
1152 .. tabs::
1153
1154    .. group-tab:: C++
1155
1156       .. doxygenclass:: simgrid::s4u::Disk
1157
1158    .. group-tab:: Python
1159
1160       .. autoclass:: simgrid.Disk
1161
1162    .. group-tab:: C
1163
1164       .. doxygentypedef:: sg_disk_t
1165       .. doxygentypedef:: const_sg_disk_t
1166
1167 Basic management
1168 ----------------
1169
1170 .. tabs::
1171
1172    .. group-tab:: C++
1173
1174       .. code-block:: C++
1175
1176          #include <simgrid/s4u/Disk.hpp>
1177
1178       Note that there is no DiskPtr type and that you cannot use the RAII
1179       idiom on disks because SimGrid does not allow (yet) to create nor
1180       destroy resources once the simulation is started.
1181
1182       .. doxygenfunction:: simgrid::s4u::Disk::seal()
1183
1184    .. group-tab:: Python
1185
1186       .. code:: Python
1187
1188          from simgrid import Disk
1189
1190       .. automethod:: simgrid.Disk.seal
1191
1192
1193 Querying info
1194 -------------
1195
1196 .. tabs::
1197
1198    .. group-tab:: C++
1199
1200       .. doxygenfunction:: simgrid::s4u::Disk::get_cname() const
1201       .. doxygenfunction:: simgrid::s4u::Disk::get_host() const
1202       .. doxygenfunction:: simgrid::s4u::Disk::get_name() const
1203       .. doxygenfunction:: simgrid::s4u::Disk::get_properties() const
1204       .. doxygenfunction:: simgrid::s4u::Disk::get_property(const std::string &key) const
1205       .. doxygenfunction:: simgrid::s4u::Disk::get_read_bandwidth() const
1206       .. doxygenfunction:: simgrid::s4u::Disk::get_write_bandwidth() const
1207       .. doxygenfunction:: simgrid::s4u::Disk::set_property(const std::string &, const std::string &value)
1208       .. doxygenfunction:: simgrid::s4u::Disk::set_sharing_policy
1209
1210    .. group-tab:: Python
1211
1212       .. autoattribute:: simgrid.Disk.name
1213       .. automethod:: simgrid.Disk.set_sharing_policy
1214
1215 I/O operations
1216 --------------
1217
1218 .. tabs::
1219
1220    .. group-tab:: C++
1221
1222       .. doxygenfunction:: simgrid::s4u::Disk::io_init(sg_size_t size, s4u::Io::OpType type) const
1223       .. doxygenfunction:: simgrid::s4u::Disk::read(sg_size_t size) const
1224       .. doxygenfunction:: simgrid::s4u::Disk::read_async(sg_size_t size) const
1225       .. doxygenfunction:: simgrid::s4u::Disk::write(sg_size_t size) const
1226       .. doxygenfunction:: simgrid::s4u::Disk::write_async(sg_size_t size) const
1227
1228    .. group-tab:: Python
1229
1230       .. automethod:: simgrid.Disk.read
1231       .. automethod:: simgrid.Disk.read_async
1232       .. automethod:: simgrid.Disk.write
1233       .. automethod:: simgrid.Disk.write_async
1234
1235 Signals
1236 -------
1237
1238 .. tabs::
1239
1240    .. group-tab:: C++
1241
1242       .. doxygenfunction:: simgrid::s4u::Disk::on_creation_cb
1243       .. doxygenfunction:: simgrid::s4u::Disk::on_destruction_cb
1244       .. doxygenfunction:: simgrid::s4u::Disk::on_this_destruction_cb
1245       .. doxygenfunction:: simgrid::s4u::Disk::on_onoff_cb
1246       .. doxygenfunction:: simgrid::s4u::Disk::on_this_onoff_cb
1247
1248
1249 .. _API_s4u_Host:
1250
1251 =============
1252 ⁣  class Host
1253 =============
1254
1255 .. tabs::
1256
1257    .. group-tab:: C++
1258
1259       .. doxygenclass:: simgrid::s4u::Host
1260
1261    .. group-tab:: Python
1262
1263       .. autoclass:: simgrid.Host
1264
1265 Basic management
1266 ----------------
1267
1268 .. tabs::
1269
1270    .. group-tab:: C++
1271
1272       .. code-block:: C++
1273
1274          #include <simgrid/s4u/Host.hpp>
1275
1276       Note that there is no HostPtr type, and that you cannot use the RAII
1277       idiom on hosts because SimGrid does not allow (yet) to create nor
1278       destroy resources once the simulation is started.
1279
1280       .. doxygenfunction:: simgrid::s4u::Host::destroy()
1281       .. doxygenfunction:: simgrid::s4u::Host::seal()
1282
1283    .. group-tab:: Python
1284
1285       .. code:: Python
1286
1287          from simgrid import Host
1288
1289       .. automethod:: simgrid.Host.seal
1290
1291    .. group-tab:: C
1292
1293       .. code:: C
1294
1295          #include <simgrid/host.h>
1296
1297       .. doxygentypedef:: sg_host_t
1298       .. cpp:type:: const s4u_Host* const_sg_host_t
1299
1300          Pointer to a constant host object.
1301
1302 Retrieving hosts
1303 ----------------
1304
1305 .. tabs::
1306
1307    .. group-tab:: C++
1308
1309       See also :cpp:func:`simgrid::s4u::Engine::get_all_hosts`.
1310
1311       .. doxygenfunction:: simgrid::s4u::Host::by_name(const std::string &name)
1312       .. doxygenfunction:: simgrid::s4u::Host::by_name_or_null(const std::string &name)
1313       .. doxygenfunction:: simgrid::s4u::Host::current()
1314
1315    .. group-tab:: Python
1316
1317       See also :py:attr:`simgrid.Engine.all_hosts`.
1318
1319       .. automethod:: simgrid.Host.by_name
1320       .. automethod:: simgrid.Host.current
1321
1322    .. group-tab:: C
1323
1324       .. doxygenfunction:: sg_host_by_name(const char *name)
1325       .. doxygenfunction:: sg_host_count()
1326       .. doxygenfunction:: sg_host_list()
1327
1328 Modifying characteristics
1329 -------------------------
1330
1331 .. tabs::
1332
1333    .. group-tab:: C++
1334
1335       .. doxygenfunction:: simgrid::s4u::Host::set_core_count(int core_count)
1336       .. doxygenfunction:: simgrid::s4u::Host::set_coordinates(const std::string& coords)
1337       .. doxygenfunction:: simgrid::s4u::Host::set_sharing_policy
1338
1339    .. group-tab:: Python
1340
1341       .. autoattribute:: simgrid.Host.core_count
1342          :noindex:
1343       .. automethod:: simgrid.Host.set_coordinates
1344       .. automethod:: simgrid.Host.set_sharing_policy
1345
1346 Querying info
1347 -------------
1348
1349 .. tabs::
1350
1351    .. group-tab:: C++
1352
1353       .. doxygenfunction:: simgrid::s4u::Host::get_cname() const
1354       .. doxygenfunction:: simgrid::s4u::Host::get_core_count() const
1355       .. doxygenfunction:: simgrid::s4u::Host::get_name() const
1356       .. doxygenfunction:: simgrid::s4u::Host::get_available_speed() const
1357       .. doxygenfunction:: simgrid::s4u::Host::get_load() const
1358       .. doxygenfunction:: simgrid::s4u::Host::get_speed() const
1359
1360    .. group-tab:: Python
1361
1362       .. autoattribute:: simgrid.Host.name
1363       .. autoattribute:: simgrid.Host.core_count
1364       .. autoattribute:: simgrid.Host.load
1365       .. autoattribute:: simgrid.Host.speed
1366       .. autoattribute:: simgrid.Host.available_speed
1367
1368    .. group-tab:: C
1369
1370       .. doxygenfunction:: sg_host_core_count(const_sg_host_t host)
1371       .. doxygenfunction:: sg_host_get_name(const_sg_host_t host)
1372       .. doxygenfunction:: sg_host_get_load(const_sg_host_t host)
1373       .. doxygenfunction:: sg_host_get_speed(const_sg_host_t host)
1374
1375 User data and properties
1376 ------------------------
1377
1378 .. tabs::
1379
1380    .. group-tab:: C++
1381
1382       .. doxygenfunction:: simgrid::s4u::Host::get_properties() const
1383       .. doxygenfunction:: simgrid::s4u::Host::get_property(const std::string &key) const
1384       .. doxygenfunction:: simgrid::s4u::Host::set_properties(const std::unordered_map< std::string, std::string > &properties)
1385       .. doxygenfunction:: simgrid::s4u::Host::set_property(const std::string &key, const std::string &value)
1386
1387    .. group-tab:: C
1388
1389       .. doxygenfunction:: sg_host_set_property_value(sg_host_t host, const char *name, const char *value)
1390       .. doxygenfunction:: sg_host_get_properties(const_sg_host_t host)
1391       .. doxygenfunction:: sg_host_get_property_value(const_sg_host_t host, const char *name)
1392       .. doxygenfunction:: sg_host_extension_create(void(*deleter)(void *))
1393       .. doxygenfunction:: sg_host_extension_get(const_sg_host_t host, size_t rank)
1394
1395 Retrieving components
1396 ---------------------
1397
1398 .. tabs::
1399
1400    .. group-tab:: C++
1401
1402       .. doxygenfunction:: simgrid::s4u::Host::add_disk(const Disk *disk)
1403       .. doxygenfunction:: simgrid::s4u::Host::get_actor_count() const
1404       .. doxygenfunction:: simgrid::s4u::Host::get_all_actors() const
1405       .. doxygenfunction:: simgrid::s4u::Host::get_disks() const
1406       .. doxygenfunction:: simgrid::s4u::Host::remove_disk(const std::string &disk_name)
1407
1408    .. group-tab:: Python
1409
1410       .. automethod:: simgrid.Host.get_disks
1411
1412    .. group-tab:: C
1413
1414       .. doxygenfunction:: sg_host_get_actor_list(const_sg_host_t host, xbt_dynar_t whereto)
1415
1416 On/Off
1417 ------
1418
1419 .. tabs::
1420
1421    .. group-tab:: C++
1422
1423       .. doxygenfunction:: simgrid::s4u::Host::is_on() const
1424       .. doxygenfunction:: simgrid::s4u::Host::turn_off()
1425       .. doxygenfunction:: simgrid::s4u::Host::turn_on()
1426
1427    .. group-tab:: C
1428
1429       .. doxygenfunction:: sg_host_is_on(const_sg_host_t host)
1430       .. doxygenfunction:: sg_host_turn_off(sg_host_t host)
1431       .. doxygenfunction:: sg_host_turn_on(sg_host_t host)
1432
1433 .. _API_s4u_Host_dvfs:
1434
1435 DVFS
1436 ----
1437
1438 See also the :ref:`relevant examples <s4u_ex_dvfs>`.
1439
1440 .. tabs::
1441
1442    .. group-tab:: C++
1443
1444       .. doxygenfunction:: simgrid::s4u::Host::get_pstate() const
1445       .. doxygenfunction:: simgrid::s4u::Host::get_pstate_count() const
1446       .. doxygenfunction:: simgrid::s4u::Host::get_pstate_speed(unsigned long pstate_index) const
1447       .. doxygenfunction:: simgrid::s4u::Host::set_pstate(unsigned long pstate_index)
1448
1449    .. group-tab:: Python
1450
1451       .. autoattribute:: simgrid.Host.pstate
1452       .. autoattribute:: simgrid.Host.pstate_count
1453       .. automethod:: simgrid.Host.pstate_speed
1454
1455    .. group-tab:: C
1456
1457       .. doxygenfunction:: sg_host_get_available_speed(const_sg_host_t host)
1458       .. doxygenfunction:: sg_host_get_nb_pstates(const_sg_host_t host)
1459       .. doxygenfunction:: sg_host_get_pstate(const_sg_host_t host)
1460       .. doxygenfunction:: sg_host_get_pstate_speed(const_sg_host_t host, unsigned long pstate_index)
1461       .. doxygenfunction:: sg_host_set_pstate(sg_host_t host, unsigned long pstate)
1462
1463 Dynamic profiles
1464 ----------------
1465
1466 .. tabs::
1467
1468    .. group-tab:: C++
1469
1470       .. doxygenfunction:: simgrid::s4u::Host::set_speed_profile(kernel::profile::Profile *p)
1471       .. doxygenfunction:: simgrid::s4u::Host::set_state_profile(kernel::profile::Profile *p)
1472
1473    .. group-tab:: Python
1474
1475       .. automethod:: simgrid.Host.set_speed_profile
1476       .. automethod:: simgrid.Host.set_state_profile
1477
1478 Execution
1479 ---------
1480
1481 .. tabs::
1482
1483    .. group-tab:: C++
1484
1485       .. doxygenfunction:: simgrid::s4u::Host::exec_async
1486       .. doxygenfunction:: simgrid::s4u::Host::execute(double flops) const
1487       .. doxygenfunction:: simgrid::s4u::Host::execute(double flops, double priority) const
1488
1489 Platform and routing
1490 --------------------
1491
1492 You can also start direct communications between two arbitrary hosts
1493 using :cpp:func:`Comm::sendto() <simgrid::s4u::Comm::sendto()>`.
1494
1495 .. tabs::
1496
1497    .. group-tab:: C++
1498
1499       .. doxygenfunction:: simgrid::s4u::Host::get_englobing_zone() const
1500       .. doxygenfunction:: simgrid::s4u::Host::get_netpoint() const
1501       .. doxygenfunction:: simgrid::s4u::Host::route_to(const Host *dest, std::vector< Link * > &links, double *latency) const
1502       .. doxygenfunction:: simgrid::s4u::Host::route_to(const Host *dest, std::vector< kernel::resource::StandardLinkImpl * > &links, double *latency) const
1503       .. doxygenfunction:: simgrid::s4u::Host::create_disk(const std::string& name, double read_bandwidth, double write_bandwidth)
1504       .. doxygenfunction:: simgrid::s4u::Host::create_disk(const std::string& name, const std::string& read_bandwidth, const std::string& write_bandwidth)
1505
1506    .. group-tab:: Python
1507
1508       .. autoattribute:: simgrid.Host.netpoint
1509       .. automethod:: simgrid.Host.create_disk
1510
1511       .. automethod:: simgrid.Host.route_to
1512
1513    .. group-tab:: C
1514
1515       .. doxygenfunction:: sg_host_get_route(const_sg_host_t from, const_sg_host_t to, xbt_dynar_t links)
1516       .. doxygenfunction:: sg_host_get_route_bandwidth(const_sg_host_t from, const_sg_host_t to)
1517       .. doxygenfunction:: sg_host_get_route_latency(const_sg_host_t from, const_sg_host_t to)
1518       .. doxygenfunction:: sg_host_sendto(sg_host_t from, sg_host_t to, double byte_amount)
1519
1520 Signals
1521 -------
1522
1523 .. tabs::
1524
1525    .. group-tab:: C++
1526
1527       .. doxygenfunction:: simgrid::s4u::Host::on_creation_cb
1528       .. doxygenfunction:: simgrid::s4u::Host::on_destruction_cb
1529       .. doxygenfunction:: simgrid::s4u::Host::on_this_destruction_cb
1530       .. doxygenfunction:: simgrid::s4u::Host::on_speed_change_cb
1531       .. doxygenfunction:: simgrid::s4u::Host::on_this_speed_change_cb
1532       .. doxygenfunction:: simgrid::s4u::Host::on_onoff_cb
1533       .. doxygenfunction:: simgrid::s4u::Host::on_this_onoff_cb
1534       .. doxygenfunction:: simgrid::s4u::Host::on_exec_state_change_cb
1535
1536 .. _API_s4u_Link:
1537
1538 =============
1539 ⁣  class Link
1540 =============
1541
1542 .. tabs::
1543
1544    .. group-tab:: C++
1545
1546       .. doxygenclass:: simgrid::s4u::Link
1547       .. doxygenclass:: simgrid::s4u::SplitDuplexLink
1548       .. doxygenclass:: simgrid::s4u::LinkInRoute
1549
1550
1551    .. group-tab:: Python
1552
1553       .. autoclass:: simgrid.Link
1554
1555 Basic management
1556 ----------------
1557
1558 .. tabs::
1559
1560    .. group-tab:: C++
1561
1562       .. code-block:: C++
1563
1564          #include <simgrid/s4u/Link.hpp>
1565
1566       Note that there is no LinkPtr type and that you cannot use the RAII
1567       idiom on hosts because SimGrid does not allow (yet) to create nor
1568       destroy resources once the simulation is started.
1569
1570       .. doxygenfunction:: simgrid::s4u::Link::seal()
1571
1572    .. group-tab:: Python
1573
1574       .. code:: Python
1575
1576          from simgrid import Link
1577
1578       .. automethod:: simgrid.Link.seal
1579
1580    .. group-tab:: C
1581
1582       .. code:: C
1583
1584          #include <simgrid/link.h>
1585
1586       .. doxygentypedef:: sg_link_t
1587       .. cpp:type:: const s4u_Link* const_sg_link_t
1588
1589          Pointer to a constant link object.
1590
1591 Retrieving links
1592 ----------------
1593
1594 .. tabs::
1595
1596    .. group-tab:: C++
1597
1598       See also :cpp:func:`simgrid::s4u::Engine::get_all_links`.
1599
1600       .. doxygenfunction:: simgrid::s4u::Link::by_name(const std::string &name)
1601       .. doxygenfunction:: simgrid::s4u::Link::by_name_or_null(const std::string &name)
1602
1603    .. group-tab:: Python
1604
1605       See also :py:attr:`simgrid.Engine.all_links`.
1606
1607       .. automethod:: simgrid.Link.by_name
1608       .. autoattribute:: simgrid.Link.name
1609
1610    .. group-tab:: C
1611
1612       .. doxygenfunction:: sg_link_by_name(const char *name)
1613       .. doxygenfunction:: sg_link_count()
1614       .. doxygenfunction:: sg_link_list()
1615
1616 Querying info
1617 --------------
1618
1619 .. tabs::
1620
1621    .. group-tab:: C++
1622
1623       .. doxygenfunction:: simgrid::s4u::Link::get_bandwidth() const
1624       .. doxygenfunction:: simgrid::s4u::Link::get_cname() const
1625       .. doxygenfunction:: simgrid::s4u::Link::get_latency() const
1626       .. doxygenfunction:: simgrid::s4u::Link::get_name() const
1627       .. doxygenfunction:: simgrid::s4u::Link::get_sharing_policy() const
1628       .. doxygenfunction:: simgrid::s4u::Link::get_concurrency_limit() const
1629       .. doxygenfunction:: simgrid::s4u::Link::get_usage() const
1630       .. doxygenfunction:: simgrid::s4u::Link::is_used() const
1631
1632    .. group-tab:: Python
1633
1634       .. autoattribute:: simgrid.Link.bandwidth
1635       .. autoattribute:: simgrid.Link.latency
1636
1637    .. group-tab:: C
1638
1639       .. doxygenfunction:: sg_link_get_bandwidth(const_sg_link_t link)
1640       .. doxygenfunction:: sg_link_get_latency(const_sg_link_t link)
1641       .. doxygenfunction:: sg_link_get_name(const_sg_link_t link)
1642       .. doxygenfunction:: sg_link_is_shared(const_sg_link_t link)
1643
1644 Modifying characteristics
1645 -------------------------
1646
1647 .. tabs::
1648
1649    .. group-tab:: C++
1650
1651       .. doxygenfunction:: simgrid::s4u::Link::set_bandwidth(double value)
1652       .. doxygenfunction:: simgrid::s4u::Link::set_latency(double value)
1653       .. doxygenfunction:: simgrid::s4u::Link::set_latency(const std::string& value)
1654       .. doxygenfunction:: simgrid::s4u::Link::set_concurrency_limit(int limit)
1655       .. doxygenfunction:: simgrid::s4u::Link::set_sharing_policy
1656
1657    .. group-tab:: Python
1658
1659       .. automethod:: simgrid.Link.set_bandwidth
1660       .. automethod:: simgrid.Link.set_latency
1661       .. automethod:: simgrid.Link.set_concurrency_limit
1662       .. automethod:: simgrid.Link.set_sharing_policy
1663
1664    .. group-tab:: C
1665
1666       .. doxygenfunction:: sg_link_set_bandwidth(sg_link_t link, double value)
1667       .. doxygenfunction:: sg_link_set_latency(sg_link_t link, double value)
1668
1669 User data and properties
1670 ------------------------
1671
1672 .. tabs::
1673
1674    .. group-tab:: C++
1675
1676       .. doxygenfunction:: simgrid::s4u::Link::get_property(const std::string &key) const
1677       .. doxygenfunction:: simgrid::s4u::Link::set_property(const std::string &key, const std::string &value)
1678
1679    .. group-tab:: C
1680
1681       .. doxygenfunction:: sg_link_get_data(const_sg_link_t link)
1682       .. doxygenfunction:: sg_link_set_data(sg_link_t link, void *data)
1683
1684 On/Off
1685 ------
1686
1687 .. tabs::
1688
1689    .. group-tab:: C++
1690
1691       See also :cpp:func:`simgrid::s4u::Link::set_state_profile`.
1692
1693       .. doxygenfunction:: simgrid::s4u::Link::is_on() const
1694       .. doxygenfunction:: simgrid::s4u::Link::turn_off()
1695       .. doxygenfunction:: simgrid::s4u::Link::turn_on()
1696
1697    .. group-tab:: Python
1698
1699       See also :py:func:`simgrid.Link.set_state_profile`.
1700
1701       .. automethod:: simgrid.Link.is_on
1702       .. automethod:: simgrid.Link.turn_off
1703       .. automethod:: simgrid.Link.turn_on
1704
1705 Dynamic profiles
1706 ----------------
1707
1708 See :ref:`howto_churn` for more details.
1709
1710 .. tabs::
1711
1712    .. group-tab:: C++
1713
1714       .. doxygenfunction:: simgrid::s4u::Link::set_bandwidth_profile(kernel::profile::Profile *profile)
1715       .. doxygenfunction:: simgrid::s4u::Link::set_latency_profile(kernel::profile::Profile *profile)
1716       .. doxygenfunction:: simgrid::s4u::Link::set_state_profile(kernel::profile::Profile *profile)
1717
1718    .. group-tab:: Python
1719
1720       .. automethod:: simgrid.Link.set_bandwidth_profile
1721       .. automethod:: simgrid.Link.set_latency_profile
1722       .. automethod:: simgrid.Link.set_state_profile
1723
1724 WIFI links
1725 ----------
1726
1727 .. tabs::
1728
1729    .. group-tab:: C++
1730
1731       .. doxygenfunction:: simgrid::s4u::Link::set_host_wifi_rate
1732
1733    .. group-tab:: Python
1734
1735       .. automethod:: simgrid.Link.set_host_wifi_rate
1736
1737 Signals
1738 -------
1739
1740 .. tabs::
1741
1742    .. group-tab:: C++
1743
1744       .. doxygenfunction:: simgrid::s4u::Link::on_bandwidth_change_cb
1745       .. doxygenfunction:: simgrid::s4u::Link::on_this_bandwidth_change_cb
1746       .. doxygenfunction:: simgrid::s4u::Link::on_communication_state_change_cb
1747       .. doxygenfunction:: simgrid::s4u::Link::on_creation_cb
1748       .. doxygenfunction:: simgrid::s4u::Link::on_destruction_cb
1749       .. doxygenfunction:: simgrid::s4u::Link::on_this_destruction_cb
1750       .. doxygenfunction:: simgrid::s4u::Link::on_onoff_cb
1751       .. doxygenfunction:: simgrid::s4u::Link::on_this_onoff_cb
1752
1753 .. _API_s4u_NetZone:
1754
1755 ================
1756 ⁣  class NetZone
1757 ================
1758
1759 .. tabs::
1760
1761    .. group-tab:: C++
1762
1763       .. doxygenclass:: simgrid::s4u::NetZone
1764
1765    .. group-tab:: Python
1766
1767       .. autoclass:: simgrid.NetZone
1768
1769 Basic management
1770 ----------------
1771
1772 .. tabs::
1773
1774    .. group-tab:: C++
1775
1776       .. code-block:: C++
1777
1778          #include <simgrid/s4u/NetZone.hpp>
1779
1780       Note that there is no NetZonePtr type and that you cannot use the RAII
1781       idiom on network zones because SimGrid does not allow (yet) to create nor
1782       destroy resources once the simulation is started.
1783
1784       .. doxygenfunction:: simgrid::s4u::NetZone::seal
1785
1786    .. group-tab:: Python
1787
1788       .. code:: Python
1789
1790          from simgrid import NetZone
1791
1792       .. automethod:: simgrid.NetZone.seal
1793
1794    .. group-tab:: C
1795
1796       .. code:: C
1797
1798          #include <simgrid/zone.h>
1799
1800       .. doxygentypedef:: sg_netzone_t
1801       .. cpp:type:: const s4u_NetZone* const_sg_netzone_t
1802
1803          Pointer to a constant network zone object.
1804
1805 Retrieving zones
1806 ----------------
1807
1808 .. tabs::
1809
1810    .. group-tab:: C++
1811
1812       See :cpp:func:`simgrid::s4u::Engine::get_netzone_root`,
1813       :cpp:func:`simgrid::s4u::Engine::netzone_by_name_or_null` and
1814       :cpp:func:`simgrid::s4u::Engine::get_filtered_netzones`.
1815
1816    .. group-tab:: C
1817
1818       .. doxygenfunction:: sg_zone_get_by_name(const char *name)
1819       .. doxygenfunction:: sg_zone_get_root()
1820
1821 Querying info
1822 --------------
1823
1824 .. tabs::
1825
1826    .. group-tab:: C++
1827
1828       .. doxygenfunction:: simgrid::s4u::NetZone::get_cname() const
1829       .. doxygenfunction:: simgrid::s4u::NetZone::get_name() const
1830       .. doxygenfunction:: simgrid::s4u::NetZone::get_netpoint()
1831
1832    .. group-tab:: Python
1833
1834       .. autoattribute:: simgrid.NetZone.name
1835       .. autoattribute:: simgrid.NetZone.netpoint
1836
1837    .. group-tab:: C
1838
1839       .. doxygenfunction:: sg_zone_get_name(const_sg_netzone_t zone)
1840
1841 User data and properties
1842 ------------------------
1843
1844 .. tabs::
1845
1846    .. group-tab:: C++
1847
1848       .. doxygenfunction:: simgrid::s4u::NetZone::get_properties() const
1849       .. doxygenfunction:: simgrid::s4u::NetZone::get_property(const std::string &key) const
1850       .. doxygenfunction:: simgrid::s4u::NetZone::set_property(const std::string &key, const std::string &value)
1851
1852    .. group-tab:: Python
1853
1854       .. automethod:: simgrid.NetZone.set_property
1855
1856    .. group-tab:: C
1857
1858       .. doxygenfunction:: sg_zone_get_property_value(const_sg_netzone_t as, const char *name)
1859       .. doxygenfunction:: sg_zone_set_property_value(sg_netzone_t netzone, const char *name, const char *value)
1860
1861 Retrieving components
1862 ---------------------
1863
1864 .. tabs::
1865
1866    .. group-tab:: C++
1867
1868       .. doxygenfunction:: simgrid::s4u::NetZone::get_all_hosts() const
1869       .. doxygenfunction:: simgrid::s4u::NetZone::get_host_count() const
1870
1871    .. group-tab:: C
1872
1873       .. doxygenfunction:: sg_zone_get_hosts(const_sg_netzone_t zone, xbt_dynar_t whereto)
1874
1875 Routing data
1876 ------------
1877
1878 .. tabs::
1879
1880    .. group-tab:: C++
1881
1882       .. doxygenfunction:: simgrid::s4u::NetZone::add_component(kernel::routing::NetPoint *elm)
1883       .. doxygenfunction:: simgrid::s4u::NetZone::add_route
1884       .. doxygenfunction:: simgrid::s4u::NetZone::add_bypass_route
1885       .. doxygenfunction:: simgrid::s4u::NetZone::get_children() const
1886       .. doxygenfunction:: simgrid::s4u::NetZone::get_parent() const
1887       .. doxygenfunction:: simgrid::s4u::NetZone::set_parent(const NetZone* parent)
1888
1889    .. group-tab:: Python
1890
1891       .. automethod:: simgrid.NetZone.add_route
1892       .. automethod:: simgrid.NetZone.set_parent
1893
1894    .. group-tab:: C
1895
1896       .. doxygenfunction:: sg_zone_get_sons(const_sg_netzone_t zone, xbt_dict_t whereto)
1897
1898 Signals
1899 -------
1900
1901 .. tabs::
1902
1903   .. group-tab:: C++
1904
1905      .. doxygenfunction:: simgrid::s4u::NetZone::on_creation_cb
1906      .. doxygenfunction:: simgrid::s4u::NetZone::on_seal_cb
1907
1908 Creating resources
1909 ------------------
1910
1911 Zones
1912 ^^^^^
1913 .. tabs::
1914
1915   .. group-tab:: C++
1916
1917      .. doxygenfunction:: simgrid::s4u::create_full_zone
1918      .. doxygenfunction:: simgrid::s4u::create_empty_zone
1919      .. doxygenfunction:: simgrid::s4u::create_star_zone
1920      .. doxygenfunction:: simgrid::s4u::create_dijkstra_zone
1921      .. doxygenfunction:: simgrid::s4u::create_floyd_zone
1922      .. doxygenfunction:: simgrid::s4u::create_vivaldi_zone
1923      .. doxygenfunction:: simgrid::s4u::create_wifi_zone
1924      .. doxygenfunction:: simgrid::s4u::create_torus_zone
1925      .. doxygenfunction:: simgrid::s4u::create_fatTree_zone
1926      .. doxygenfunction:: simgrid::s4u::create_dragonfly_zone
1927
1928   .. group-tab:: Python
1929
1930      .. automethod:: simgrid.NetZone.create_full_zone
1931      .. automethod:: simgrid.NetZone.create_empty_zone
1932      .. automethod:: simgrid.NetZone.create_star_zone
1933      .. automethod:: simgrid.NetZone.create_dijkstra_zone
1934      .. automethod:: simgrid.NetZone.create_floyd_zone
1935      .. automethod:: simgrid.NetZone.create_vivaldi_zone
1936      .. automethod:: simgrid.NetZone.create_wifi_zone
1937      .. automethod:: simgrid.NetZone.create_torus_zone
1938      .. automethod:: simgrid.NetZone.create_fatTree_zone
1939      .. automethod:: simgrid.NetZone.create_dragonfly_zone
1940
1941 Hosts
1942 ^^^^^
1943
1944 .. tabs::
1945
1946   .. group-tab:: C++
1947
1948      .. doxygenfunction:: simgrid::s4u::NetZone::create_host(const std::string& name, const std::vector<double>& speed_per_pstate)
1949      .. doxygenfunction:: simgrid::s4u::NetZone::create_host(const std::string& name, double speed)
1950      .. doxygenfunction:: simgrid::s4u::NetZone::create_host(const std::string& name, const std::vector<std::string>& speed_per_pstate)
1951      .. doxygenfunction:: simgrid::s4u::NetZone::create_host(const std::string& name, const std::string& speed)
1952
1953   .. group-tab:: Python
1954
1955      .. automethod:: simgrid.NetZone.create_host
1956
1957 Links
1958 ^^^^^
1959
1960 .. tabs::
1961
1962   .. group-tab:: C++
1963
1964      .. doxygenfunction:: simgrid::s4u::NetZone::create_link(const std::string& name, const std::vector<double>& bandwidths)
1965      .. doxygenfunction:: simgrid::s4u::NetZone::create_link(const std::string& name, double bandwidth)
1966      .. doxygenfunction:: simgrid::s4u::NetZone::create_link(const std::string& name, const std::vector<std::string>& bandwidthds)
1967      .. doxygenfunction:: simgrid::s4u::NetZone::create_link(const std::string& name, const std::string& bandwidth)
1968      .. doxygenfunction:: simgrid::s4u::NetZone::create_split_duplex_link(const std::string& name, const std::string& bandwidth)
1969      .. doxygenfunction:: simgrid::s4u::NetZone::create_split_duplex_link(const std::string& name, double bandwidth)
1970
1971   .. group-tab:: Python
1972
1973      .. automethod:: simgrid.NetZone.create_link
1974      .. automethod:: simgrid.NetZone.create_split_duplex_link
1975
1976 Router
1977 ^^^^^^
1978
1979 .. tabs::
1980
1981   .. group-tab:: C++
1982
1983      .. doxygenfunction:: simgrid::s4u::NetZone::create_router(const std::string& name)
1984
1985   .. group-tab:: Python
1986
1987      .. automethod:: simgrid.NetZone.create_router
1988
1989 .. _API_s4u_VirtualMachine:
1990
1991 =======================
1992 ⁣  class VirtualMachine
1993 =======================
1994
1995
1996 .. doxygenclass:: simgrid::s4u::VirtualMachine
1997
1998 Basic management
1999 ----------------
2000 .. tabs::
2001
2002    .. group-tab:: C++
2003
2004       .. code-block:: C++
2005
2006          #include <simgrid/s4u/VirtualMachine.hpp>
2007
2008       Note that there is no VirtualMachinePtr type, and that you cannot use the RAII
2009       idiom on virtual machines. There is no good reason for that and should change in the future.
2010
2011    .. group-tab:: C
2012
2013       .. code:: C
2014
2015          #include <simgrid/vm.h>
2016
2017       .. doxygentypedef:: sg_vm_t
2018       .. cpp:type:: const s4u_VirtualMachine* const_sg_vm_t
2019
2020          Pointer to a constant virtual machine object.
2021
2022 Creating VMs
2023 ------------
2024
2025 .. tabs::
2026
2027    .. group-tab:: C++
2028
2029       .. doxygenfunction:: simgrid::s4u::Host::create_vm(const std::string &name, int core_amount)
2030       .. doxygenfunction:: simgrid::s4u::Host::create_vm(const std::string &name, int core_amount, size_t ramsize)
2031       .. doxygenfunction:: simgrid::s4u::VirtualMachine::destroy
2032
2033    .. group-tab:: C
2034
2035       .. doxygenfunction:: sg_vm_create_core
2036       .. doxygenfunction:: sg_vm_create_multicore
2037       .. doxygenfunction:: sg_vm_destroy
2038
2039 Querying info
2040 --------------
2041
2042 .. tabs::
2043
2044    .. group-tab:: C++
2045
2046       .. doxygenfunction:: simgrid::s4u::VirtualMachine::get_pm() const
2047       .. doxygenfunction:: simgrid::s4u::VirtualMachine::get_ramsize() const
2048       .. doxygenfunction:: simgrid::s4u::VirtualMachine::get_state() const
2049
2050       .. doxygenfunction:: simgrid::s4u::VirtualMachine::set_bound(double bound)
2051       .. doxygenfunction:: simgrid::s4u::VirtualMachine::set_pm(Host *pm)
2052       .. doxygenfunction:: simgrid::s4u::VirtualMachine::set_ramsize(size_t ramsize)
2053
2054    .. group-tab:: C
2055
2056       .. doxygenfunction:: sg_vm_get_ramsize(const_sg_vm_t vm)
2057       .. doxygenfunction:: sg_vm_set_bound(sg_vm_t vm, double bound)
2058       .. doxygenfunction:: sg_vm_set_ramsize(sg_vm_t vm, size_t size)
2059
2060       .. doxygenfunction:: sg_vm_get_name
2061       .. doxygenfunction:: sg_vm_get_pm
2062       .. doxygenfunction:: sg_vm_is_created
2063       .. doxygenfunction:: sg_vm_is_running
2064       .. doxygenfunction:: sg_vm_is_suspended
2065
2066 Life cycle
2067 ----------
2068
2069 .. tabs::
2070
2071    .. group-tab:: C++
2072
2073       .. doxygenfunction:: simgrid::s4u::VirtualMachine::resume()
2074       .. doxygenfunction:: simgrid::s4u::VirtualMachine::shutdown()
2075       .. doxygenfunction:: simgrid::s4u::VirtualMachine::start()
2076       .. doxygenfunction:: simgrid::s4u::VirtualMachine::suspend()
2077
2078    .. group-tab:: C
2079
2080       .. doxygenfunction:: sg_vm_start
2081       .. doxygenfunction:: sg_vm_suspend
2082       .. doxygenfunction:: sg_vm_resume
2083       .. doxygenfunction:: sg_vm_shutdown
2084
2085 Signals
2086 -------
2087
2088 .. tabs::
2089
2090    .. group-tab:: C++
2091
2092       .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_creation_cb
2093       .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_destruction_cb
2094       .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_this_destruction_cb
2095       .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_migration_end_cb
2096       .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_this_migration_end_cb
2097       .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_migration_start_cb
2098       .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_this_migration_start_cb
2099       .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_resume_cb
2100       .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_this_resume_cb
2101       .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_shutdown_cb
2102       .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_this_shutdown_cb
2103       .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_start_cb
2104       .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_this_start_cb
2105       .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_started_cb
2106       .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_this_started_cb
2107       .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_suspend_cb
2108       .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_this_suspend_cb
2109
2110 .. _API_s4u_Activity:
2111
2112 ==========
2113 Activities
2114 ==========
2115
2116 ==============
2117 class Activity
2118 ==============
2119
2120 .. doxygenclass:: simgrid::s4u::Activity
2121
2122 **Known subclasses:**
2123 :ref:`Communications <API_s4u_Comm>` (started on Mailboxes and consuming links),
2124 :ref:`Executions <API_s4u_Exec>` (started on Host and consuming CPU resources)
2125 :ref:`I/O <API_s4u_Io>` (started on and consuming disks).
2126 See also the :ref:`section on activities <s4u_Activities>` above.
2127
2128 Basic management
2129 ----------------
2130
2131 .. tabs::
2132
2133    .. group-tab:: C++
2134
2135       .. code-block:: C++
2136
2137          #include <simgrid/s4u/Activity.hpp>
2138
2139       .. doxygentypedef:: ActivityPtr
2140
2141 Querying info
2142 -------------
2143
2144 .. tabs::
2145
2146    .. group-tab:: C++
2147
2148       .. doxygenfunction:: simgrid::s4u::Activity::get_cname() const
2149       .. doxygenfunction:: simgrid::s4u::Activity::get_name() const
2150       .. doxygenfunction:: simgrid::s4u::Activity::get_remaining() const
2151       .. doxygenfunction:: simgrid::s4u::Activity::get_state() const
2152       .. doxygenfunction:: simgrid::s4u::Activity::set_remaining(double remains)
2153       .. doxygenfunction:: simgrid::s4u::Activity::set_state(Activity::State state)
2154
2155
2156 Activities life cycle
2157 ---------------------
2158
2159 .. tabs::
2160
2161    .. group-tab:: C++
2162
2163       .. doxygenfunction:: simgrid::s4u::Activity::start
2164       .. doxygenfunction:: simgrid::s4u::Activity::cancel
2165       .. doxygenfunction:: simgrid::s4u::Activity::test
2166       .. doxygenfunction:: simgrid::s4u::Activity::wait
2167       .. doxygenfunction:: simgrid::s4u::Activity::wait_for
2168       .. doxygenfunction:: simgrid::s4u::Activity::wait_until(double time_limit)
2169       .. doxygenfunction:: simgrid::s4u::Activity::vetoable_start()
2170
2171 Suspending and resuming an activity
2172 -----------------------------------
2173
2174 .. tabs::
2175
2176    .. group-tab:: C++
2177
2178       .. doxygenfunction:: simgrid::s4u::Activity::suspend
2179       .. doxygenfunction:: simgrid::s4u::Activity::resume
2180       .. doxygenfunction:: simgrid::s4u::Activity::is_suspended
2181
2182 .. _API_s4u_Comm:
2183
2184 =============
2185 ⁣  class Comm
2186 =============
2187
2188 .. tabs::
2189
2190    .. group-tab:: C++
2191
2192       .. doxygenclass:: simgrid::s4u::Comm
2193
2194    .. group-tab:: Python
2195
2196       .. autoclass:: simgrid.Comm
2197
2198 Basic management
2199 ----------------
2200
2201 .. tabs::
2202
2203    .. group-tab:: C++
2204
2205       .. code-block:: C++
2206
2207          #include <simgrid/s4u/Comm.hpp>
2208
2209       .. doxygentypedef:: CommPtr
2210
2211    .. group-tab:: Python
2212
2213       .. code:: Python
2214
2215          from simgrid import Comm
2216
2217    .. group-tab:: c
2218
2219       .. code:: c
2220
2221          #include <simgrid/comm.h>
2222
2223       .. doxygentypedef:: sg_comm_t
2224
2225 Querying info
2226 -------------
2227
2228 .. tabs::
2229
2230    .. group-tab:: C++
2231
2232       .. doxygenfunction:: simgrid::s4u::Comm::get_dst_data_size() const
2233       .. doxygenfunction:: simgrid::s4u::Comm::get_mailbox() const
2234       .. doxygenfunction:: simgrid::s4u::Comm::get_sender() const
2235       .. doxygenfunction:: simgrid::s4u::Comm::set_dst_data(void **buff)
2236       .. doxygenfunction:: simgrid::s4u::Comm::set_dst_data(void **buff, size_t size)
2237       .. doxygenfunction:: simgrid::s4u::Comm::detach()
2238       .. doxygenfunction:: simgrid::s4u::Comm::detach(const std::function<void(void*)>& clean_function)
2239       .. doxygenfunction:: simgrid::s4u::Comm::set_payload_size(uint64_t bytes)
2240       .. doxygenfunction:: simgrid::s4u::Comm::set_rate(double rate)
2241       .. doxygenfunction:: simgrid::s4u::Comm::set_src_data(void *buff)
2242       .. doxygenfunction:: simgrid::s4u::Comm::set_src_data(void *buff, size_t size)
2243       .. doxygenfunction:: simgrid::s4u::Comm::set_src_data_size(size_t size)
2244
2245    .. group-tab:: Python
2246
2247       .. autoattribute:: simgrid.Comm.dst_data_size
2248       .. autoattribute:: simgrid.Comm.mailbox
2249       .. autoattribute:: simgrid.Comm.sender
2250       .. autoattribute:: simgrid.Comm.state_str
2251       .. automethod:: simgrid.Comm.detach
2252       .. automethod:: simgrid.Comm.set_payload_size
2253       .. automethod:: simgrid.Comm.set_rate
2254
2255 Direct host-to-host communication
2256 ---------------------------------
2257
2258 Most communications are created using :ref:`s4u_mailbox`, but you can
2259 also start direct communications as shown below. See also the
2260 :ref:`relevant examples <s4u_ex_comm_host2host>`.
2261
2262 .. tabs::
2263
2264    .. group-tab:: C++
2265
2266       .. doxygenfunction:: simgrid::s4u::Comm::sendto
2267       .. doxygenfunction:: simgrid::s4u::Comm::sendto_init()
2268       .. doxygenfunction:: simgrid::s4u::Comm::sendto_init(Host *from, Host *to)
2269       .. doxygenfunction:: simgrid::s4u::Comm::sendto_async
2270
2271    .. group-tab:: Python
2272
2273       .. automethod:: simgrid.Comm.sendto
2274       .. automethod:: simgrid.Comm.sendto_init
2275       .. automethod:: simgrid.Comm.sendto_async
2276
2277 Life cycle
2278 ----------
2279
2280 .. tabs::
2281
2282    .. group-tab:: C++
2283
2284       .. doxygenfunction:: simgrid::s4u::Comm::cancel
2285       .. doxygenfunction:: simgrid::s4u::Comm::start
2286       .. doxygenfunction:: simgrid::s4u::Comm::test
2287       .. doxygenfunction:: simgrid::s4u::Comm::test_any(const std::vector< CommPtr >& comms)
2288       .. doxygenfunction:: simgrid::s4u::Comm::wait
2289       .. doxygenfunction:: simgrid::s4u::Comm::wait_all(const std::vector< CommPtr >& comms)
2290       .. doxygenfunction:: simgrid::s4u::Comm::wait_all_for(const std::vector< CommPtr >& comms, double timeout)
2291       .. doxygenfunction:: simgrid::s4u::Comm::wait_any(const std::vector< CommPtr >& comms)
2292       .. doxygenfunction:: simgrid::s4u::Comm::wait_any_for(const std::vector< CommPtr >& comms, double timeout)
2293       .. doxygenfunction:: simgrid::s4u::Comm::wait_for
2294       .. doxygenfunction:: simgrid::s4u::Comm::wait_until
2295
2296    .. group-tab:: Python
2297
2298       .. automethod:: simgrid.Comm.cancel
2299       .. automethod:: simgrid.Comm.start
2300       .. automethod:: simgrid.Comm.test
2301       .. automethod:: simgrid.Comm.test_any
2302       .. automethod:: simgrid.Comm.wait
2303       .. automethod:: simgrid.Comm.wait_for
2304       .. automethod:: simgrid.Comm.wait_all
2305       .. automethod:: simgrid.Comm.wait_all_for
2306       .. automethod:: simgrid.Comm.wait_any
2307       .. automethod:: simgrid.Comm.wait_any_for
2308       .. automethod:: simgrid.Comm.wait_until
2309
2310    .. group-tab:: C
2311
2312       .. doxygenfunction:: sg_comm_test
2313       .. doxygenfunction:: sg_comm_wait
2314       .. doxygenfunction:: sg_comm_wait_all
2315       .. doxygenfunction:: sg_comm_wait_any
2316
2317 Suspending and resuming a communication
2318 ---------------------------------------
2319
2320 .. tabs::
2321
2322    .. group-tab:: C++
2323
2324       .. doxygenfunction:: simgrid::s4u::Comm::suspend
2325       .. doxygenfunction:: simgrid::s4u::Comm::resume
2326       .. doxygenfunction:: simgrid::s4u::Comm::is_suspended
2327
2328    .. group-tab:: Python
2329
2330       .. automethod:: simgrid.Comm.suspend
2331       .. automethod:: simgrid.Comm.resume
2332       .. autoattribute:: simgrid.Comm.is_suspended
2333
2334 Signals
2335 -------
2336
2337 .. tabs::
2338
2339    .. group-tab:: C++
2340
2341       .. doxygenfunction:: simgrid::s4u::Comm::on_start_cb
2342       .. doxygenfunction:: simgrid::s4u::Comm::on_this_start_cb
2343       .. doxygenfunction:: simgrid::s4u::Comm::on_completion_cb
2344       .. doxygenfunction:: simgrid::s4u::Comm::on_this_completion_cb
2345       .. doxygenfunction:: simgrid::s4u::Comm::on_recv_cb
2346       .. doxygenfunction:: simgrid::s4u::Comm::on_send_cb
2347       .. doxygenfunction:: simgrid::s4u::Comm::on_suspended_cb
2348       .. doxygenfunction:: simgrid::s4u::Comm::on_resumed_cb
2349       .. doxygenfunction:: simgrid::s4u::Comm::on_veto_cb
2350
2351 .. _API_s4u_Exec:
2352
2353 =============
2354 ⁣  class Exec
2355 =============
2356
2357 .. tabs::
2358
2359    .. group-tab:: C++
2360
2361       .. doxygenclass:: simgrid::s4u::Exec
2362
2363    .. group-tab:: Python
2364
2365       .. autoclass:: simgrid.Exec
2366
2367 Basic management
2368 ----------------
2369
2370 .. tabs::
2371
2372    .. group-tab:: C++
2373
2374       .. code-block:: C++
2375
2376          #include <simgrid/s4u/Exec.hpp>
2377
2378       .. doxygentypedef:: ExecPtr
2379
2380    .. group-tab:: Python
2381
2382       .. code:: Python
2383
2384          from simgrid import Exec
2385
2386    .. group-tab:: C
2387
2388       .. code-block:: C
2389
2390          #include <simgrid/exec.h>
2391
2392       .. doxygentypedef:: sg_exec_t
2393       .. doxygentypedef:: const_sg_exec_t
2394
2395 Querying info
2396 -------------
2397
2398 .. tabs::
2399
2400    .. group-tab:: C++
2401
2402       .. doxygenfunction:: simgrid::s4u::Exec::get_cost() const
2403       .. doxygenfunction:: simgrid::s4u::Exec::get_finish_time() const
2404       .. doxygenfunction:: simgrid::s4u::Exec::get_host() const
2405       .. doxygenfunction:: simgrid::s4u::Exec::get_host_number() const
2406       .. doxygenfunction:: simgrid::s4u::Exec::get_remaining
2407       .. doxygenfunction:: simgrid::s4u::Exec::get_remaining_ratio
2408       .. doxygenfunction:: simgrid::s4u::Exec::get_start_time() const
2409       .. doxygenfunction:: simgrid::s4u::Exec::set_bound(double bound)
2410       .. doxygenfunction:: simgrid::s4u::Exec::set_host
2411       .. doxygenfunction:: simgrid::s4u::Exec::set_priority(double priority)
2412
2413    .. group-tab:: Python
2414
2415       .. autoattribute:: simgrid.Exec.host
2416       .. autoattribute:: simgrid.Exec.remaining
2417       .. autoattribute:: simgrid.Exec.remaining_ratio
2418
2419    .. group-tab:: C
2420
2421       .. doxygenfunction:: sg_exec_set_bound(sg_exec_t exec, double bound)
2422       .. doxygenfunction:: sg_exec_get_name(const_sg_exec_t exec)
2423       .. doxygenfunction:: sg_exec_set_name(sg_exec_t exec, const char* name)
2424       .. doxygenfunction:: sg_exec_set_host(sg_exec_t exec, sg_host_t new_host)
2425       .. doxygenfunction:: sg_exec_get_remaining(const_sg_exec_t exec)
2426       .. doxygenfunction:: sg_exec_get_remaining_ratio(const_sg_exec_t exec)
2427
2428 Life cycle
2429 ----------
2430
2431 .. tabs::
2432
2433    .. group-tab:: C++
2434
2435       .. doxygenfunction:: simgrid::s4u::Exec::cancel
2436       .. doxygenfunction:: simgrid::s4u::Exec::start
2437       .. doxygenfunction:: simgrid::s4u::Exec::test
2438       .. doxygenfunction:: simgrid::s4u::Exec::wait
2439       .. doxygenfunction:: simgrid::s4u::Exec::wait_any(const std::vector< ExecPtr >& execs)
2440       .. doxygenfunction:: simgrid::s4u::Exec::wait_any_for(const std::vector< ExecPtr >& execs, double timeout)
2441       .. doxygenfunction:: simgrid::s4u::Exec::wait_for
2442
2443    .. group-tab:: Python
2444
2445        .. automethod:: simgrid.Exec.cancel
2446        .. automethod:: simgrid.Exec.start
2447        .. automethod:: simgrid.Exec.test
2448        .. automethod:: simgrid.Exec.wait
2449
2450    .. group-tab:: C
2451
2452        .. doxygenfunction:: sg_exec_start(sg_exec_t exec)
2453        .. doxygenfunction:: sg_exec_cancel(sg_exec_t exec);
2454        .. doxygenfunction:: sg_exec_test(sg_exec_t exec);
2455        .. doxygenfunction:: sg_exec_wait(sg_exec_t exec);
2456        .. doxygenfunction:: sg_exec_wait_for(sg_exec_t exec, double timeout);
2457        .. doxygenfunction:: sg_exec_wait_any_for(sg_exec_t* execs, size_t count, double timeout);
2458        .. doxygenfunction:: sg_exec_wait_any(sg_exec_t* execs, size_t count);
2459
2460 Suspending and resuming an execution
2461 ------------------------------------
2462
2463 .. tabs::
2464
2465    .. group-tab:: C++
2466
2467       .. doxygenfunction:: simgrid::s4u::Exec::suspend
2468       .. doxygenfunction:: simgrid::s4u::Exec::resume
2469       .. doxygenfunction:: simgrid::s4u::Exec::is_suspended
2470
2471    .. group-tab:: Python
2472
2473       .. automethod:: simgrid.Exec.suspend
2474       .. automethod:: simgrid.Exec.resume
2475       .. autoattribute:: simgrid.Exec.is_suspended
2476
2477 Signals
2478 -------
2479
2480 .. tabs::
2481
2482    .. group-tab:: C++
2483
2484       .. doxygenfunction:: simgrid::s4u::Exec::on_start_cb
2485       .. doxygenfunction:: simgrid::s4u::Exec::on_this_start_cb
2486       .. doxygenfunction:: simgrid::s4u::Exec::on_completion_cb
2487       .. doxygenfunction:: simgrid::s4u::Exec::on_this_completion_cb
2488
2489       .. doxygenfunction:: simgrid::s4u::Exec::on_suspended_cb
2490       .. doxygenfunction:: simgrid::s4u::Exec::on_resumed_cb
2491       .. doxygenfunction:: simgrid::s4u::Exec::on_veto_cb
2492
2493 .. _API_s4u_Io:
2494
2495 ===========
2496 ⁣  class Io
2497 ===========
2498
2499 .. tabs::
2500
2501    .. group-tab:: C++
2502
2503       .. doxygenclass:: simgrid::s4u::Io
2504
2505    .. group-tab:: Python
2506
2507       .. autoclass:: simgrid.Io
2508
2509 Basic management
2510 ----------------
2511
2512 .. tabs::
2513
2514    .. group-tab:: C++
2515
2516       .. code-block:: C++
2517
2518          #include <simgrid/s4u/Io.hpp>
2519
2520       .. doxygentypedef:: IoPtr
2521
2522 Querying info
2523 -------------
2524
2525 .. tabs::
2526
2527    .. group-tab:: C++
2528
2529       .. doxygenfunction:: simgrid::s4u::Io::get_performed_ioops() const
2530       .. doxygenfunction:: simgrid::s4u::Io::get_remaining
2531
2532 Life cycle
2533 ----------
2534
2535 .. tabs::
2536
2537    .. group-tab:: C++
2538
2539       .. doxygenfunction:: simgrid::s4u::Io::cancel
2540       .. doxygenfunction:: simgrid::s4u::Io::start
2541       .. doxygenfunction:: simgrid::s4u::Io::test
2542       .. doxygenfunction:: simgrid::s4u::Io::wait
2543       .. doxygenfunction:: simgrid::s4u::Io::wait_for
2544       .. doxygenfunction:: simgrid::s4u::Io::wait_any(const std::vector<IoPtr> &ios)
2545       .. doxygenfunction:: simgrid::s4u::Io::wait_any_for(const std::vector<IoPtr> &ios, double timeout)
2546
2547    .. group-tab:: Python
2548
2549       .. automethod:: simgrid.Io.test
2550       .. automethod:: simgrid.Io.wait
2551       .. automethod:: simgrid.Io.wait_any_for
2552       .. automethod:: simgrid.Io.wait_any
2553
2554 Signals
2555 -------
2556
2557 .. tabs::
2558
2559    .. group-tab:: C++
2560
2561       .. doxygenfunction:: simgrid::s4u::Io::on_start_cb
2562       .. doxygenfunction:: simgrid::s4u::Io::on_this_start_cb
2563       .. doxygenfunction:: simgrid::s4u::Io::on_completion_cb
2564       .. doxygenfunction:: simgrid::s4u::Io::on_this_completion_cb
2565
2566       .. doxygenfunction:: simgrid::s4u::Io::on_suspended_cb
2567       .. doxygenfunction:: simgrid::s4u::Io::on_resumed_cb
2568       .. doxygenfunction:: simgrid::s4u::Io::on_veto_cb
2569
2570
2571 .. _API_s4u_Tasks:
2572
2573 ==========
2574 Tasks
2575 ==========
2576
2577 ==============
2578 class Task
2579 ==============
2580
2581 .. doxygenclass:: simgrid::s4u::Task
2582
2583 **Known subclasses:**
2584 :ref:`Communication Tasks <API_s4u_CommTask>`,
2585 :ref:`Executions Tasks <API_s4u_ExecTask>`,
2586 :ref:`I/O Tasks <API_s4u_Task>`.
2587 See also the :ref:`section on activities <s4u_Tasks>` above.
2588
2589 Basic management
2590 ----------------
2591
2592 .. tabs::
2593
2594    .. group-tab:: C++
2595
2596       .. code-block:: C++
2597
2598          #include <simgrid/s4u/Task.hpp>
2599
2600       .. doxygentypedef:: TaskPtr
2601
2602 Querying info
2603 -------------
2604
2605 .. tabs::
2606
2607    .. group-tab:: C++
2608
2609       .. doxygenfunction:: simgrid::s4u::Task::get_cname() const
2610       .. doxygenfunction:: simgrid::s4u::Task::get_name() const
2611       .. doxygenfunction:: simgrid::s4u::Task::get_count() const
2612       .. doxygenfunction:: simgrid::s4u::Task::get_amount() const
2613       .. doxygenfunction:: simgrid::s4u::Task::set_amount(double amount)
2614
2615 Life cycle
2616 ----------
2617
2618 .. tabs::
2619
2620    .. group-tab:: C++
2621       .. doxygenfunction:: simgrid::s4u::Task::enqueue_firings(int n)
2622
2623 Managing Dependencies
2624 ---------------------
2625 .. tabs::
2626
2627    .. group-tab:: C++
2628       .. doxygenfunction:: simgrid::s4u::Task::add_successor(TaskPtr t)
2629       .. doxygenfunction:: simgrid::s4u::Task::remove_successor(TaskPtr t)
2630       .. doxygenfunction:: simgrid::s4u::Task::remove_all_successors()
2631       .. doxygenfunction:: simgrid::s4u::Task::get_successors() const
2632
2633 Managing Tokens
2634 ---------------
2635 .. doxygenclass:: simgrid::s4u::Token
2636
2637 .. tabs::
2638
2639    .. group-tab:: C++
2640       .. doxygenfunction:: simgrid::s4u::Task::set_token(std::shared_ptr<Token> token)
2641       .. doxygenfunction:: simgrid::s4u::Task::get_next_token_from(TaskPtr t)
2642
2643 Signals
2644 -------
2645
2646 .. tabs::
2647
2648    .. group-tab:: C++
2649       .. doxygenfunction:: simgrid::s4u::Task::on_start_cb
2650       .. doxygenfunction:: simgrid::s4u::Task::on_this_start_cb
2651       .. doxygenfunction:: simgrid::s4u::Task::on_completion_cb
2652       .. doxygenfunction:: simgrid::s4u::Task::on_this_completion_cb
2653
2654 .. _API_s4u_CommTask:
2655
2656 ================
2657 ⁣  class CommTask
2658 ================
2659 .. tabs::
2660
2661    .. group-tab:: C++
2662
2663       .. doxygenclass:: simgrid::s4u::CommTask
2664
2665 Basic management
2666 ----------------
2667
2668 .. tabs::
2669
2670    .. group-tab:: C++
2671
2672       .. code-block:: C++
2673
2674          #include <simgrid/s4u/Task.hpp>
2675
2676       .. doxygentypedef:: CommTaskPtr
2677
2678 Querying info
2679 -------------
2680
2681 .. tabs::
2682
2683    .. group-tab:: C++
2684
2685       .. doxygenfunction:: simgrid::s4u::Task::get_source() const
2686       .. doxygenfunction:: simgrid::s4u::Task::get_destination() const
2687       .. doxygenfunction:: simgrid::s4u::Task::get_bytes() const
2688       .. doxygenfunction:: simgrid::s4u::Task::set_source(simgrid::s4u::Host* source);
2689       .. doxygenfunction:: simgrid::s4u::Task::set_destination(simgrid::s4u::Host* destination);
2690       .. doxygenfunction:: simgrid::s4u::Task::set_bytes(double bytes)
2691
2692
2693 .. _API_s4u_ExecTask:
2694
2695 ================
2696 ⁣  class ExecTask
2697 ================
2698 .. tabs::
2699
2700    .. group-tab:: C++
2701
2702       .. doxygenclass:: simgrid::s4u::ExecTask
2703
2704 Basic management
2705 ----------------
2706
2707 .. tabs::
2708
2709    .. group-tab:: C++
2710
2711       .. code-block:: C++
2712
2713          #include <simgrid/s4u/Task.hpp>
2714
2715       .. doxygentypedef:: ExecTaskPtr
2716
2717 Querying info
2718 -------------
2719
2720 .. tabs::
2721
2722    .. group-tab:: C++
2723
2724       .. doxygenfunction:: simgrid::s4u::Task::get_host() const
2725       .. doxygenfunction:: simgrid::s4u::Task::get_flops() const
2726       .. doxygenfunction:: simgrid::s4u::Task::set_host(simgrid::s4u::Host* host);
2727       .. doxygenfunction:: simgrid::s4u::Task::set_flops(double flops);
2728
2729 .. _API_s4u_IoTask:
2730
2731 ================
2732 ⁣  class IoTask
2733 ================
2734 .. tabs::
2735
2736    .. group-tab:: C++
2737
2738       .. doxygenclass:: simgrid::s4u::IoTask
2739
2740 Basic management
2741 ----------------
2742
2743 .. tabs::
2744
2745    .. group-tab:: C++
2746
2747       .. code-block:: C++
2748
2749          #include <simgrid/s4u/Task.hpp>
2750
2751       .. doxygentypedef:: IoTaskPtr
2752
2753 Querying info
2754 -------------
2755
2756 .. tabs::
2757
2758    .. group-tab:: C++
2759
2760      .. doxygenfunction:: simgrid::s4u::Task::get_disk() const
2761      .. doxygenfunction:: simgrid::s4u::Task::get_bytes() const
2762      .. doxygenfunction:: simgrid::s4u::Task::get_op_type() const
2763      .. doxygenfunction:: simgrid::s4u::Task::set_disk(simgrid::s4u::Disk* disk);
2764      .. doxygenfunction:: simgrid::s4u::Task::set_bytes(simgrid::double bytes);
2765      .. doxygenfunction:: simgrid::s4u::Task::set_op_type(simgrid::s4u::Io::OpType type);
2766
2767 .. _API_s4u_Synchronizations:
2768
2769 =======================
2770 Synchronization Objects
2771 =======================
2772
2773 .. _API_s4u_Mutex:
2774
2775 ==============
2776 ⁣  Mutex
2777 ==============
2778
2779 .. tabs::
2780
2781    .. group-tab:: C++
2782
2783       .. doxygenclass:: simgrid::s4u::Mutex
2784
2785    .. group-tab:: Python
2786
2787       .. autoclass:: simgrid.Mutex
2788
2789 Basic management
2790 ----------------
2791
2792    .. tabs::
2793
2794       .. group-tab:: C++
2795
2796          .. code-block:: C++
2797
2798             #include <simgrid/s4u/Mutex.hpp>
2799
2800          .. doxygentypedef:: MutexPtr
2801
2802          .. doxygenfunction:: simgrid::s4u::Mutex::create()
2803
2804       .. group-tab:: Python
2805
2806          .. code-block:: Python
2807
2808             from simgrid import Mutex
2809             mutex = Mutex()
2810
2811             # Use a context manager to acquire and automatically release the mutex
2812             # when leaving the scope.
2813             with mutex:
2814                 # Access shared resource ...
2815                 pass
2816
2817          .. automethod:: simgrid.Mutex.__init__
2818
2819       .. group-tab:: C
2820
2821          .. code-block:: C
2822
2823             #include <simgrid/mutex.h>
2824
2825          .. doxygentypedef:: sg_mutex_t
2826          .. cpp:type:: const s4u_Mutex* const_sg_mutex_t
2827
2828             Pointer to a constant mutex object.
2829
2830          .. doxygenfunction:: sg_mutex_init()
2831          .. doxygenfunction:: sg_mutex_destroy(const_sg_mutex_t mutex)
2832
2833 Locking
2834 -------
2835
2836    .. tabs::
2837
2838       .. group-tab:: C++
2839
2840          .. doxygenfunction:: simgrid::s4u::Mutex::lock()
2841          .. doxygenfunction:: simgrid::s4u::Mutex::try_lock()
2842          .. doxygenfunction:: simgrid::s4u::Mutex::unlock()
2843
2844       .. group-tab:: Python
2845
2846          .. automethod:: simgrid.Mutex.lock
2847          .. automethod:: simgrid.Mutex.try_lock
2848          .. automethod:: simgrid.Mutex.unlock
2849
2850       .. group-tab:: C
2851
2852          .. doxygenfunction:: sg_mutex_lock(sg_mutex_t mutex)
2853          .. doxygenfunction:: sg_mutex_try_lock(sg_mutex_t mutex)
2854          .. doxygenfunction:: sg_mutex_unlock(sg_mutex_t mutex)
2855
2856 .. _API_s4u_Barrier:
2857
2858 ================
2859 ⁣  Barrier
2860 ================
2861
2862 .. tabs::
2863
2864    .. group-tab:: C++
2865
2866       .. doxygenclass:: simgrid::s4u::Barrier
2867
2868    .. group-tab:: Python
2869
2870       .. autoclass:: simgrid.Barrier
2871
2872 .. tabs::
2873
2874    .. group-tab:: C++
2875
2876       .. code-block:: C++
2877
2878          #include <simgrid/s4u/Barrier.hpp>
2879
2880       .. doxygentypedef:: BarrierPtr
2881
2882       .. doxygenfunction:: simgrid::s4u::Barrier::create(unsigned int expected_actors)
2883       .. doxygenfunction:: simgrid::s4u::Barrier::wait()
2884
2885    .. group-tab:: Python
2886
2887       .. code-block:: Python
2888
2889          from simgrid import Barrier
2890          barrier = Barrier(2)
2891
2892       .. automethod:: simgrid.Barrier.__init__
2893       .. automethod:: simgrid.Barrier.wait
2894
2895    .. group-tab:: C
2896
2897       .. code-block:: C
2898
2899          #include <simgrid/barrier.hpp>
2900
2901       .. doxygentypedef:: sg_bar_t
2902
2903       .. doxygenfunction:: sg_barrier_init(unsigned int count)
2904       .. doxygenfunction:: sg_barrier_destroy(sg_bar_t bar)
2905       .. doxygenfunction:: sg_barrier_wait(sg_bar_t bar)
2906
2907
2908 .. _API_s4u_ConditionVariable:
2909
2910 ==========================
2911 ⁣  Condition variable
2912 ==========================
2913
2914 .. doxygenclass:: simgrid::s4u::ConditionVariable
2915
2916 Basic management
2917 ----------------
2918
2919    .. tabs::
2920
2921       .. group-tab:: C++
2922
2923          .. code-block:: C++
2924
2925             #include <simgrid/s4u/ConditionVariable.hpp>
2926
2927          .. doxygentypedef:: ConditionVariablePtr
2928
2929          .. doxygenfunction:: simgrid::s4u::ConditionVariable::create()
2930
2931       .. group-tab:: C
2932
2933          .. code-block:: C
2934
2935             #include <simgrid/cond.h>
2936
2937          .. doxygentypedef:: sg_cond_t
2938          .. doxygentypedef:: const_sg_cond_t
2939          .. doxygenfunction:: sg_cond_init
2940          .. doxygenfunction:: sg_cond_destroy
2941
2942 Waiting and notifying
2943 ---------------------
2944
2945    .. tabs::
2946
2947       .. group-tab:: C++
2948
2949          .. doxygenfunction:: simgrid::s4u::ConditionVariable::notify_all()
2950          .. doxygenfunction:: simgrid::s4u::ConditionVariable::notify_one()
2951          .. doxygenfunction:: simgrid::s4u::ConditionVariable::wait(s4u::MutexPtr lock)
2952          .. doxygenfunction:: simgrid::s4u::ConditionVariable::wait(const std::unique_lock< s4u::Mutex > &lock)
2953          .. doxygenfunction:: simgrid::s4u::ConditionVariable::wait(const std::unique_lock< Mutex > &lock, P pred)
2954          .. doxygenfunction:: simgrid::s4u::ConditionVariable::wait_for(const std::unique_lock< s4u::Mutex > &lock, double duration)
2955          .. doxygenfunction:: simgrid::s4u::ConditionVariable::wait_for(const std::unique_lock< s4u::Mutex > &lock, double duration, P pred)
2956          .. doxygenfunction:: simgrid::s4u::ConditionVariable::wait_for(const std::unique_lock< s4u::Mutex > &lock, std::chrono::duration< Rep, Period > duration)
2957          .. doxygenfunction:: simgrid::s4u::ConditionVariable::wait_for(const std::unique_lock< s4u::Mutex > &lock, std::chrono::duration< Rep, Period > duration, P pred)
2958          .. doxygenfunction:: simgrid::s4u::ConditionVariable::wait_until(const std::unique_lock< s4u::Mutex > &lock, const SimulationTimePoint< Duration > &timeout_time)
2959          .. doxygenfunction:: simgrid::s4u::ConditionVariable::wait_until(const std::unique_lock< s4u::Mutex > &lock, const SimulationTimePoint< Duration > &timeout_time, P pred)
2960          .. doxygenfunction:: simgrid::s4u::ConditionVariable::wait_until(const std::unique_lock< s4u::Mutex > &lock, double timeout_time)
2961          .. doxygenfunction:: simgrid::s4u::ConditionVariable::wait_until(const std::unique_lock< s4u::Mutex > &lock, double timeout_time, P pred)
2962
2963       .. group-tab:: C
2964
2965          .. doxygenfunction:: sg_cond_notify_all
2966          .. doxygenfunction:: sg_cond_notify_one
2967          .. doxygenfunction:: sg_cond_wait
2968          .. doxygenfunction:: sg_cond_wait_for
2969
2970 .. _API_s4u_Semaphore:
2971
2972 ==================
2973 ⁣  Semaphore
2974 ==================
2975
2976 .. tabs::
2977
2978    .. group-tab:: C++
2979
2980       .. doxygenclass:: simgrid::s4u::Semaphore
2981
2982    .. group-tab:: Python
2983
2984       .. autoclass:: simgrid.Semaphore
2985
2986 Basic management
2987 ----------------
2988
2989    .. tabs::
2990
2991       .. group-tab:: C++
2992
2993          .. code-block:: C++
2994
2995             #include <simgrid/s4u/Semaphore.hpp>
2996
2997          .. doxygentypedef:: SemaphorePtr
2998          .. doxygenfunction:: simgrid::s4u::Semaphore::create(unsigned int initial_capacity)
2999
3000       .. group-tab:: Python
3001
3002          .. code-block:: Python
3003
3004             from simgrid import Semaphore
3005             semaphore = Semaphore(1)
3006             # Automatically acquire the semaphore, and release it after leaving the scope.
3007             with semaphore:
3008                 # Do something with the shared resource
3009                 pass
3010
3011          .. automethod:: simgrid.Semaphore.__init__
3012
3013       .. group-tab:: C
3014
3015          .. code-block:: C
3016
3017             #include <simgrid/semaphore.h>
3018
3019          .. doxygentypedef:: sg_sem_t
3020          .. cpp:type:: const s4u_Semaphore* const_sg_sem_t
3021
3022             Pointer to a constant semaphore object.
3023
3024          .. doxygenfunction:: sg_sem_init(int initial_value)
3025          .. doxygenfunction:: sg_sem_destroy(const_sg_sem_t sem)
3026
3027 Locking
3028 -------
3029
3030    .. tabs::
3031
3032       .. group-tab:: C++
3033
3034          .. doxygenfunction:: simgrid::s4u::Semaphore::acquire()
3035          .. doxygenfunction:: simgrid::s4u::Semaphore::acquire_timeout(double timeout)
3036          .. doxygenfunction:: simgrid::s4u::Semaphore::get_capacity() const
3037          .. doxygenfunction:: simgrid::s4u::Semaphore::release()
3038          .. doxygenfunction:: simgrid::s4u::Semaphore::would_block() const
3039
3040       .. group-tab:: Python
3041
3042          .. automethod:: simgrid.Semaphore.acquire
3043          .. automethod:: simgrid.Semaphore.acquire_timeout
3044          .. autoattribute:: simgrid.Semaphore.capacity
3045          .. automethod:: simgrid.Semaphore.release
3046          .. autoattribute:: simgrid.Semaphore.would_block
3047
3048       .. group-tab:: C
3049
3050          .. doxygenfunction:: sg_sem_acquire(sg_sem_t sem)
3051          .. doxygenfunction:: sg_sem_acquire_timeout(sg_sem_t sem, double timeout)
3052          .. doxygenfunction:: sg_sem_get_capacity(const_sg_sem_t sem)
3053          .. doxygenfunction:: sg_sem_release(sg_sem_t sem)
3054          .. doxygenfunction:: sg_sem_would_block(const_sg_sem_t sem)
3055
3056 ===============
3057 Error reporting
3058 ===============
3059
3060 .. tabs::
3061
3062    .. group-tab:: C++
3063
3064       .. doxygenclass:: simgrid::Exception
3065
3066       The following exceptions denote a problem in the simulated platform, and it is often useful to catch them.
3067
3068       .. doxygenclass:: simgrid::CancelException
3069       .. doxygenclass:: simgrid::HostFailureException
3070       .. doxygenclass:: simgrid::NetworkFailureException
3071       .. doxygenclass:: simgrid::StorageFailureException
3072       .. doxygenclass:: simgrid::TimeoutException
3073       .. doxygenclass:: simgrid::VmFailureException
3074
3075       The following errors denote a problem in the SimGrid tool itself. Most of the time, you should let these
3076       exception go, so that the simulation stops. But you may want to catch them, for example when you launch
3077       SimGrid from a python notebook and want to handle the problem accordingly.
3078
3079       .. doxygenclass:: simgrid::AssertionError
3080       .. doxygenclass:: simgrid::ParseError
3081       .. doxygenclass:: simgrid::TracingError
3082
3083    .. group-tab:: Python
3084
3085       The following exceptions denote a problem in the simulated platform, and it is often useful to catch them.
3086
3087       .. autoclass:: simgrid.CancelException
3088       .. autoclass:: simgrid.HostFailureException
3089       .. autoclass:: simgrid.NetworkFailureException
3090       .. autoclass:: simgrid.StorageFailureException
3091       .. autoclass:: simgrid.TimeoutException
3092       .. autoclass:: simgrid.VmFailureException
3093
3094       The following errors denote a problem in the SimGrid tool itself. Most of the time, you should let these
3095       exception go, so that the simulation stops. But you may want to catch them, for example when you launch
3096       SimGrid from a python notebook and want to handle the problem accordingly.
3097
3098       .. autoclass:: simgrid.AssertionError
3099
3100    .. group-tab:: C
3101
3102       .. doxygenenum:: sg_error_t
3103
3104
3105 .. |hr| raw:: html
3106
3107    <hr />