X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d23d862cfe45045b5a90879b7e0bc44a25bc5291..65f030e23995d8a7d37ca2b13a53fb93f8d76656:/src/plugins/host_dvfs.cpp diff --git a/src/plugins/host_dvfs.cpp b/src/plugins/host_dvfs.cpp index b99df53b9b..3b719536db 100644 --- a/src/plugins/host_dvfs.cpp +++ b/src/plugins/host_dvfs.cpp @@ -10,6 +10,25 @@ #include +SIMGRID_REGISTER_PLUGIN(host_dvfs, "Dvfs support", &sg_host_dvfs_plugin_init) + +static simgrid::config::Flag cfg_sampling_rate("plugin/dvfs/sampling-rate", {"plugin/dvfs/sampling_rate"}, + "How often should the dvfs plugin check whether the frequency needs to be changed?", 0.1, + [](double val){if (val != 0.1) sg_host_dvfs_plugin_init();}); + +static simgrid::config::Flag cfg_governor("plugin/dvfs/governor", + "Which Governor should be used that adapts the CPU frequency?", "performance", + + std::map({ + {"performance", "TODO: add some doc"}, + {"conservative", "TODO: Doc"}, + {"ondemand", "TODO: Doc"}, + {"performance", "TODO: Doc"}, + {"powersave", "TODO: Doc"}, + }), + + [](std::string val){if (val != "performance") 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. @@ -18,9 +37,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_plugin_dvfs, surf, "Logging specific to the SURF HostDvfs plugin"); -static const char* property_sampling_rate = "plugin/dvfs/sampling_rate"; -static const char* property_governor = "plugin/dvfs/governor"; - namespace simgrid { namespace plugin { @@ -42,8 +58,8 @@ public: void init() { - const char* local_sampling_rate_config = host_->get_property(property_sampling_rate); - double global_sampling_rate_config = simgrid::config::get_value(property_sampling_rate); + const char* local_sampling_rate_config = host_->get_property("plugin/dvfs/sampling-rate"); + double global_sampling_rate_config = cfg_sampling_rate; if (local_sampling_rate_config != nullptr) { sampling_rate_ = std::stod(local_sampling_rate_config); } else { @@ -195,7 +211,7 @@ public: * * For the sampling rate, use this: * - * - \ + * - \ * * This will run the update() method of the specified governor every 2 seconds * on that host. @@ -204,22 +220,10 @@ public: * these values globally. Using them within the \ will overwrite this * global configuration */ -class HostDvfs { -public: - static simgrid::xbt::Extension EXTENSION_ID; - - explicit HostDvfs(simgrid::s4u::Host*){}; - ~HostDvfs() = default; -}; - -simgrid::xbt::Extension HostDvfs::EXTENSION_ID; - } // namespace dvfs } // namespace plugin } // namespace simgrid -using simgrid::plugin::dvfs::HostDvfs; - /* **************************** events callback *************************** */ static void on_host_added(simgrid::s4u::Host& host) { @@ -238,12 +242,12 @@ static void on_host_added(simgrid::s4u::Host& host) XBT_DEBUG("DVFS process on %s is a daemon: %d", daemon_proc->get_host()->get_cname(), daemon_proc->is_daemon()); std::string dvfs_governor; - const char* host_conf = daemon_proc->get_host()->get_property(property_governor); + const char* host_conf = daemon_proc->get_host()->get_property("plugin/dvfs/governor"); if (host_conf != nullptr) { - dvfs_governor = std::string(daemon_proc->get_host()->get_property(property_governor)); + dvfs_governor = std::string(host_conf); boost::algorithm::to_lower(dvfs_governor); } else { - dvfs_governor = simgrid::config::get_value(property_governor); + dvfs_governor = cfg_governor; boost::algorithm::to_lower(dvfs_governor); } @@ -288,22 +292,19 @@ static void on_host_added(simgrid::s4u::Host& host) /* **************************** Public interface *************************** */ + /** \ingroup SURF_plugin_load * \brief Initializes the HostDvfs plugin * \details The HostDvfs plugin provides an API to get the current load of each host. */ void sg_host_dvfs_plugin_init() { - if (HostDvfs::EXTENSION_ID.valid()) + static bool inited = false; + if (inited) return; - - HostDvfs::EXTENSION_ID = simgrid::s4u::Host::extension_create(); + inited = true; sg_host_load_plugin_init(); simgrid::s4u::Host::on_creation.connect(&on_host_added); - simgrid::config::declare_flag( - property_sampling_rate, "How often should the dvfs plugin check whether the frequency needs to be changed?", 0.1); - simgrid::config::declare_flag( - property_governor, "Which Governor should be used that adapts the CPU frequency?", "performance"); }