Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Messing up with VM
[simgrid.git] / src / surf / plugins / host_energy.cpp
index 7b9c025..2a0947f 100644 (file)
@@ -174,7 +174,7 @@ void HostEnergy::update()
       // 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();
@@ -385,7 +385,7 @@ static void onActionStateChange(simgrid::surf::CpuAction* action, simgrid::surf:
       // 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>();
@@ -413,9 +413,8 @@ static void onHostDestruction(simgrid::s4u::Host& host)
   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()
@@ -518,7 +517,7 @@ double sg_host_get_current_consumption(sg_host_t host)
 {
   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);
 }
 }