#include "simgrid/plugins/energy.h"
#include "simgrid/plugins/load.h"
#include "simgrid/s4u/Engine.hpp"
+#include "src/include/surf/surf.hpp"
#include "src/plugins/vm/VirtualMachineImpl.hpp"
#include "src/surf/cpu_interface.hpp"
#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
{
double start_time = this->last_updated_;
double finish_time = surf_get_clock();
-
+ //
+ // We may have start == finish if the past consumption was updated since the simcall was started
+ // for example if 2 actors requested to update the same host's consumption in a given scheduling round.
+ //
+ // Even in this case, we need to save the pstate for the next call (after this if),
+ // which may have changed since that recent update.
if (start_time < finish_time) {
double previous_energy = this->total_energy_;
this->total_energy_ = previous_energy + energy_this_step;
this->last_updated_ = finish_time;
- XBT_DEBUG("[update_energy of %s] period=[%.2f-%.2f]; current power peak=%.0E flop/s; consumption change: %.2f J -> "
- "%.2f J",
- host_->get_cname(), start_time, finish_time, host_->pimpl_cpu->get_speed(1.0), previous_energy,
+ XBT_DEBUG("[update_energy of %s] period=[%.8f-%.8f]; current speed=%.2E flop/s (pstate %i); total consumption before: consumption change: %.8f J -> added now: %.8f J",
+ host_->get_cname(), start_time, finish_time, host_->pimpl_cpu->get_pstate_peak_speed(this->pstate_), this->pstate_, previous_energy,
energy_this_step);
}
if (this->pstate_ == pstate_off_) // The host is off (or was off at the beginning of this time interval)
return this->watts_off_;
- double current_speed = host_->getSpeed();
+ double current_speed = host_->get_speed();
double cpu_load;
- // We may have start == finish if the past consumption was updated since the simcall was started
- // for example if 2 actors requested to update the same host's consumption in a given scheduling round.
- //
- // Even in this case, we need to save the pstate for the next call (after this big if),
- // which may have changed since that recent update.
if (current_speed <= 0)
// Some users declare a pstate of speed 0 flops (e.g., to model boot time).
double power_slope = 0;
if (cpu_load > 0) { /* Something is going on, the machine is not idle */
- double min_power = range.min_;
- double max_power = range.max_;
+ min_power = range.min_;
+ max_power = range.max_;
/**
* The min_power states how much we consume when only one single
current_power = range.idle_;
}
- XBT_DEBUG("[get_current_watts] min_power=%f, max_power=%f, slope=%f", min_power, max_power, power_slope);
+ XBT_DEBUG("[get_current_watts] pstate=%i, min_power=%f, max_power=%f, slope=%f", this->pstate_, min_power, max_power, power_slope);
XBT_DEBUG("[get_current_watts] Current power (watts) = %f, load = %f", current_power, cpu_load);
return current_power;
host.extension_set(new HostEnergy(&host));
}
-static void on_action_state_change(simgrid::surf::CpuAction* action)
+static void on_action_state_change(simgrid::surf::CpuAction* action,
+ simgrid::kernel::resource::Action::State /*previous*/)
{
for (simgrid::surf::Cpu* const& cpu : action->cpus()) {
simgrid::s4u::Host* host = cpu->get_host();