X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d23d862cfe45045b5a90879b7e0bc44a25bc5291..69de422132d074947ba01152e1748c5e0d1a92bf:/src/plugins/host_energy.cpp diff --git a/src/plugins/host_energy.cpp b/src/plugins/host_energy.cpp index 6a8936a30b..e166ac5bed 100644 --- a/src/plugins/host_energy.cpp +++ b/src/plugins/host_energy.cpp @@ -6,12 +6,15 @@ #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 #include +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 @@ -156,7 +159,12 @@ void HostEnergy::update() { 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_; @@ -169,9 +177,8 @@ void HostEnergy::update() 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); } @@ -220,14 +227,9 @@ double HostEnergy::get_current_watts_value() 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). @@ -275,8 +277,8 @@ double HostEnergy::get_current_watts_value(double cpu_load) 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 @@ -301,7 +303,7 @@ double HostEnergy::get_current_watts_value(double cpu_load) 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; @@ -384,7 +386,8 @@ static void on_creation(simgrid::s4u::Host& host) 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();