Up until now, we only supported idle and max_core consumption.
We then used a linear model to compute the energy that we used.
This is not an accurate model, since the difference between idle and 1 core
and 1 core and 2 cores is not equal. We hence need the first core.
But even that is not 100% accurate; for the moment it will have to suffice, though.
p Testing the mechanism for computing host energy consumption
$ $SG_TEST_EXENV energy-consumption/energy-consumption$EXEEXT ${srcdir:=.}/../platforms/energy_platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [ 0.000000] (1:dvfs_test@MyHost1) Energetic profile: 100.0:200.0, 93.0:170.0, 90.0:150.0
+> [ 0.000000] (1:dvfs_test@MyHost1) Energetic profile: 100.0:120.0:200.0, 93.0:110.0:170.0, 90.0:105.0:150.0
> [ 0.000000] (1:dvfs_test@MyHost1) Initial peak speed=1E+08 flop/s; Energy dissipated =0E+00 J
> [ 0.000000] (1:dvfs_test@MyHost1) Sleep for 10 seconds
> [ 10.000000] (1:dvfs_test@MyHost1) Done sleeping (duration: 10.00 s). Current peak speed=1E+08; Energy dissipated=1000.00 J
> [ 10.000000] (1:dvfs_test@MyHost1) Run a task of 1E+08 flops
-> [ 11.000000] (1:dvfs_test@MyHost1) Task done (duration: 1.00 s). Current peak speed=1E+08 flop/s; Current consumption: from 100W to 200W depending on load; Energy dissipated=1200 J
+> [ 11.000000] (1:dvfs_test@MyHost1) Task done (duration: 1.00 s). Current peak speed=1E+08 flop/s; Current consumption: from 120W to 200W depending on load; Energy dissipated=1200 J
> [ 11.000000] (1:dvfs_test@MyHost1) ========= Requesting pstate 2 (speed should be of 2E+07 flop/s and is of 2E+07 flop/s)
> [ 11.000000] (1:dvfs_test@MyHost1) Run a task of 1E+08 flops
> [ 16.000000] (1:dvfs_test@MyHost1) Task done (duration: 5.00 s). Current peak speed=2E+07 flop/s; Energy dissipated=1950 J
! output sort 19
$ $SG_TEST_EXENV energy-onoff/energy-onoff$EXEEXT ${srcdir:=.}/energy-onoff/platform_onoff.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
-> [ 0.000000] (1:onoff_test@MyHost2) Energetic profile: 95.0:200.0,93.0:170.0,90.0:150.0, 120:120,110:110
+> [ 0.000000] (1:onoff_test@MyHost2) Energetic profile: 95.0:120.0:200.0,93.0:110.0:170.0,90.0:100.0:150.0, 120:120:120,110:110:110
> [ 0.000000] (1:onoff_test@MyHost2) Initial peak speed=1E+08 flop/s; Energy dissipated =0E+00 J
> [ 0.000000] (1:onoff_test@MyHost2) Sleep for 10 seconds
> [ 10.000000] (1:onoff_test@MyHost2) Done sleeping. Current peak speed=1E+08; Energy dissipated=950.00 J
values that are right for you. -->
<host id="MyHost1" speed="100.0Mf,50.0Mf,20.0Mf, 0.006666667f,0.1429f" pstate="0" >
- <prop id="watt_per_state" value="95.0:200.0,93.0:170.0,90.0:150.0, 120:120,110:110" />
+ <prop id="watt_per_state" value="95.0:120.0:200.0,93.0:110.0:170.0,90.0:100.0:150.0, 120:120:120,110:110:110" />
<prop id="watt_off" value="10" />
</host>
<host id="MyHost2" speed="100.0Mf" >
- <prop id="watt_per_state" value="100.0:200.0" />
+ <prop id="watt_per_state" value="100.0:120.0:200.0" />
<prop id="watt_off" value="10" />
</host>
> [310.000000] (1:test@MyHost1) Finally, trick the ptask to do a 'remote execution', on host MyHost2
> [320.000000] (1:test@MyHost1) Goodbye now!
> [320.000000] (0:maestro@) Simulation done.
-> [320.000000] (0:maestro@) Total energy of host MyHost1: 34000.000000 Joules
-> [320.000000] (0:maestro@) Total energy of host MyHost2: 35000.000000 Joules
-> [320.000000] (0:maestro@) Total energy of host MyHost3: 34000.000000 Joules
+> [320.000000] (0:maestro@) Total energy of host MyHost1: 39800.000000 Joules
+> [320.000000] (0:maestro@) Total energy of host MyHost2: 40800.000000 Joules
+> [320.000000] (0:maestro@) Total energy of host MyHost3: 39800.000000 Joules
<!-- List of min_power:max_power pairs (in Watts) corresponding to the speed consumed when the processor is idle
and when it is fully loaded -->
<!-- The list must contain one speed pair for each previously defined pstate-->
- <prop id="watt_per_state" value="100.0:200.0, 93.0:170.0, 90.0:150.0" />
+ <prop id="watt_per_state" value="100.0:120.0:200.0, 93.0:110.0:170.0, 90.0:105.0:150.0" />
<prop id="watt_off" value="10" />
</host>
<host id="MyHost2" speed="100.0Mf,50.0Mf,20.0Mf" pstate="0" >
- <prop id="watt_per_state" value="100.0:200.0, 93.0:170.0, 90.0:150.0" />
+ <prop id="watt_per_state" value="100.0:120.0:200.0, 93.0:110.0:170.0, 90.0:105.0:150.0" />
<prop id="watt_off" value="10" />
</host>
<host id="MyHost3" speed="100.0Mf,50.0Mf,20.0Mf" pstate="0" >
- <prop id="watt_per_state" value="100.0:200.0, 93.0:170.0, 90.0:150.0" />
+ <prop id="watt_per_state" value="100.0:120.0:200.0, 93.0:110.0:170.0, 90.0:105.0:150.0" />
<prop id="watt_off" value="10" />
</host>
double start_time = this->last_updated;
double finish_time = surf_get_clock();
double cpu_load;
- if (surf_host->cpu_->speed_.peak <= 0)
+ if (surf_host->cpu_->getPstateSpeedCurrent() <= 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->cpu_->getConstraint()) / surf_host->cpu_->speed_.peak;
+ cpu_load = lmm_constraint_get_usage(surf_host->cpu_->getConstraint()) / surf_host->cpu_->getPstateSpeedCurrent();
+
+ /** Divide by the number of cores here **/
+ cpu_load /= surf_host->cpu_->getCoreCount();
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
*
double HostEnergy::getWattMinAt(int pstate)
{
xbt_assert(!power_range_watts_list.empty(), "No power range properties specified for host %s", host->name().c_str());
- return power_range_watts_list[pstate].first;
+ return power_range_watts_list[pstate].min;
}
double HostEnergy::getWattMaxAt(int pstate)
{
xbt_assert(!power_range_watts_list.empty(), "No power range properties specified for host %s", host->name().c_str());
- return power_range_watts_list[pstate].second;
+ return power_range_watts_list[pstate].max;
}
/** @brief Computes the power consumed by the host according to the current pstate and processor load */
/* min_power corresponds to the idle power (cpu load = 0) */
/* max_power is the power consumed at 100% cpu load */
- auto range = power_range_watts_list.at(host->pstate());
- double min_power = range.first;
- double max_power = range.second;
- double power_slope = max_power - min_power;
- double current_power = min_power + cpu_load * power_slope;
+ auto range = power_range_watts_list.at(host->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 */
+ double min_power = range.min;
+ double max_power = range.max;
+ double power_slope = max_power - min_power;
+ current_power = min_power + cpu_load * power_slope;
+ }
+ else { /* Our machine is idle, take the dedicated value! */
+ current_power = range.idle;
+ }
XBT_DEBUG("[get_current_watts] min_power=%f, max_power=%f, slope=%f", min_power, max_power, power_slope);
XBT_DEBUG("[get_current_watts] Current power (watts) = %f, load = %f", current_power, cpu_load);
/* min_power corresponds to the idle power (cpu load = 0) */
/* max_power is the power consumed at 100% cpu load */
+ char *msg_idle = bprintf("Invalid idle value for pstate %d on host %s: %%s", i, host->name().c_str());
char *msg_min = bprintf("Invalid min value for pstate %d on host %s: %%s", i, host->name().c_str());
- char *msg_max = bprintf("Invalid min value for pstate %d on host %s: %%s", i, host->name().c_str());
- power_range_watts_list.push_back(power_range(
- xbt_str_parse_double(xbt_dynar_get_as(current_power_values, 0, char*), msg_min),
- xbt_str_parse_double(xbt_dynar_get_as(current_power_values, 1, char*), msg_max)
- ));
+ char *msg_max = bprintf("Invalid max value for pstate %d on host %s: %%s", i, host->name().c_str());
+ PowerRange range(
+ xbt_str_parse_double(xbt_dynar_get_as(current_power_values, 0, char*), msg_idle),
+ xbt_str_parse_double(xbt_dynar_get_as(current_power_values, 1, char*), msg_min),
+ xbt_str_parse_double(xbt_dynar_get_as(current_power_values, 2, char*), msg_max)
+ );
+ power_range_watts_list.push_back(range);
xbt_free(msg_min);
xbt_free(msg_max);
class XBT_PRIVATE HostEnergy;
+class PowerRange {
+ public:
+ double idle;
+ double min;
+ double max;
+
+ PowerRange(double idle, double min, double max) : idle(idle), min(min), max(max) {
+ }
+};
+
class HostEnergy {
public:
static simgrid::xbt::Extension<simgrid::s4u::Host, HostEnergy> EXTENSION_ID;
- typedef std::pair<double,double> power_range;
explicit HostEnergy(simgrid::s4u::Host *ptr);
~HostEnergy();
private:
void initWattsRangeList();
simgrid::s4u::Host *host = nullptr;
- std::vector<power_range> power_range_watts_list; /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */
+ std::vector<PowerRange> power_range_watts_list; /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */
public:
double watts_off = 0.0; /*< Consumption when the machine is turned off (shutdown) */
double total_energy = 0.0; /*< Total energy consumed by the host */