XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_energy, surf, "Logging specific to the SURF energy plugin");
namespace simgrid {
-namespace energy {
+namespace plugin {
class PowerRange {
public:
// We consider that the machine is then fully loaded. That's arbitrary but it avoids a NaN
cpu_load = 1;
else
- cpu_load = lmm_constraint_get_usage(host->pimpl_cpu->constraint()) / current_speed;
+ cpu_load = host->pimpl_cpu->constraint()->get_usage() / current_speed;
/** Divide by the number of cores here **/
cpu_load /= host->pimpl_cpu->coreCount();
double energy_this_step = instantaneous_consumption * (finish_time - start_time);
- // TODO Trace: Trace energy_this_step from start_time to finish_time in host->name()
+ // TODO Trace: Trace energy_this_step from start_time to finish_time in host->getName()
this->total_energy = previous_energy + energy_this_step;
this->last_updated = finish_time;
{
xbt_assert(not power_range_watts_list.empty(), "No power range properties specified for host %s", host->getCname());
+ /*
+ * * Return watts_off if pstate == pstate_off
+ * * this happens when host is off
+ */
+ if (this->pstate == pstate_off) {
+ return watts_off;
+ }
+
/* min_power corresponds to the power consumed when only one core is active */
/* max_power is the power consumed at 100% cpu load */
auto range = power_range_watts_list.at(this->pstate);
}
}
-using simgrid::energy::HostEnergy;
+using simgrid::plugin::HostEnergy;
/* **************************** events callback *************************** */
static void onCreation(simgrid::s4u::Host& host)
if (dynamic_cast<simgrid::s4u::VirtualMachine*>(&host)) // Ignore virtual machines
return;
- //TODO Trace: set to zero the energy variable associated to host->name()
+ // TODO Trace: set to zero the energy variable associated to host->getName()
host.extension_set(new HostEnergy(&host));
}
// If it's a VM, take the corresponding PM
simgrid::s4u::VirtualMachine* vm = dynamic_cast<simgrid::s4u::VirtualMachine*>(host);
if (vm) // If it's a VM, take the corresponding PM
- host = vm->pimpl_vm_->getPm();
+ host = vm->getPm();
// Get the host_energy extension for the relevant host
HostEnergy* host_energy = host->extension<HostEnergy>();
if (dynamic_cast<simgrid::s4u::VirtualMachine*>(&host)) // Ignore virtual machines
return;
- HostEnergy* host_energy = host.extension<HostEnergy>();
- host_energy->update();
- XBT_INFO("Energy consumption of host %s: %f Joules", host.getCname(), host_energy->getConsumedEnergy());
+ XBT_INFO("Energy consumption of host %s: %f Joules", host.getCname(),
+ host.extension<HostEnergy>()->getConsumedEnergy());
}
static void onSimulationEnd()
}
/* **************************** Public interface *************************** */
-SG_BEGIN_DECL()
+extern "C" {
/** \ingroup plugin_energy
* \brief Enable host energy plugin
{
xbt_assert(HostEnergy::EXTENSION_ID.valid(),
"The Energy plugin is not active. Please call sg_energy_plugin_init() during initialization.");
- double cpu_load = lmm_constraint_get_usage(host->pimpl_cpu->constraint()) / host->getSpeed();
+ double cpu_load = host->pimpl_cpu->constraint()->get_usage() / host->getSpeed();
return host->extension<HostEnergy>()->getCurrentWattsValue(cpu_load);
}
-
-SG_END_DECL()
+}