- /* min_power corresponds to the power consumed when only one core is active */
- /* max_power is the power consumed at 100% cpu load */
- auto range = power_range_watts_list_.at(this->pstate_);
- double current_power = 0;
- double min_power = 0;
- double max_power = 0;
- double power_slope = 0;
-
- if (cpu_load > 0) { /* Something is going on, the machine is not idle */
- min_power = range.min_;
- max_power = range.max_;
-
- /**
- * The min_power states how much we consume when only one single
- * core is working. This means that when cpu_load == 1/coreCount, then
- * current_power == min_power.
- *
- * The maximum must be reached when all cores are working (but 1 core was
- * already accounted for by min_power)
- * i.e., we need min_power + (maxCpuLoad-1/coreCount)*power_slope == max_power
- * (maxCpuLoad is by definition 1)
- */
- double power_slope;
- int coreCount = host_->get_core_count();
- double coreReciprocal = static_cast<double>(1) / static_cast<double>(coreCount);
- if (coreCount > 1)
- power_slope = (max_power - min_power) / (1 - coreReciprocal);
- else
- power_slope = 0; // Should be 0, since max_power == min_power (in this case)
-
- current_power = min_power + (cpu_load - coreReciprocal) * power_slope;
- } else { /* Our machine is idle, take the dedicated value! */
- current_power = range.idle_;
+ PowerRange power_range = power_range_watts_list_.at(this->pstate_);
+ double current_power;
+
+ if (cpu_load > 0)
+ {
+ /**
+ * Something is going on, the host is not idle.
+ *
+ * The power consumption follows the regular model:
+ * P(cpu_load) = Pstatic + Pdynamic * cpu_load
+ * where Pstatic = power_range.epsilon_ and Pdynamic = power_range.slope_
+ * and the cpu_load is a value between 0 and 1.
+ */
+ current_power = power_range.epsilon_ + cpu_load * power_range.slope_;
+ }
+ else
+ {
+ /* The host is idle, take the dedicated value! */
+ current_power = power_range.idle_;