Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Sort the signals on the plugin page
[simgrid.git] / docs / source / Plugins.rst
1 .. _plugins:
2
3 SimGrid Plugins
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("PluginsBox")
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 You can extend SimGrid without modifying it, thanks to our plugin
19 mechanism. This page describes how to write your own plugin, and
20 documents some of the plugins distributed with SimGrid:
21
22   - :ref:`Host Load <plugin_host_load>`: monitors the load of the compute units.
23   - :ref:`Host Energy <plugin_host_energy>`: models the energy dissipation of the compute units.
24   - :ref:`Link Energy <plugin_link_energy>`: models the energy dissipation of the network.
25   - :ref:`WiFi Energy <plugin_link_energy_wifi>`: models the energy dissipation of wifi links.
26
27 You can activate these plugins with the :ref:`--cfg=plugin <cfg=plugin>` command
28 line option, for example with ``--cfg=plugin:host_energy``. You can get the full
29 list of existing plugins with ``--cfg=plugin:help``.
30
31 Defining a Plugin
32 *****************
33
34 A plugin can get some additional code executed within the SimGrid
35 kernel, and attach the data needed by that code to the SimGrid
36 objects.
37
38 The host load plugin in
39 `src/plugins/host_load.cpp <https://framagit.org/simgrid/simgrid/tree/master/src/plugins/host_load.cpp>`_
40 constitutes a good introductory example. It defines a class
41 ``HostLoad`` that is meant to be attached to each host. This class
42 contains a ``EXTENSION_ID`` field that is mandatory to our extension
43 mechanism. Then, the function ``sg_host_load_plugin_init``
44 initializes the plugin. It first calls
45 :cpp:func:`simgrid::s4u::Host::extension_create()` to register its
46 extension to the ``s4u::Host`` objects, and then attaches some
47 callbacks to signals.
48
49 You can attach your own extension to most kinds of s4u object:
50 :cpp:class:`Actors <simgrid::s4u::Actor>`,
51 :cpp:class:`Disks <simgrid::s4u::Disk>`,
52 :cpp:class:`Hosts <simgrid::s4u::Host>` and
53 :cpp:class:`Links <simgrid::s4u::Link>`. If you need to extend another
54 kind of objects, please let us now.
55
56 .. cpp:class:: template<class R, class... P> simgrid::xbt::signal<R(P...)>
57
58   A signal/slot mechanism, where you can attach callbacks to a given signal, and then fire the signal.
59
60   The template parameter is the function signature of the signal (the return value currently ignored).
61
62 .. cpp:function::: template<class R, class... P, class U>  unsigned int simgrid::xbt::signal<R(P...)>::connect(U slot)
63
64   Add a new callback to this signal.
65
66 .. cpp:function:: template<class R, class... P> simgrid::xbt::signal<R(P...)>::operator()(P... args)
67
68   Fire that signal, invoking all callbacks.
69
70 Partial list of existing signals in s4u:
71
72 - In actors:
73   :cpp:func:`Actor::on_creation <simgrid::s4u::Actor::on_creation_cb>`
74   :cpp:func:`Actor::on_suspend <simgrid::s4u::Actor::on_suspend_cb>`
75   :cpp:func:`Actor::on_this_suspend <simgrid::s4u::Actor::on_this_suspend_cb>`
76   :cpp:func:`Actor::on_resume <simgrid::s4u::Actor::on_resume_cb>`
77   :cpp:func:`Actor::on_this_resume <simgrid::s4u::Actor::on_this_resume_cb>`
78   :cpp:func:`Actor::on_sleep <simgrid::s4u::Actor::on_sleep_cb>`
79   :cpp:func:`Actor::on_this_sleep <simgrid::s4u::Actor::on_this_sleep_cb>`
80   :cpp:func:`Actor::on_wake_up <simgrid::s4u::Actor::on_wake_up_cb>`
81   :cpp:func:`Actor::on_this_wake_up <simgrid::s4u::Actor::on_this_wake_up_cb>`
82   :cpp:func:`Actor::on_host_change <simgrid::s4u::Actor::on_host_change_cb>`
83   :cpp:func:`Actor::on_this_host_change <simgrid::s4u::Actor::on_this_host_change_cb>`
84   :cpp:func:`Actor::on_termination <simgrid::s4u::Actor::on_termination_cb>`
85   :cpp:func:`Actor::on_this_termination <simgrid::s4u::Actor::on_this_termination_cb>`
86   :cpp:func:`Actor::on_destruction <simgrid::s4u::Actor::on_destruction_cb>`
87 - In the engine:
88   :cpp:func:`Engine::on_platform_creation <simgrid::s4u::Engine::on_platform_creation_cb>`
89   :cpp:func:`Engine::on_platform_created <simgrid::s4u::Engine::on_platform_created_cb>`
90   :cpp:func:`Engine::on_time_advance <simgrid::s4u::Engine::on_time_advance_cb>`
91   :cpp:func:`Engine::on_simulation_end <simgrid::s4u::Engine::on_simulation_end_cb>`
92   :cpp:func:`Engine::on_deadlock <simgrid::s4u::Engine::on_deadlock_cb>`
93
94 - In resources:
95
96   - :cpp:func:`Disk::on_creation <simgrid::s4u::Disk::on_creation_cb>`
97     :cpp:func:`Disk::on_destruction <simgrid::s4u::Disk::on_destruction_cb>`
98     :cpp:func:`Disk::on_this_destruction <simgrid::s4u::Disk::on_this_destruction_cb>`
99     :cpp:func:`Disk::on_onoff <simgrid::s4u::Disk::on_onoff_cb>`
100     :cpp:func:`Disk::on_this_onoff <simgrid::s4u::Disk::on_this_onoff_cb>`
101   - :cpp:func:`Host::on_creation <simgrid::s4u::Host::on_creation_cb>`
102     :cpp:func:`Host::on_destruction <simgrid::s4u::Host::on_destruction_cb>`
103     :cpp:func:`Host::on_this_destruction <simgrid::s4u::Host::on_this_destruction_cb>`
104     :cpp:func:`Host::on_onoff <simgrid::s4u::Host::on_onoff_cb>`
105     :cpp:func:`Host::on_this_onoff <simgrid::s4u::Host::on_this_onoff_cb>`
106     :cpp:func:`Host::on_speed_change <simgrid::s4u::Host::on_speed_change_cb>`
107     :cpp:func:`Host::on_this_speed_change <simgrid::s4u::Host::on_this_speed_change_cb>`
108     :cpp:func:`Host::on_exec_state_change <simgrid::s4u::Host::on_exec_state_change_cb>`
109   - :cpp:func:`Link::on_creation <simgrid::s4u::Link::on_creation_cb>`
110     :cpp:func:`Link::on_destruction <simgrid::s4u::Link::on_destruction_cb>`
111     :cpp:func:`Link::on_this_destruction <simgrid::s4u::Link::on_this_destruction_cb>`
112     :cpp:func:`Link::on_onoff <simgrid::s4u::Link::on_onoff_cb>`
113     :cpp:func:`Link::on_this_onoff <simgrid::s4u::Link::on_this_onoff_cb>`
114     :cpp:func:`Link::on_bandwidth_change <simgrid::s4u::Link::on_bandwidth_change_cb>`
115     :cpp:func:`Link::on_this_bandwidth_change <simgrid::s4u::Link::on_this_bandwidth_change_cb>`
116     :cpp:func:`Link::on_communication_state_change <simgrid::s4u::Link::on_communication_state_change_cb>`
117
118   - :cpp:func:`NetZone::on_creation <simgrid::s4u::NetZone::on_creation_cb>`
119     :cpp:func:`NetZone::on_seal <simgrid::s4u::NetZone::on_seal_cb>`
120   - :cpp:func:`VirtualMachine::on_start <simgrid::s4u::VirtualMachine::on_start_cb>`
121     :cpp:func:`VirtualMachine::on_started <simgrid::s4u::VirtualMachine::on_started_cb>`
122     :cpp:func:`VirtualMachine::on_suspend <simgrid::s4u::VirtualMachine::on_suspend_cb>`
123     :cpp:func:`VirtualMachine::on_resume <simgrid::s4u::VirtualMachine::on_resume_cb>`
124     :cpp:func:`VirtualMachine::on_migration_start <simgrid::s4u::VirtualMachine::on_migration_start_cb>`
125     :cpp:func:`VirtualMachine::on_migration_end <simgrid::s4u::VirtualMachine::on_migration_end_cb>`
126
127 - In activities:
128
129   - :cpp:func:`Comm::on_send <simgrid::s4u::Comm::on_send_cb>`
130     :cpp:func:`Comm::on_recv <simgrid::s4u::Comm::on_recv_cb>`
131     :cpp:func:`Comm::on_completion <simgrid::s4u::Comm::on_completion_cb>`
132   - :cpp:func:`CommImpl::on_start <simgrid::s4u::CommImpl::on_start_cb>`
133     :cpp:func:`CommImpl::on_completion <simgrid::s4u::CommImpl::on_completion_cb>`
134   - :cpp:func:`Exec::on_start <simgrid::s4u::Exec::on_start_cb>`
135     :cpp:func:`Exec::on_completion <simgrid::s4u::Exec::on_completion_cb>`
136   - :cpp:func:`Io::on_start <simgrid::s4u::Io::on_start_cb>`
137     :cpp:func:`Io::on_completion <simgrid::s4u::Io::on_completion_cb>`
138
139 Existing Plugins
140 ****************
141
142 Only the major plugins are described here. Please check in src/plugins
143 to explore the other ones.
144
145 .. _plugin_host_energy:
146
147 Host Energy
148 ===========
149
150 .. doxygengroup:: plugin_host_energy
151
152
153
154 .. _plugin_link_energy:
155
156 Link Energy
157 ===========
158
159 .. doxygengroup:: plugin_link_energy
160
161 .. _plugin_link_energy_wifi:
162
163 WiFi Energy
164 ===========
165
166 .. doxygengroup:: plugin_link_energy_wifi
167
168
169
170 .. _plugin_host_load:
171
172 Host Load
173 =========
174
175 .. doxygengroup:: plugin_host_load
176
177
178
179 .. _plugin_filesystem:
180
181 File System
182 ===========
183
184 .. doxygengroup:: plugin_filesystem
185
186 .. _plugin_battery:
187
188 Battery
189 ===========
190
191 .. doxygengroup:: plugin_battery
192
193 .. _plugin_operation:
194
195 Operation
196 ===========
197
198 .. doxygengroup:: plugin_operation
199
200 ..  LocalWords:  SimGrid