Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a word in the doc about signal's API
[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 Energy <plugin_host_energy>`: models the energy dissipation of the compute units.
23   - :ref:`Link Energy <plugin_link_energy>`: models the energy dissipation of the network.
24   - :ref:`Host Load <plugin_host_load>`: monitors the load of the compute units.
25
26 You can activate these plugins with the :ref:`--cfg=plugin <cfg=plugin>` command
27 line option, for example with ``--cfg=plugin:host_energy``. You can get the full
28 list of existing plugins with ``--cfg=plugin:help``.
29
30 Defining a Plugin
31 *****************
32
33 A plugin can get some additional code executed within the SimGrid
34 kernel, and attach the data needed by that code to the SimGrid
35 objects. 
36
37 The host load plugin in 
38 `src/plugins/host_load.cpp <https://framagit.org/simgrid/simgrid/tree/master/src/plugins/host_load.cpp>`_
39 constitutes a good introductory example. It defines a class
40 ``HostLoad`` that is meant to be attached to each host. This class
41 contains a ``EXTENSION_ID`` field that is mandatory to our extension
42 mechanism. Then, the function ``sg_host_load_plugin_init``
43 initializes the plugin. It first calls
44 :cpp:func:`simgrid::s4u::Host::extension_create()` to register its
45 extension to the ``s4u::Host`` objects, and then attaches some
46 callbacks to signals.
47
48 You can attach your own extension to most kinds of s4u object:
49 :cpp:class:`Actors <simgrid::s4u::Actor>`,
50 :cpp:class:`Disks <simgrid::s4u::Disk>`,
51 :cpp:class:`Hosts <simgrid::s4u::Host>` and
52 :cpp:class:`Links <simgrid::s4u::Link>`. If you need to extend another
53 kind of objects, please let us now.
54
55 .. cpp:class:: template<class R, class... P> simgrid::xbt::signal<R(P...)>
56
57   A signal/slot mechanism, where you can attach callbacks to a given signal, and then fire the signal. 
58
59   The template parameter is the function signature of the signal (the return value currently ignored).
60
61 .. cpp:function::: template<class R, class... P, class U>  unsigned int simgrid::xbt::signal<R(P...)>::connect(U slot)
62
63   Add a new callback to this signal.
64
65 .. cpp:function:: template<class R, class... P> simgrid::xbt::signal<R(P...)>::operator()(P... args)
66
67   Fire that signal, invoking all callbacks.
68
69 Partial list of existing signals in s4u:
70
71 - :cpp:member:`Actor::on_creation <simgrid::s4u::Actor::on_creation>`
72   :cpp:member:`Actor::on_suspend <simgrid::s4u::Actor::on_suspend>`
73   :cpp:member:`Actor::on_resume <simgrid::s4u::Actor::on_resume>`
74   :cpp:member:`Actor::on_sleep <simgrid::s4u::Actor::on_sleep>`
75   :cpp:member:`Actor::on_wake_up <simgrid::s4u::Actor::on_wake_up>`
76   :cpp:member:`Actor::on_host_change <simgrid::s4u::Actor::on_host_change>`
77   :cpp:member:`Actor::on_termination <simgrid::s4u::Actor::on_termination>`
78   :cpp:member:`Actor::on_destruction <simgrid::s4u::Actor::on_destruction>`
79 - :cpp:member:`Comm::on_start <simgrid::s4u::Comm::on_start>`
80   :cpp:member:`Comm::on_completion <simgrid::s4u::Comm::on_completion>`
81 - :cpp:member:`Engine::on_platform_creation <simgrid::s4u::Engine::on_platform_creation>`
82   :cpp:member:`Engine::on_platform_created <simgrid::s4u::Engine::on_platform_created>`
83   :cpp:member:`Engine::on_time_advance <simgrid::s4u::Engine::on_time_advance>`
84   :cpp:member:`Engine::on_simulation_end <simgrid::s4u::Engine::on_simulation_end>`
85   :cpp:member:`Engine::on_deadlock <simgrid::s4u::Engine::on_deadlock>`
86 - :cpp:member:`Exec::on_start <simgrid::s4u::Exec::on_start>`
87   :cpp:member:`Exec::on_completion <simgrid::s4u::Exec::on_completion>`
88 - :cpp:member:`Host::on_creation <simgrid::s4u::Host::on_creation>`
89   :cpp:member:`Host::on_destruction <simgrid::s4u::Host::on_destruction>`
90   :cpp:member:`Host::on_state_change <simgrid::s4u::Host::on_state_change>`
91   :cpp:member:`Host::on_speed_change <simgrid::s4u::Host::on_speed_change>`
92 - :cpp:member:`Link::on_creation <simgrid::s4u::Link::on_creation>`
93   :cpp:member:`Link::on_destruction <simgrid::s4u::Link::on_destruction>`
94   :cpp:member:`Link::on_state_change <simgrid::s4u::Link::on_state_change>`
95   :cpp:member:`Link::on_speed_change <simgrid::s4u::Link::on_bandwidth_change>`
96   :cpp:member:`Link::on_communicate <simgrid::s4u::Link::on_communicate>`
97   :cpp:member:`Link::on_communication_state_change <simgrid::s4u::Link::on_communication_state_change>`
98 - :cpp:member:`Netzone::on_creation <simgrid::s4u::Netzone::on_creation>`
99   :cpp:member:`Netzone::on_seal <simgrid::s4u::Netzone::on_seal>`
100   :cpp:member:`Netzone::on_route_creation <simgrid::s4u::Netzone::on_route_creation>`
101 - :cpp:member:`VirtualMachine::on_start <simgrid::s4u::VirtualMachine::on_start>`
102   :cpp:member:`VirtualMachine::on_started <simgrid::s4u::VirtualMachine::on_started>`
103   :cpp:member:`VirtualMachine::on_suspend <simgrid::s4u::VirtualMachine::on_suspend>`
104   :cpp:member:`VirtualMachine::on_resume <simgrid::s4u::VirtualMachine::on_resume>`
105   :cpp:member:`VirtualMachine::on_migration_start <simgrid::s4u::VirtualMachine::on_migration_start>`
106   :cpp:member:`VirtualMachine::on_migration_end <simgrid::s4u::VirtualMachine::on_migration_end>`
107
108 Existing Plugins
109 ****************
110
111 Only the major plugins are described here. Please check in src/plugins
112 to explore the other ones.
113
114 .. _plugin_host_energy:
115
116 Host Energy
117 ===========
118
119 .. doxygengroup:: plugin_host_energy
120
121
122
123 .. _plugin_link_energy:
124
125 Link Energy
126 ===========
127
128 .. doxygengroup:: plugin_link_energy
129
130
131
132 .. _plugin_host_load:
133
134 Host Load
135 =========
136
137 .. doxygengroup:: plugin_host_load
138
139
140
141 .. _plugin_filesystem:
142
143 File System
144 ===========
145
146 .. doxygengroup:: plugin_filesystem
147
148
149 ..  LocalWords:  SimGrid
150