Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Document ActivitySet
[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   - :ref:`Battery <plugin_battery>`: models batteries that get discharged by the energy consumption of a given host.
27   - :ref:`Solar Panel <plugin_solar_panel>`: models solar panels which energy production depends on the solar irradiance.
28   - :ref:`Chiller <plugin_chiller>`: models chillers which dissipate heat by consuming energy.
29
30 You can activate these plugins with the :ref:`--cfg=plugin <cfg=plugin>` command
31 line option, for example with ``--cfg=plugin:host_energy``. You can get the full
32 list of existing plugins with ``--cfg=plugin:help``.
33
34 Defining a Plugin
35 *****************
36
37 A plugin can get some additional code executed within the SimGrid
38 kernel, and attach the data needed by that code to the SimGrid
39 objects.
40
41 The host load plugin in
42 `src/plugins/host_load.cpp <https://framagit.org/simgrid/simgrid/tree/master/src/plugins/host_load.cpp>`_
43 constitutes a good introductory example. It defines a class
44 ``HostLoad`` that is meant to be attached to each host. This class
45 contains a ``EXTENSION_ID`` field that is mandatory to our extension
46 mechanism. Then, the function ``sg_host_load_plugin_init``
47 initializes the plugin. It first calls
48 :cpp:func:`simgrid::s4u::Host::extension_create()` to register its
49 extension to the ``s4u::Host`` objects, and then attaches some
50 callbacks to signals.
51
52 You can attach your own extension to most kinds of s4u object:
53 :cpp:class:`Actors <simgrid::s4u::Actor>`,
54 :cpp:class:`Disks <simgrid::s4u::Disk>`,
55 :cpp:class:`Hosts <simgrid::s4u::Host>` and
56 :cpp:class:`Links <simgrid::s4u::Link>`. If you need to extend another
57 kind of objects, please let us now.
58
59 .. cpp:class:: template<class R, class... P> simgrid::xbt::signal<R(P...)>
60
61   A signal/slot mechanism, where you can attach callbacks to a given signal, and then fire the signal.
62
63   The template parameter is the function signature of the signal (the return value currently ignored).
64
65 .. cpp:function::: template<class R, class... P, class U>  unsigned int simgrid::xbt::signal<R(P...)>::connect(U slot)
66
67   Add a new callback to this signal.
68
69 .. cpp:function:: template<class R, class... P> simgrid::xbt::signal<R(P...)>::operator()(P... args)
70
71   Fire that signal, invoking all callbacks.
72
73 .. _s4u_API_signals:
74
75 Existing signals
76 ================
77
78 - In actors:
79   :cpp:func:`Actor::on_creation <simgrid::s4u::Actor::on_creation_cb>`
80   :cpp:func:`Actor::on_suspend <simgrid::s4u::Actor::on_suspend_cb>`
81   :cpp:func:`Actor::on_this_suspend <simgrid::s4u::Actor::on_this_suspend_cb>`
82   :cpp:func:`Actor::on_resume <simgrid::s4u::Actor::on_resume_cb>`
83   :cpp:func:`Actor::on_this_resume <simgrid::s4u::Actor::on_this_resume_cb>`
84   :cpp:func:`Actor::on_sleep <simgrid::s4u::Actor::on_sleep_cb>`
85   :cpp:func:`Actor::on_this_sleep <simgrid::s4u::Actor::on_this_sleep_cb>`
86   :cpp:func:`Actor::on_wake_up <simgrid::s4u::Actor::on_wake_up_cb>`
87   :cpp:func:`Actor::on_this_wake_up <simgrid::s4u::Actor::on_this_wake_up_cb>`
88   :cpp:func:`Actor::on_host_change <simgrid::s4u::Actor::on_host_change_cb>`
89   :cpp:func:`Actor::on_this_host_change <simgrid::s4u::Actor::on_this_host_change_cb>`
90   :cpp:func:`Actor::on_termination <simgrid::s4u::Actor::on_termination_cb>`
91   :cpp:func:`Actor::on_this_termination <simgrid::s4u::Actor::on_this_termination_cb>`
92   :cpp:func:`Actor::on_destruction <simgrid::s4u::Actor::on_destruction_cb>`
93 - In the engine:
94   :cpp:func:`Engine::on_platform_creation <simgrid::s4u::Engine::on_platform_creation_cb>`
95   :cpp:func:`Engine::on_platform_created <simgrid::s4u::Engine::on_platform_created_cb>`
96   :cpp:func:`Engine::on_time_advance <simgrid::s4u::Engine::on_time_advance_cb>`
97   :cpp:func:`Engine::on_simulation_end <simgrid::s4u::Engine::on_simulation_end_cb>`
98   :cpp:func:`Engine::on_deadlock <simgrid::s4u::Engine::on_deadlock_cb>`
99
100 - In resources:
101
102   - :cpp:func:`Disk::on_creation <simgrid::s4u::Disk::on_creation_cb>`
103     :cpp:func:`Disk::on_destruction <simgrid::s4u::Disk::on_destruction_cb>`
104     :cpp:func:`Disk::on_this_destruction <simgrid::s4u::Disk::on_this_destruction_cb>`
105     :cpp:func:`Disk::on_onoff <simgrid::s4u::Disk::on_onoff_cb>`
106     :cpp:func:`Disk::on_this_onoff <simgrid::s4u::Disk::on_this_onoff_cb>`
107   - :cpp:func:`Host::on_creation <simgrid::s4u::Host::on_creation_cb>`
108     :cpp:func:`Host::on_destruction <simgrid::s4u::Host::on_destruction_cb>`
109     :cpp:func:`Host::on_this_destruction <simgrid::s4u::Host::on_this_destruction_cb>`
110     :cpp:func:`Host::on_onoff <simgrid::s4u::Host::on_onoff_cb>`
111     :cpp:func:`Host::on_this_onoff <simgrid::s4u::Host::on_this_onoff_cb>`
112     :cpp:func:`Host::on_speed_change <simgrid::s4u::Host::on_speed_change_cb>`
113     :cpp:func:`Host::on_this_speed_change <simgrid::s4u::Host::on_this_speed_change_cb>`
114     :cpp:func:`Host::on_exec_state_change <simgrid::s4u::Host::on_exec_state_change_cb>`
115   - :cpp:func:`Link::on_creation <simgrid::s4u::Link::on_creation_cb>`
116     :cpp:func:`Link::on_destruction <simgrid::s4u::Link::on_destruction_cb>`
117     :cpp:func:`Link::on_this_destruction <simgrid::s4u::Link::on_this_destruction_cb>`
118     :cpp:func:`Link::on_onoff <simgrid::s4u::Link::on_onoff_cb>`
119     :cpp:func:`Link::on_this_onoff <simgrid::s4u::Link::on_this_onoff_cb>`
120     :cpp:func:`Link::on_bandwidth_change <simgrid::s4u::Link::on_bandwidth_change_cb>`
121     :cpp:func:`Link::on_this_bandwidth_change <simgrid::s4u::Link::on_this_bandwidth_change_cb>`
122     :cpp:func:`Link::on_communication_state_change <simgrid::s4u::Link::on_communication_state_change_cb>`
123
124   - :cpp:func:`NetZone::on_creation <simgrid::s4u::NetZone::on_creation_cb>`
125     :cpp:func:`NetZone::on_seal <simgrid::s4u::NetZone::on_seal_cb>`
126   - :cpp:func:`VirtualMachine::on_start <simgrid::s4u::VirtualMachine::on_start_cb>`
127     :cpp:func:`VirtualMachine::on_this_start <simgrid::s4u::VirtualMachine::on_this_start_cb>`
128     :cpp:func:`VirtualMachine::on_started <simgrid::s4u::VirtualMachine::on_started_cb>`
129     :cpp:func:`VirtualMachine::on_this_started <simgrid::s4u::VirtualMachine::on_this_started_cb>`
130     :cpp:func:`VirtualMachine::on_suspend <simgrid::s4u::VirtualMachine::on_suspend_cb>`
131     :cpp:func:`VirtualMachine::on_this_suspend <simgrid::s4u::VirtualMachine::on_this_suspend_cb>`
132     :cpp:func:`VirtualMachine::on_resume <simgrid::s4u::VirtualMachine::on_resume_cb>`
133     :cpp:func:`VirtualMachine::on_this_resume <simgrid::s4u::VirtualMachine::on_this_resume_cb>`
134     :cpp:func:`VirtualMachine::on_migration_start <simgrid::s4u::VirtualMachine::on_migration_start_cb>`
135     :cpp:func:`VirtualMachine::on_this_migration_start <simgrid::s4u::VirtualMachine::on_this_migration_start_cb>`
136     :cpp:func:`VirtualMachine::on_migration_end <simgrid::s4u::VirtualMachine::on_migration_end_cb>`
137     :cpp:func:`VirtualMachine::on_this_migration_end <simgrid::s4u::VirtualMachine::on_this_migration_end_cb>`
138
139 - In activities:
140
141   - :cpp:func:`Comm::on_send <simgrid::s4u::Comm::on_send_cb>`
142     :cpp:func:`Comm::on_recv <simgrid::s4u::Comm::on_recv_cb>`
143   - :cpp:func:`Comm::on_start <simgrid::s4u::Comm::on_start_cb>`
144     :cpp:func:`Comm::on_this_start <simgrid::s4u::Comm::on_this_start_cb>`
145     :cpp:func:`Comm::on_completion <simgrid::s4u::Comm::on_completion_cb>`
146     :cpp:func:`Comm::on_this_completion <simgrid::s4u::Comm::on_this_completion_cb>`
147     :cpp:func:`Comm::on_suspend <simgrid::s4u::Comm::on_suspend_cb>`
148     :cpp:func:`Comm::on_this_suspend <simgrid::s4u::Comm::on_this_suspend_cb>`
149     :cpp:func:`Comm::on_resume <simgrid::s4u::Comm::on_resume_cb>`
150     :cpp:func:`Comm::on_this_resume <simgrid::s4u::Comm::on_this_resume_cb>`
151     :cpp:func:`Comm::on_veto <simgrid::s4u::Comm::on_veto_cb>`
152     :cpp:func:`Comm::on_this_veto <simgrid::s4u::Comm::on_this_veto_cb>`
153   - :cpp:func:`Exec::on_start <simgrid::s4u::Exec::on_start_cb>`
154     :cpp:func:`Exec::on_this_start <simgrid::s4u::Exec::on_this_start_cb>`
155     :cpp:func:`Exec::on_completion <simgrid::s4u::Exec::on_completion_cb>`
156     :cpp:func:`Exec::on_this_completion <simgrid::s4u::Exec::on_this_completion_cb>`
157     :cpp:func:`Exec::on_suspend <simgrid::s4u::Exec::on_suspend_cb>`
158     :cpp:func:`Exec::on_this_suspend <simgrid::s4u::Exec::on_this_suspend_cb>`
159     :cpp:func:`Exec::on_resume <simgrid::s4u::Exec::on_resume_cb>`
160     :cpp:func:`Exec::on_this_resume <simgrid::s4u::Exec::on_this_resume_cb>`
161     :cpp:func:`Exec::on_veto <simgrid::s4u::Exec::on_veto_cb>`
162     :cpp:func:`Exec::on_this_veto <simgrid::s4u::Exec::on_this_veto_cb>`
163   - :cpp:func:`Io::on_start <simgrid::s4u::Io::on_start_cb>`
164     :cpp:func:`Io::on_this_start <simgrid::s4u::Io::on_this_start_cb>`
165     :cpp:func:`Io::on_completion <simgrid::s4u::Io::on_completion_cb>`
166     :cpp:func:`Io::on_this_completion <simgrid::s4u::Io::on_this_completion_cb>`
167     :cpp:func:`Io::on_suspend <simgrid::s4u::Io::on_suspend_cb>`
168     :cpp:func:`Io::on_this_suspend <simgrid::s4u::Io::on_this_suspend_cb>`
169     :cpp:func:`Io::on_resume <simgrid::s4u::Io::on_resume_cb>`
170     :cpp:func:`Io::on_this_resume <simgrid::s4u::Io::on_this_resume_cb>`
171     :cpp:func:`Io::on_veto <simgrid::s4u::Io::on_veto_cb>`
172     :cpp:func:`Io::on_this_veto <simgrid::s4u::Io::on_this_veto_cb>`
173
174 Existing Plugins
175 ****************
176
177 Only the major plugins are described here. Please check in src/plugins
178 to explore the other ones.
179
180 .. _plugin_host_energy:
181
182 Host Energy
183 ===========
184
185 .. doxygengroup:: plugin_host_energy
186
187
188
189 .. _plugin_link_energy:
190
191 Link Energy
192 ===========
193
194 .. doxygengroup:: plugin_link_energy
195
196 .. _plugin_link_energy_wifi:
197
198 WiFi Energy
199 ===========
200
201 .. doxygengroup:: plugin_link_energy_wifi
202
203
204
205 .. _plugin_host_load:
206
207 Host Load
208 =========
209
210 .. doxygengroup:: plugin_host_load
211
212 .. _plugin_filesystem:
213
214 File System
215 ===========
216
217 .. doxygengroup:: plugin_filesystem
218
219 .. _plugin_battery:
220
221 Battery
222 =======
223
224 .. doxygengroup:: plugin_battery
225
226 .. _plugin_solar_panel:
227
228 Solar Panel
229 ===========
230
231 .. doxygengroup:: plugin_solar_panel
232
233 .. _plugin_chiller:
234
235 Chiller
236 =======
237
238 .. doxygengroup:: plugin_chiller
239
240 ..  LocalWords:  SimGrid