public:
explicit Performance(simgrid::s4u::Host* ptr) : Governor(ptr) {}
- void update() { host->setPstate(0); }
- std::string getName() { return "Performance"; }
+ void update() override { host->setPstate(0); }
+ std::string getName() override { return "Performance"; }
};
class Powersave : public Governor {
public:
explicit Powersave(simgrid::s4u::Host* ptr) : Governor(ptr) {}
- void update() { host->setPstate(host->getPstatesCount() - 1); }
- std::string getName() { return "Powersave"; }
+ void update() override { host->setPstate(host->getPstatesCount() - 1); }
+ std::string getName() override { return "Powersave"; }
};
class OnDemand : public Governor {
public:
explicit OnDemand(simgrid::s4u::Host* ptr) : Governor(ptr) {}
- std::string getName() { return "OnDemand"; }
- void update()
+ std::string getName() override { return "OnDemand"; }
+ void update() override
{
double load = sg_host_get_current_load(host);
// FIXME I don't like that we multiply with the getCoreCount() just here...
if (load*host->getCoreCount() > freq_up_threshold) {
host->setPstate(0); /* Run at max. performance! */
- XBT_INFO("Changed to pstate %f", 0.0);
+ XBT_INFO("Load: %f > threshold: %f --> changed to pstate %i", load * host->getCoreCount(), freq_up_threshold, 0);
} else {
/* The actual implementation uses a formula here: (See Kernel file cpufreq_ondemand.c:158)
*
public:
explicit Conservative(simgrid::s4u::Host* ptr) : Governor(ptr) {}
- virtual std::string getName() { return "Conservative"; }
- virtual void update()
+ virtual std::string getName() override { return "Conservative"; }
+ virtual void update() override
{
double load = sg_host_get_current_load(host)*host->getCoreCount();
int pstate = host->getPstate();
}
}
};
-}
class HostDvfs {
public:
HostDvfs::~HostDvfs() = default;
}
}
+}
-using simgrid::plugin::HostDvfs;
+using simgrid::plugin::dvfs::HostDvfs;
/* **************************** events callback *************************** */
static void on_host_added(simgrid::s4u::Host& host)
boost::algorithm::to_lower(dvfs_governor);
}
- // FIXME This is really ugly. When do we free the governor? Actually, never, because
- // daemons never stop to run - they will be killed when the simulation is over. :(
- simgrid::plugin::dvfs::Governor* governor;
- if (dvfs_governor == "conservative") {
- governor = new simgrid::plugin::dvfs::Conservative(daemonProc->getHost());
- } else if (dvfs_governor == "ondemand") {
- governor = new simgrid::plugin::dvfs::OnDemand(daemonProc->getHost());
- } else if (dvfs_governor == "performance") {
- governor = new simgrid::plugin::dvfs::Performance(daemonProc->getHost());
- } else if (dvfs_governor == "powersave") {
- governor = new simgrid::plugin::dvfs::Powersave(daemonProc->getHost());
- } else {
- XBT_CRITICAL("No governor specified for host %s", daemonProc->getHost()->getCname());
- }
+ auto governor = [&dvfs_governor, &daemonProc]() {
+ if (dvfs_governor == "conservative") {
+ return std::unique_ptr<simgrid::plugin::dvfs::Governor>(
+ new simgrid::plugin::dvfs::Conservative(daemonProc->getHost()));
+ } else if (dvfs_governor == "ondemand") {
+ return std::unique_ptr<simgrid::plugin::dvfs::Governor>(
+ new simgrid::plugin::dvfs::OnDemand(daemonProc->getHost()));
+ } else if (dvfs_governor == "performance") {
+ return std::unique_ptr<simgrid::plugin::dvfs::Governor>(
+ new simgrid::plugin::dvfs::Performance(daemonProc->getHost()));
+ } else if (dvfs_governor == "powersave") {
+ return std::unique_ptr<simgrid::plugin::dvfs::Governor>(
+ new simgrid::plugin::dvfs::Powersave(daemonProc->getHost()));
+ } else {
+ XBT_CRITICAL("No governor specified for host %s, falling back to Performance",
+ daemonProc->getHost()->getCname());
+ return std::unique_ptr<simgrid::plugin::dvfs::Governor>(
+ new simgrid::plugin::dvfs::Performance(daemonProc->getHost()));
+ }
+ }();
while (1) {
// Sleep *before* updating; important for startup (i.e., t = 0).