Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Allow to register plugins from their file, w/o touching the core implem
[simgrid.git] / src / plugins / host_energy.cpp
index 4fdc423..6334ddd 100644 (file)
@@ -6,12 +6,15 @@
 #include "simgrid/plugins/energy.h"
 #include "simgrid/plugins/load.h"
 #include "simgrid/s4u/Engine.hpp"
+#include "src/include/surf/surf.hpp"
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
 #include "src/surf/cpu_interface.hpp"
 
 #include <boost/algorithm/string/classification.hpp>
 #include <boost/algorithm/string/split.hpp>
 
+SIMGRID_REGISTER_PLUGIN(host_energy, "Cpu energy consumption.", &sg_host_energy_plugin_init)
+
 /** @addtogroup plugin_energy
 
 This is the energy plugin, enabling to account not only for computation time, but also for the dissipated energy in the
@@ -156,7 +159,12 @@ void HostEnergy::update()
 {
   double start_time  = this->last_updated_;
   double finish_time = surf_get_clock();
-
+  //
+  // We may have start == finish if the past consumption was updated since the simcall was started
+  // for example if 2 actors requested to update the same host's consumption in a given scheduling round.
+  //
+  // Even in this case, we need to save the pstate for the next call (after this if),
+  // which may have changed since that recent update.
   if (start_time < finish_time) {
     double previous_energy = this->total_energy_;
 
@@ -223,11 +231,6 @@ double HostEnergy::get_current_watts_value()
   double current_speed = host_->get_speed();
 
   double cpu_load;
-  // We may have start == finish if the past consumption was updated since the simcall was started
-  // for example if 2 actors requested to update the same host's consumption in a given scheduling round.
-  //
-  // Even in this case, we need to save the pstate for the next call (after this big if),
-  // which may have changed since that recent update.
 
   if (current_speed <= 0)
     // Some users declare a pstate of speed 0 flops (e.g., to model boot time).
@@ -275,8 +278,8 @@ double HostEnergy::get_current_watts_value(double cpu_load)
   double power_slope   = 0;
 
   if (cpu_load > 0) { /* Something is going on, the machine is not idle */
-    double min_power = range.min_;
-    double max_power = range.max_;
+    min_power = range.min_;
+    max_power = range.max_;
 
     /**
      * The min_power states how much we consume when only one single