/* This callback is fired either when the host changes its state (on/off) ("onStateChange") or its speed
* (because the user changed the pstate, or because of external trace events) ("onSpeedChange") */
/* This callback is fired either when the host changes its state (on/off) ("onStateChange") or its speed
* (because the user changed the pstate, or because of external trace events) ("onSpeedChange") */
/* **************************** Public interface *************************** */
/** @ingroup plugin_host_energy
/* **************************** Public interface *************************** */
/** @ingroup plugin_host_energy
HostEnergy::EXTENSION_ID = simgrid::s4u::Host::extension_create<HostEnergy>();
simgrid::s4u::Host::on_creation_cb(&on_creation);
HostEnergy::EXTENSION_ID = simgrid::s4u::Host::extension_create<HostEnergy>();
simgrid::s4u::Host::on_creation_cb(&on_creation);
simgrid::s4u::Host::on_speed_change_cb(&on_host_change);
simgrid::s4u::Host::on_destruction_cb(&on_host_destruction);
simgrid::s4u::Host::on_speed_change_cb(&on_host_change);
simgrid::s4u::Host::on_destruction_cb(&on_host_destruction);
+ simgrid::s4u::Host::on_exec_state_change_cb(&on_action_state_change);
+ simgrid::s4u::VirtualMachine::on_suspend_cb(&on_host_change);
+ simgrid::s4u::VirtualMachine::on_resume_cb(&on_host_change);
+ simgrid::s4u::Exec::on_suspend_cb(on_activity_suspend_resume);
+ simgrid::s4u::Exec::on_resume_cb(on_activity_suspend_resume);
// We may only have one actor on a node. If that actor executes something like
// compute -> recv -> compute
// We may only have one actor on a node. If that actor executes something like
// compute -> recv -> compute
// that the next trigger would be the 2nd compute, hence ignoring the idle time
// during the recv call. By updating at the beginning of a compute, we can
// fix that. (If the cpu is not idle, this is not required.)
simgrid::s4u::Exec::on_start_cb([](simgrid::s4u::Exec const& activity) {
if (activity.get_host_number() == 1) { // We only run on one host
// that the next trigger would be the 2nd compute, hence ignoring the idle time
// during the recv call. By updating at the beginning of a compute, we can
// fix that. (If the cpu is not idle, this is not required.)
simgrid::s4u::Exec::on_start_cb([](simgrid::s4u::Exec const& activity) {
if (activity.get_host_number() == 1) { // We only run on one host
xbt_assert(host_energy->has_pstate_power_values(), "No power range properties specified for host %s",
host->get_cname());
return host_energy->get_consumed_energy();
xbt_assert(host_energy->has_pstate_power_values(), "No power range properties specified for host %s",
host->get_cname());
return host_energy->get_consumed_energy();
xbt_assert(host_energy->has_pstate_power_values(), "No power range properties specified for host %s",
host->get_cname());
return host_energy->get_current_watts_value();
xbt_assert(host_energy->has_pstate_power_values(), "No power range properties specified for host %s",
host->get_cname());
return host_energy->get_current_watts_value();