Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics: cpu_load is not supposed to be >1 anymore
[simgrid.git] / src / plugins / host_energy.cpp
index f1167b87a87a088d859c82277d53ed6e27a93ff1..5b3cfca1f0bca2b7df40d4279cbc60cbd3a9651f 100644 (file)
@@ -261,9 +261,8 @@ double HostEnergy::get_current_watts_value()
 
     /* Divide by the number of cores here to have a value between 0 and 1 */
     cpu_load /= host_->pimpl_cpu->get_core_count();
+    xbt_assert(not(cpu_load > 1), "The impossible did happen, as usual.");
 
-    if (cpu_load > 1) // A machine with a load > 1 consumes as much as a fully loaded machine, not more
-      cpu_load = 1;
     if (cpu_load > 0)
       host_was_used_ = true;
   }
@@ -343,20 +342,30 @@ void HostEnergy::init_watts_range_list()
       double p_full;
       double p_epsilon;
 
-      if (current_power_values.size() == 2) { // Case: Idle:AllCores
-        p_full    = xbt_str_parse_double((current_power_values.at(1)).c_str(),
+      if (current_power_values.size() == 3) {
+        p_idle     = xbt_str_parse_double((current_power_values.at(0)).c_str(),
                                       "Invalid obsolete XML file. Fix your watt_per_state property.");
-        p_epsilon = p_full;
-      } else { // Case: Idle:Epsilon:AllCores
         p_one_core = xbt_str_parse_double((current_power_values.at(1)).c_str(),
                                           "Invalid obsolete XML file. Fix your watt_per_state property.");
         p_full     = xbt_str_parse_double((current_power_values.at(2)).c_str(),
                                       "Invalid obsolete XML file. Fix your watt_per_state property.");
-        if (host_->get_core_count() == 1)
+        if (host_->get_core_count() == 1) {
           p_epsilon = p_full;
-        else
+        } else {
           p_epsilon = p_one_core - ((p_full - p_one_core) / (host_->get_core_count() - 1));
+        }
+      } else { // consuption given with idle and full only
+        p_idle = xbt_str_parse_double((current_power_values.at(0)).c_str(),
+                                      "Invalid obsolete XML file. Fix your watt_per_state property.");
+        p_full = xbt_str_parse_double((current_power_values.at(1)).c_str(),
+                                      "Invalid obsolete XML file. Fix your watt_per_state property.");
+        if (host_->get_core_count() == 1) {
+          p_epsilon = p_full;
+        } else {
+          p_epsilon = p_idle;
+        }
       }
+
       PowerRange range(p_idle, p_epsilon, p_full);
       power_range_watts_list_.push_back(range);