Skip to content

Latest commit

 

History

History
225 lines (169 loc) · 9.95 KB

Plugins.rst

File metadata and controls

225 lines (169 loc) · 9.95 KB

SimGrid Plugins



You can extend SimGrid without modifying it, thanks to our plugin mechanism. This page describes how to write your own plugin, and documents some of the plugins distributed with SimGrid:

You can activate these plugins with the :ref:`--cfg=plugin <cfg=plugin>` command line option, for example with --cfg=plugin:host_energy. You can get the full list of existing plugins with --cfg=plugin:help.

Defining a Plugin

A plugin can get some additional code executed within the SimGrid kernel, and attach the data needed by that code to the SimGrid objects.

The host load plugin in src/plugins/host_load.cpp constitutes a good introductory example. It defines a class HostLoad that is meant to be attached to each host. This class contains a EXTENSION_ID field that is mandatory to our extension mechanism. Then, the function sg_host_load_plugin_init initializes the plugin. It first calls :cpp:func:`simgrid::s4u::Host::extension_create()` to register its extension to the s4u::Host objects, and then attaches some callbacks to signals.

You can attach your own extension to most kinds of s4u object: :cpp:class:`Actors <simgrid::s4u::Actor>`, :cpp:class:`Disks <simgrid::s4u::Disk>`, :cpp:class:`Hosts <simgrid::s4u::Host>` and :cpp:class:`Links <simgrid::s4u::Link>`. If you need to extend another kind of objects, please let us now.

.. cpp:class:: template<class R, class... P> simgrid::xbt::signal<R(P...)>

  A signal/slot mechanism, where you can attach callbacks to a given signal, and then fire the signal.

  The template parameter is the function signature of the signal (the return value currently ignored).

.. cpp:function:: template<class R, class... P> simgrid::xbt::signal<R(P...)>::operator()(P... args)

  Fire that signal, invoking all callbacks.

Existing signals

Existing Plugins

Only the major plugins are described here. Please check in src/plugins to explore the other ones.

Host Energy

.. doxygengroup:: plugin_host_energy



Link Energy

.. doxygengroup:: plugin_link_energy

WiFi Energy

.. doxygengroup:: plugin_link_energy_wifi



Host Load

.. doxygengroup:: plugin_host_load

File System

.. doxygengroup:: plugin_filesystem

Battery

.. doxygengroup:: plugin_battery

Solar Panel

.. doxygengroup:: plugin_solar_panel

Chiller

.. doxygengroup:: plugin_chiller