Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
simplifications
[simgrid.git] / src / surf / plugins / energy.cpp
index 5212967..028b8af 100644 (file)
@@ -48,7 +48,7 @@ In this example, the idle consumption is 95 Watts, 93 Watts and 90 Watts in each
 are at 200 Watts, 170 Watts, and 150 Watts respectively.
 
 To change the pstate of a given CPU, use the following functions:
-#MSG_host_get_nb_pstates(), simgrid#s4u#Host#set_pstate(), #MSG_host_get_power_peak_at().
+#MSG_host_get_nb_pstates(), simgrid#s4u#Host#setPstate(), #MSG_host_get_power_peak_at().
 
 To simulate the energy-related elements, first call the simgrid#energy#sg_energy_plugin_init() before your #MSG_init(),
 and then use the following function to retrieve the consumption of a given host: MSG_host_get_consumed_energy().
@@ -70,15 +70,22 @@ void HostEnergy::update()
   double start_time = this->last_updated;
   double finish_time = surf_get_clock();
   double cpu_load;
-  if (surf_host->p_cpu->speed_.peak <= 0)
+  if (surf_host->cpu_->speed_.peak <= 0)
     // Some users declare a pstate of speed 0 flops (e.g., to model boot time).
     // 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(surf_host->p_cpu->getConstraint()) / surf_host->p_cpu->speed_.peak;
+    cpu_load = lmm_constraint_get_usage(surf_host->cpu_->getConstraint()) / surf_host->cpu_->speed_.peak;
 
-  if (cpu_load > 1) // A machine with a load > 1 consumes as much as a fully loaded machine, not mores
+  if (cpu_load > 1) // A machine with a load > 1 consumes as much as a fully loaded machine, not more
     cpu_load = 1;
+  /* The problem with this model is that the load is always 0 or 1, never something less.
+   * Another possibility could be to model the total energy as
+   *
+   *   X/(X+Y)*W_idle + Y/(X+Y)*W_burn
+   *
+   * where X is the amount of ideling cores, and Y the amount of computing cores.
+   */
 
   double previous_energy = this->total_energy;
 
@@ -94,7 +101,7 @@ void HostEnergy::update()
   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",
-      surf_host->getName(), start_time, finish_time, surf_host->p_cpu->speed_.peak, previous_energy, energy_this_step);
+      surf_host->getName(), start_time, finish_time, surf_host->cpu_->speed_.peak, previous_energy, energy_this_step);
 }
 
 HostEnergy::HostEnergy(simgrid::s4u::Host *ptr) : host(ptr), last_updated(surf_get_clock())
@@ -210,7 +217,7 @@ static void onActionStateChange(simgrid::surf::CpuAction *action, simgrid::surf:
     if (vm) // If it's a VM, take the corresponding PM
       host = vm->getPm()->extension<simgrid::surf::HostImpl>();
 
-    HostEnergy *host_energy = host->piface->extension<HostEnergy>();
+    HostEnergy *host_energy = host->piface_->extension<HostEnergy>();
 
     if(host_energy->last_updated < surf_get_clock())
       host_energy->update();