Partial list of existing signals in s4u:
-- :cpp:member:`Actor::on_creation <simgrid::s4u::Actor::on_creation_cb>`
- :cpp:member:`Actor::on_suspend <simgrid::s4u::Actor::on_suspend_cb>`
- :cpp:member:`Actor::on_resume <simgrid::s4u::Actor::on_resume_cb>`
- :cpp:member:`Actor::on_sleep <simgrid::s4u::Actor::on_sleep_cb>`
- :cpp:member:`Actor::on_wake_up <simgrid::s4u::Actor::on_wake_up_cb>`
- :cpp:member:`Actor::on_host_change <simgrid::s4u::Actor::on_host_change_cb>`
- :cpp:member:`Actor::on_termination <simgrid::s4u::Actor::on_termination_cb>`
- :cpp:member:`Actor::on_destruction <simgrid::s4u::Actor::on_destruction_cb>`
-- :cpp:member:`Comm::on_send <simgrid::s4u::Comm::on_send_cb>`
- :cpp:member:`Comm::on_recv <simgrid::s4u::Comm::on_recv_cb>`
- :cpp:member:`Comm::on_completion <simgrid::s4u::Comm::on_completion_cb>`
-- :cpp:member:`CommImpl::on_start <simgrid::kernel::actiivty::CommImpl::on_start_cb>`
- :cpp:member:`CommImpl::on_completion <simgrid::kernel::activity::CommImpl::on_completion_cb>`
-- :cpp:member:`Disk::on_creation <simgrid::s4u::Disk::on_creation_cb>`
- :cpp:member:`Disk::on_destruction <simgrid::s4u::Disk::on_destruction_cb>`
- :cpp:member:`Disk::on_state_change <simgrid::s4u::Disk::on_state_change_cb>`
-- :cpp:member:`Engine::on_platform_creation <simgrid::s4u::Engine::on_platform_creation_cb>`
- :cpp:member:`Engine::on_platform_created <simgrid::s4u::Engine::on_platform_created_cb>`
- :cpp:member:`Engine::on_time_advance <simgrid::s4u::Engine::on_time_advance_cb>`
- :cpp:member:`Engine::on_simulation_end <simgrid::s4u::Engine::on_simulation_end_cb>`
- :cpp:member:`Engine::on_deadlock <simgrid::s4u::Engine::on_deadlock_cb>`
-- :cpp:member:`Exec::on_start <simgrid::s4u::Exec::on_start_cb>`
- :cpp:member:`Exec::on_completion <simgrid::s4u::Exec::on_completion_cb>`
-- :cpp:member:`Host::on_creation <simgrid::s4u::Host::on_creation_cb>`
- :cpp:member:`Host::on_destruction <simgrid::s4u::Host::on_destruction_cb>`
- :cpp:member:`Host::on_state_change <simgrid::s4u::Host::on_state_change_cb>`
- :cpp:member:`Host::on_speed_change <simgrid::s4u::Host::on_speed_change_cb>`
-- :cpp:member:`Io::on_start <simgrid::s4u::Io::on_start_cb>`
- :cpp:member:`Io::on_completion <simgrid::s4u::Io::on_completion_cb>`
-- :cpp:member:`Link::on_creation <simgrid::s4u::Link::on_creation_cb>`
- :cpp:member:`Link::on_destruction <simgrid::s4u::Link::on_destruction_cb>`
- :cpp:member:`Link::on_state_change <simgrid::s4u::Link::on_state_change_cb>`
- :cpp:member:`Link::on_speed_change <simgrid::s4u::Link::on_bandwidth_change_cb>`
- :cpp:member:`Link::on_communication_state_change <simgrid::s4u::Link::on_communication_state_change_cb>`
-- :cpp:member:`NetZone::on_creation <simgrid::s4u::NetZone::on_creation_cb>`
- :cpp:member:`NetZone::on_seal <simgrid::s4u::NetZone::on_seal_cb>`
-- :cpp:member:`VirtualMachine::on_start <simgrid::s4u::VirtualMachine::on_start_cb>`
- :cpp:member:`VirtualMachine::on_started <simgrid::s4u::VirtualMachine::on_started_cb>`
- :cpp:member:`VirtualMachine::on_suspend <simgrid::s4u::VirtualMachine::on_suspend_cb>`
- :cpp:member:`VirtualMachine::on_resume <simgrid::s4u::VirtualMachine::on_resume_cb>`
- :cpp:member:`VirtualMachine::on_migration_start <simgrid::s4u::VirtualMachine::on_migration_start_cb>`
- :cpp:member:`VirtualMachine::on_migration_end <simgrid::s4u::VirtualMachine::on_migration_end_cb>`
+- :cpp:func:`Actor::on_creation <simgrid::s4u::Actor::on_creation_cb>`
+ :cpp:func:`Actor::on_suspend <simgrid::s4u::Actor::on_suspend_cb>`
+ :cpp:func:`Actor::on_resume <simgrid::s4u::Actor::on_resume_cb>`
+ :cpp:func:`Actor::on_sleep <simgrid::s4u::Actor::on_sleep_cb>`
+ :cpp:func:`Actor::on_wake_up <simgrid::s4u::Actor::on_wake_up_cb>`
+ :cpp:func:`Actor::on_host_change <simgrid::s4u::Actor::on_host_change_cb>`
+ :cpp:func:`Actor::on_termination <simgrid::s4u::Actor::on_termination_cb>`
+ :cpp:func:`Actor::on_destruction <simgrid::s4u::Actor::on_destruction_cb>`
+- :cpp:func:`Comm::on_send <simgrid::s4u::Comm::on_send_cb>`
+ :cpp:func:`Comm::on_recv <simgrid::s4u::Comm::on_recv_cb>`
+ :cpp:func:`Comm::on_completion <simgrid::s4u::Comm::on_completion_cb>`
+- :cpp:func:`CommImpl::on_start <simgrid::s4u::Comm::on_start_cb>`
+ :cpp:func:`CommImpl::on_completion <simgrid::s4u::Comm::on_completion_cb>`
+- :cpp:func:`Disk::on_creation <simgrid::s4u::Disk::on_creation_cb>`
+ :cpp:func:`Disk::on_destruction <simgrid::s4u::Disk::on_destruction_cb>`
+ :cpp:func:`Disk::on_state_change <simgrid::s4u::Disk::on_state_change_cb>`
+- :cpp:func:`Engine::on_platform_creation <simgrid::s4u::Engine::on_platform_creation_cb>`
+ :cpp:func:`Engine::on_platform_created <simgrid::s4u::Engine::on_platform_created_cb>`
+ :cpp:func:`Engine::on_time_advance <simgrid::s4u::Engine::on_time_advance_cb>`
+ :cpp:func:`Engine::on_simulation_end <simgrid::s4u::Engine::on_simulation_end_cb>`
+ :cpp:func:`Engine::on_deadlock <simgrid::s4u::Engine::on_deadlock_cb>`
+- :cpp:func:`Exec::on_start <simgrid::s4u::Exec::on_start_cb>`
+ :cpp:func:`Exec::on_completion <simgrid::s4u::Exec::on_completion_cb>`
+- :cpp:func:`Host::on_creation <simgrid::s4u::Host::on_creation_cb>`
+ :cpp:func:`Host::on_destruction <simgrid::s4u::Host::on_destruction_cb>`
+ :cpp:func:`Host::on_state_change <simgrid::s4u::Host::on_state_change_cb>`
+ :cpp:func:`Host::on_speed_change <simgrid::s4u::Host::on_speed_change_cb>`
+- :cpp:func:`Io::on_start <simgrid::s4u::Io::on_start_cb>`
+ :cpp:func:`Io::on_completion <simgrid::s4u::Io::on_completion_cb>`
+- :cpp:func:`Link::on_creation <simgrid::s4u::Link::on_creation_cb>`
+ :cpp:func:`Link::on_destruction <simgrid::s4u::Link::on_destruction_cb>`
+ :cpp:func:`Link::on_state_change <simgrid::s4u::Link::on_state_change_cb>`
+ :cpp:func:`Link::on_speed_change <simgrid::s4u::Link::on_bandwidth_change_cb>`
+ :cpp:func:`Link::on_communication_state_change <simgrid::s4u::Link::on_communication_state_change_cb>`
+- :cpp:func:`NetZone::on_creation <simgrid::s4u::NetZone::on_creation_cb>`
+ :cpp:func:`NetZone::on_seal <simgrid::s4u::NetZone::on_seal_cb>`
+- :cpp:func:`VirtualMachine::on_start <simgrid::s4u::VirtualMachine::on_start_cb>`
+ :cpp:func:`VirtualMachine::on_started <simgrid::s4u::VirtualMachine::on_started_cb>`
+ :cpp:func:`VirtualMachine::on_suspend <simgrid::s4u::VirtualMachine::on_suspend_cb>`
+ :cpp:func:`VirtualMachine::on_resume <simgrid::s4u::VirtualMachine::on_resume_cb>`
+ :cpp:func:`VirtualMachine::on_migration_start <simgrid::s4u::VirtualMachine::on_migration_start_cb>`
+ :cpp:func:`VirtualMachine::on_migration_end <simgrid::s4u::VirtualMachine::on_migration_end_cb>`
Existing Plugins
****************
Lab 1: Simpler deployments
--------------------------
-.. rst-class:: learning-goals
+.. rst-class:: compact-list
**Learning goals:**
Lab 2: Using the Whole Platform
-------------------------------
-.. rst-class:: learning-goals
+.. rst-class:: compact-list
**Learning goals:**
Lab 3: Fixed Experiment Duration
--------------------------------
-.. rst-class:: learning-goals
+.. rst-class:: compact-list
**Learning goals:**
Lab 4: What-if analysis
-----------------------
-.. rst-class:: learning-goals
+.. rst-class:: compact-list
**Learning goals:**
Lab 5: Competing Applications
-----------------------------
-.. rst-class:: learning-goals
+.. rst-class:: compact-list
**Learning goals:**
div[itemprop="articleBody"] {
word-wrap: break-word;
}
-ul.learning-goals {
+ul.compact-list {
line-height: 80%;
margin-left: 2em;
padding: 0.2em;
margin-bottom: 1em;
}
-ul.learning-goals li {
+ul.compact-list li {
list-style: disc;
}
-ul.learning-goals li p {
+ul.compact-list li p {
margin-bottom: 0;
}
-p.learning-goals {
+p.compact-list {
margin-bottom: 0;
}
The :ref:`simgrid::s4u::this_actor <API_s4u_this_actor>` namespace
provides many helper functions to simplify the code of actors.
-- **Simulation Elements**
-
- - :ref:`class Actor <API_s4u_Actor>`:
- Active entities executing your application.
- - :ref:`class Engine <API_s4u_Engine>`
- Simulation engine (singleton).
- - :ref:`class Mailbox <API_s4u_Mailbox>`
- Communication rendezvous, with which actors meet each other.
-
-- **Resources**
-
- - :ref:`class Disk <API_s4u_Disk>`
- Resource on which actors can write and read data.
- - :ref:`class Host <API_s4u_Host>`:
- Actor location, providing computational power.
- - :ref:`class Link <API_s4u_Link>`
- Interconnecting hosts.
- - :ref:`class NetZone <API_s4u_NetZone>`:
- Sub-region of the platform, containing resources (Hosts, Links, etc).
- - :ref:`class VirtualMachine <API_s4u_VirtualMachine>`:
- Execution containers that can be moved between Hosts.
-
-- **Activities** (:ref:`class Activity <API_s4u_Activity>`):
- The things that actors can do on resources
-
- - :ref:`class Comm <API_s4u_Comm>`
- Communication activity, started on Mailboxes and consuming links.
- - :ref:`class Exec <API_s4u_Exec>`
- Computation activity, started on Host and consuming CPU resources.
- - :ref:`class Io <API_s4u_Io>`
- I/O activity, started on and consuming disks.
-
-- **Synchronization Objects**: Classical IPC that actors can use
-
- - :ref:`class Barrier <API_s4u_Barrier>`
- - :ref:`class ConditionVariable <API_s4u_ConditionVariable>`
- - :ref:`class Mutex <API_s4u_Mutex>`
- - :ref:`class Semaphore <API_s4u_Semaphore>`
+.. rst-class:: compact-list
+ - **Simulation Elements**
+
+ - :ref:`class Actor <API_s4u_Actor>`: Active entities executing your application.
+ - :ref:`class Engine <API_s4u_Engine>`: Simulation engine (singleton).
+ - :ref:`class Mailbox <API_s4u_Mailbox>`: Communication rendezvous, with which actors meet each other.
+
+ - **Resources**
+
+ - :ref:`class Disk <API_s4u_Disk>`: Resource on which actors can write and read data.
+ - :ref:`class Host <API_s4u_Host>`: Actor location, providing computational power.
+ - :ref:`class Link <API_s4u_Link>`: Interconnecting hosts.
+ - :ref:`class NetZone <API_s4u_NetZone>`: Sub-region of the platform, containing resources (Hosts, Links, etc).
+ - :ref:`class VirtualMachine <API_s4u_VirtualMachine>`: Execution containers that can be moved between Hosts.
+
+ - **Activities** (:ref:`class Activity <API_s4u_Activity>`): The things that actors can do on resources.
+
+ - :ref:`class Comm <API_s4u_Comm>`: Communication activity, started on Mailboxes and consuming links.
+ - :ref:`class Exec <API_s4u_Exec>`: Computation activity, started on Host and consuming CPU resources.
+ - :ref:`class Io <API_s4u_Io>`: I/O activity, started on and consuming disks.
+
+ - **Synchronization Objects**: Classical IPC that actors can use
+
+ - :ref:`class Barrier <API_s4u_Barrier>`
+ - :ref:`class ConditionVariable <API_s4u_ConditionVariable>`
+ - :ref:`class Mutex <API_s4u_Mutex>`
+ - :ref:`class Semaphore <API_s4u_Semaphore>`
.. |API_s4u_Actors| replace:: **Actors**
.. _API_s4u_Actors: #api-s4u-actor
Finally, to wait at most until a specified time limit, use
:cpp:func:`s4u::Activity::wait_until() <simgrid::s4u::Activity::wait_until>`.
-Every kind of activity can be asynchronous:
-
- - :ref:`s4u::CommPtr <API_s4u_Comm>` are created with
- :cpp:func:`s4u::Mailbox::put_async() <simgrid::s4u::Mailbox::put_async>` and
- :cpp:func:`s4u::Mailbox::get_async() <simgrid::s4u::Mailbox::get_async>`.
- - :ref:`s4u::IoPtr <API_s4u_Io>` are created with
- :cpp:func:`s4u::Disk::read_async() <simgrid::s4u::Disk::read_async>` and
- :cpp:func:`s4u::Disk::write_async() <simgrid::s4u::Disk::write_async>`.
- - :ref:`s4u::ExecPtr <API_s4u_Exec>` are created with
- :cpp:func:`s4u::Host::exec_async() <simgrid::s4u::Host::exec_async>`.
- - In the future, it will become possible to have asynchronous IPC
- such as asynchronous mutex lock requests.
+Every kind of activity can be asynchronous.
+:ref:`s4u::CommPtr <API_s4u_Comm>` are created with :cpp:func:`s4u::Mailbox::put_async() <simgrid::s4u::Mailbox::put_async>` and
+:cpp:func:`s4u::Mailbox::get_async() <simgrid::s4u::Mailbox::get_async>`;
+:ref:`s4u::IoPtr <API_s4u_Io>` are created with :cpp:func:`s4u::Disk::read_async() <simgrid::s4u::Disk::read_async>` and
+:cpp:func:`s4u::Disk::write_async() <simgrid::s4u::Disk::write_async>`; and
+:ref:`s4u::ExecPtr <API_s4u_Exec>` are created with
+:cpp:func:`s4u::Host::exec_async() <simgrid::s4u::Host::exec_async>`.
+In the future, it will become possible to have asynchronous IPC such as asynchronous mutex lock requests.
The following example shows how to have several concurrent
communications ongoing. First, you have to declare a vector in which
:language: c++
:start-after: init-begin
:end-before: init-end
- :dedent: 4
+ :dedent: 2
Then, you start all the communications that should occur concurrently with
:cpp:func:`s4u::Mailbox::put_async() <simgrid::s4u::Mailbox::put_async>`.
Finally, the actor waits for the completion of all of them at once
-with
-:cpp:func:`s4u::Comm::wait_all() <simgrid::s4u::Comm::wait_all>`.
+with :cpp:func:`s4u::Comm::wait_all() <simgrid::s4u::Comm::wait_all>`.
.. literalinclude:: ../../examples/cpp/comm-waitall/s4u-comm-waitall.cpp
:language: c++
:start-after: put-begin
:end-before: put-end
- :dedent: 4
-
+ :dedent: 2
=====================
Activities Life cycle
.. group-tab:: C++
- .. doxygenvariable:: simgrid::s4u::Actor::on_creation
- .. doxygenvariable:: simgrid::s4u::Actor::on_suspend
- .. doxygenvariable:: simgrid::s4u::Actor::on_host_change
- .. doxygenvariable:: simgrid::s4u::Actor::on_resume
- .. doxygenvariable:: simgrid::s4u::Actor::on_sleep
- .. doxygenvariable:: simgrid::s4u::Actor::on_wake_up
- .. doxygenvariable:: simgrid::s4u::Actor::on_termination
- .. doxygenvariable:: simgrid::s4u::Actor::on_destruction
+ .. doxygenfunction:: simgrid::s4u::Actor::on_creation_cb
+ .. doxygenfunction:: simgrid::s4u::Actor::on_suspend_cb
+ .. doxygenfunction:: simgrid::s4u::Actor::on_host_change_cb
+ .. doxygenfunction:: simgrid::s4u::Actor::on_resume_cb
+ .. doxygenfunction:: simgrid::s4u::Actor::on_sleep_cb
+ .. doxygenfunction:: simgrid::s4u::Actor::on_wake_up_cb
+ .. doxygenfunction:: simgrid::s4u::Actor::on_termination_cb
+ .. doxygenfunction:: simgrid::s4u::Actor::on_destruction_cb
.. _API_s4u_this_actor:
.. group-tab:: C++
- .. doxygenvariable:: simgrid::s4u::Disk::on_creation
- .. doxygenvariable:: simgrid::s4u::Disk::on_destruction
- .. doxygenvariable:: simgrid::s4u::Disk::on_state_change
+ .. doxygenfunction:: simgrid::s4u::Disk::on_creation_cb
+ .. doxygenfunction:: simgrid::s4u::Disk::on_destruction_cb
+ .. doxygenfunction:: simgrid::s4u::Disk::on_state_change_cb
.. _API_s4u_Host:
.. group-tab:: C++
- .. doxygenvariable:: simgrid::s4u::VirtualMachine::on_creation
- .. doxygenvariable:: simgrid::s4u::VirtualMachine::on_destruction
- .. doxygenvariable:: simgrid::s4u::VirtualMachine::on_migration_end
- .. doxygenvariable:: simgrid::s4u::VirtualMachine::on_migration_start
- .. doxygenvariable:: simgrid::s4u::VirtualMachine::on_resume
- .. doxygenvariable:: simgrid::s4u::VirtualMachine::on_shutdown
- .. doxygenvariable:: simgrid::s4u::VirtualMachine::on_start
- .. doxygenvariable:: simgrid::s4u::VirtualMachine::on_started
- .. doxygenvariable:: simgrid::s4u::VirtualMachine::on_suspend
+ .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_creation_cb
+ .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_destruction_cb
+ .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_migration_end_cb
+ .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_migration_start_cb
+ .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_resume_cb
+ .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_shutdown_cb
+ .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_start_cb
+ .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_started_cb
+ .. doxygenfunction:: simgrid::s4u::VirtualMachine::on_suspend_cb
.. _API_s4u_Activity:
.. group-tab:: C++
+ .. doxygenfunction:: simgrid::s4u::Comm::on_start_cb
.. doxygenfunction:: simgrid::s4u::Comm::on_completion_cb
.. doxygenfunction:: simgrid::s4u::Comm::on_recv_cb
.. doxygenfunction:: simgrid::s4u::Comm::on_send_cb
.. automethod:: simgrid.Io.wait_any_for
.. automethod:: simgrid.Io.wait_any
+Signals
+-------
+
+.. tabs::
+
+ .. group-tab:: C++
+
+ .. doxygenfunction:: simgrid::s4u::Io::on_start_cb
+ .. doxygenfunction:: simgrid::s4u::Io::on_completion_cb
+
.. _API_s4u_Synchronizations:
=======================
This example shows how to attach a callback to:
- the end of a specific actor: :cpp:func:`simgrid::s4u::Actor::on_exit()`
- - the end of any actor: :cpp:member:`simgrid::s4u::Actor::on_termination()`
- - the destruction of any actor: :cpp:member:`simgrid::s4u::Actor::on_destruction()`
+ - the end of any actor: :cpp:func:`simgrid::s4u::Actor::on_termination_cb`
+ - the destruction of any actor: :cpp:func:`simgrid::s4u::Actor::on_destruction_cb`
.. example-tab:: examples/c/actor-exiting/actor-exiting.c
/** Add a callback fired when an actor terminates its code.
* @beginrst
* The actor may continue to exist if it is still referenced in the simulation, but it's not active anymore.
- * If you want to free extra data when the actor's destructor is called, use :cpp:var:`Actor::on_destruction`.
+ * If you want to free extra data when the actor's destructor is called, use :cpp:func:`Actor::on_destruction_cb`.
* If you want to register to the termination of a given actor, use :cpp:func:`this_actor::on_exit()` instead.
* @endrst
*/
friend kernel::EngineImpl;
#endif
+ static xbt::signal<void(Io const&)> on_start;
+
protected:
explicit Io(kernel::activity::IoImplPtr pimpl);
public:
enum class OpType { READ, WRITE };
- static xbt::signal<void(Io const&)> on_start;
+ static void on_start_cb(const std::function<void(Io const&)>& cb) { on_start.connect(cb); }
static IoPtr init();
Io* start() override;
In addition, this constitutes a good introductory example on how to write a plugin.
It attaches an extension to each host to store some data, and places callbacks in the following signals:
- - :cpp:member:`simgrid::s4u::Host::on_creation`: Attach a new extension to the newly created host.
- - :cpp:member:`simgrid::s4u::Exec::on_start`: Make note that a new execution started, increasing the load.
- - :cpp:member:`simgrid::s4u::Exec::on_completion`: Make note that an execution completed, decreasing the load.
- - :cpp:member:`simgrid::s4u::Host::on_state_change`: Do what is appropriate when the host gets suspended, turned off
+ - :cpp:func:`simgrid::s4u::Host::on_creation_cb`: Attach a new extension to the newly created host.
+ - :cpp:func:`simgrid::s4u::Exec::on_start_cb`: Make note that a new execution started, increasing the load.
+ - :cpp:func:`simgrid::s4u::Exec::on_completion_cb`: Make note that an execution completed, decreasing the load.
+ - :cpp:func:`simgrid::s4u::Host::on_state_change_cb`: Do what is appropriate when the host gets suspended, turned off
or similar.
- - :cpp:member:`simgrid::s4u::Host::on_speed_change`: Do what is appropriate when the DVFS is modified.
+ - :cpp:func:`simgrid::s4u::Host::on_speed_change_cb`: Do what is appropriate when the DVFS is modified.
Note that extensions are automatically destroyed when the host gets destroyed.
@endrst