Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix energy consumption when the host is turned off (fix #171)
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 30 May 2017 19:41:49 +0000 (21:41 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 30 May 2017 19:41:55 +0000 (21:41 +0200)
pstate and host state are changed before the signal, so we have to
save these information at the end of previous call. We cannot directly
save the instantaneous consumption because the load is only known at
the end ot the time interval.

src/surf/plugins/host_energy.cpp

index c1f8842..9a441b9 100644 (file)
@@ -137,7 +137,7 @@ void HostEnergy::update()
   double previous_energy = this->total_energy;
 
   double instantaneous_consumption;
   double previous_energy = this->total_energy;
 
   double instantaneous_consumption;
-  if (host->isOff())
+  if (this->pstate == -1) // The host was off at the beginning of this time interval
     instantaneous_consumption = this->watts_off;
   else
     instantaneous_consumption = this->getCurrentWattsValue(cpu_load);
     instantaneous_consumption = this->watts_off;
   else
     instantaneous_consumption = this->getCurrentWattsValue(cpu_load);
@@ -148,10 +148,13 @@ void HostEnergy::update()
 
   this->total_energy = previous_energy + energy_this_step;
   this->last_updated = finish_time;
 
   this->total_energy = previous_energy + energy_this_step;
   this->last_updated = finish_time;
-  this->pstate       = host->pstate();
+
   XBT_DEBUG(
       "[update_energy of %s] period=[%.2f-%.2f]; current power peak=%.0E flop/s; consumption change: %.2f J -> %.2f J",
       host->cname(), start_time, finish_time, host->pimpl_cpu->speed_.peak, previous_energy, energy_this_step);
   XBT_DEBUG(
       "[update_energy of %s] period=[%.2f-%.2f]; current power peak=%.0E flop/s; consumption change: %.2f J -> %.2f J",
       host->cname(), start_time, finish_time, host->pimpl_cpu->speed_.peak, previous_energy, energy_this_step);
+
+  /* Save data for the upcoming time interval: whether it's on/off and the pstate if it's on */
+  this->pstate = host->isOn() ? host->pstate() : -1;
 }
 
 HostEnergy::HostEnergy(simgrid::s4u::Host* ptr) : host(ptr), last_updated(surf_get_clock())
 }
 
 HostEnergy::HostEnergy(simgrid::s4u::Host* ptr) : host(ptr), last_updated(surf_get_clock())