X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/67fe7b9d6c00b390a8598bc1e72d42d8343cb218..8345310cee54ebaf86c3f21cbd6dfc145f2323a7:/src/plugins/host_dvfs.cpp diff --git a/src/plugins/host_dvfs.cpp b/src/plugins/host_dvfs.cpp index 202442686e..b62cc98a93 100644 --- a/src/plugins/host_dvfs.cpp +++ b/src/plugins/host_dvfs.cpp @@ -12,6 +12,22 @@ 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({ + {"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. @@ -20,9 +36,6 @@ SIMGRID_REGISTER_PLUGIN(host_dvfs, "Dvfs support", &sg_host_dvfs_plugin_init) 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 { @@ -44,8 +57,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(cfg_sampling_rate.get_name()); + double global_sampling_rate_config = cfg_sampling_rate; if (local_sampling_rate_config != nullptr) { sampling_rate_ = std::stod(local_sampling_rate_config); } else { @@ -197,7 +210,7 @@ public: * * For the sampling rate, use this: * - * - \ + * - \ * * This will run the update() method of the specified governor every 2 seconds * on that host. @@ -206,22 +219,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) { @@ -240,12 +241,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); } @@ -290,22 +291,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"); }