#include <boost/algorithm/string.hpp>
+SIMGRID_REGISTER_PLUGIN(host_dvfs, "Dvfs support", &sg_host_dvfs_plugin_init)
+
/** @addtogroup SURF_plugin_load
This plugin makes it very simple for users to obtain the current load for each host.
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
+SIMGRID_REGISTER_PLUGIN(host_energy, "Cpu energy consumption.", &sg_host_energy_plugin_init)
+
/** @addtogroup plugin_energy
This is the energy plugin, enabling to account not only for computation time, but also for the dissipated energy in the
#include "src/plugins/vm/VirtualMachineImpl.hpp"
#include <simgrid/s4u.hpp>
+SIMGRID_REGISTER_PLUGIN(host_load, "Cpu load", &sg_host_load_plugin_init)
+
/** @addtogroup plugin_load
This plugin makes it very simple for users to obtain the current load for each host.
#include "simgrid/plugins/energy.h"
#include "simgrid/s4u/Engine.hpp"
#include "src/surf/network_interface.hpp"
+#include "src/surf/surf_interface.hpp"
#include "surf/surf.hpp"
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
+SIMGRID_REGISTER_PLUGIN(link_energy, "Link energy consumption.", &sg_link_energy_plugin_init)
+
/** @addtogroup SURF_plugin_energy
std::set<std::string> watched_hosts;
extern std::map<std::string, simgrid::surf::StorageType*> storage_types;
-#include <simgrid/plugins/dvfs.h> // FIXME: this plug-in should not be linked to the core
-#include <simgrid/plugins/energy.h> // FIXME: this plug-in should not be linked to the core
-#include <simgrid/plugins/load.h> // FIXME: this plug-in should not be linked to the core
-
-s_surf_model_description_t surf_plugin_description[] = {
- {"host_energy", "Cpu energy consumption.", &sg_host_energy_plugin_init},
- {"link_energy", "Link energy consumption.", &sg_link_energy_plugin_init},
- {"host_dvfs", "Dvfs support", &sg_host_dvfs_plugin_init},
- {"host_load", "Cpu load.", &sg_host_load_plugin_init},
- {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */
-};
+s_surf_model_description_t* surf_plugin_description = nullptr;
+XBT_PUBLIC void simgrid_add_plugin_description(const char* name, const char* description, void_f_void_t init_fun)
+{
+ static int plugin_amount = 0;
+
+ /* no need to check for plugin name conflict: the compiler already ensures that the generated
+ * simgrid_##id##_plugin_register() is unique */
+
+ plugin_amount++;
+ surf_plugin_description = static_cast<s_surf_model_description_t*>(
+ xbt_realloc(surf_plugin_description, sizeof(s_surf_model_description_t) * (plugin_amount + 2)));
+
+ surf_plugin_description[plugin_amount - 1] = {name, description, init_fun};
+ surf_plugin_description[plugin_amount] = {nullptr, nullptr, nullptr}; // this array must be null terminated
+}
/* Don't forget to update the option description in smx_config when you change this */
s_surf_model_description_t surf_network_model_description[] = {
XBT_PUBLIC int find_model_description(s_surf_model_description_t* table, std::string name);
XBT_PUBLIC void model_help(const char* category, s_surf_model_description_t* table);
+#define SIMGRID_REGISTER_PLUGIN(id, desc, init) \
+ void simgrid_##id##_plugin_register(); \
+ void XBT_ATTRIB_CONSTRUCTOR(800) simgrid_##id##_plugin_register() { \
+ simgrid_add_plugin_description(#id, desc, init); \
+ }
+
+XBT_PUBLIC void simgrid_add_plugin_description(const char* name, const char* description, void_f_void_t init_fun);
+
/** @brief The list of all available plugins */
-XBT_PUBLIC_DATA s_surf_model_description_t surf_plugin_description[];
+XBT_PUBLIC_DATA s_surf_model_description_t* surf_plugin_description;
/** @brief The list of all available optimization modes (both for cpu and networks).
* These optimization modes can be set using --cfg=cpu/optim:... and --cfg=network/optim:... */
XBT_PUBLIC_DATA s_surf_model_description_t surf_optimization_mode_description[];
int main(int argc, char* argv[])
{
- sg_host_energy_plugin_init();
MSG_init(&argc, argv);
+ MSG_config("plugin", "host_energy");
xbt_assert(argc == 2, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]);