From: Christian Heinrich Date: Thu, 6 Oct 2016 09:31:53 +0000 (+0200) Subject: [ENERGY] Introduce idle/1core/maxCore energy consumption X-Git-Tag: v3_14~364 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/02ea6400fac5265cad1af98d468964d444fc82cb [ENERGY] Introduce idle/1core/maxCore energy consumption 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. --- diff --git a/examples/msg/energy-consumption/energy-consumption.tesh b/examples/msg/energy-consumption/energy-consumption.tesh index 20d6c7107b..3666ed1e78 100644 --- a/examples/msg/energy-consumption/energy-consumption.tesh +++ b/examples/msg/energy-consumption/energy-consumption.tesh @@ -3,12 +3,12 @@ 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 diff --git a/examples/msg/energy-onoff/energy-onoff.tesh b/examples/msg/energy-onoff/energy-onoff.tesh index 9f7407c4a6..9c97376fe5 100644 --- a/examples/msg/energy-onoff/energy-onoff.tesh +++ b/examples/msg/energy-onoff/energy-onoff.tesh @@ -4,7 +4,7 @@ p Testing the mechanism for computing host energy consumption ! 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 diff --git a/examples/msg/energy-onoff/platform_onoff.xml b/examples/msg/energy-onoff/platform_onoff.xml index 624a2ff1e4..58be9ca6fd 100644 --- a/examples/msg/energy-onoff/platform_onoff.xml +++ b/examples/msg/energy-onoff/platform_onoff.xml @@ -28,11 +28,11 @@ values that are right for you. --> - + - + diff --git a/examples/msg/energy-ptask/energy-ptask.tesh b/examples/msg/energy-ptask/energy-ptask.tesh index cfd1d7798f..ffbc944041 100644 --- a/examples/msg/energy-ptask/energy-ptask.tesh +++ b/examples/msg/energy-ptask/energy-ptask.tesh @@ -8,6 +8,6 @@ $ $SG_TEST_EXENV energy-ptask/energy-ptask$EXEEXT ${srcdir:=.}/../platforms/ener > [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 diff --git a/examples/platforms/energy_platform.xml b/examples/platforms/energy_platform.xml index 2d17166f11..d1ca0ff79f 100644 --- a/examples/platforms/energy_platform.xml +++ b/examples/platforms/energy_platform.xml @@ -9,15 +9,15 @@ - + - + - + diff --git a/src/surf/plugins/energy.cpp b/src/surf/plugins/energy.cpp index 028b8af65b..3d7c8a8533 100644 --- a/src/surf/plugins/energy.cpp +++ b/src/surf/plugins/energy.cpp @@ -70,15 +70,19 @@ void HostEnergy::update() 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 * @@ -125,13 +129,13 @@ HostEnergy::~HostEnergy()=default; 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 */ @@ -141,11 +145,21 @@ double HostEnergy::getCurrentWattsValue(double cpu_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); @@ -181,12 +195,15 @@ void HostEnergy::initWattsRangeList() /* 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); diff --git a/src/surf/plugins/energy.hpp b/src/surf/plugins/energy.hpp index 2d9709c26d..26fa2999a3 100644 --- a/src/surf/plugins/energy.hpp +++ b/src/surf/plugins/energy.hpp @@ -20,10 +20,19 @@ namespace energy { 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 EXTENSION_ID; - typedef std::pair power_range; explicit HostEnergy(simgrid::s4u::Host *ptr); ~HostEnergy(); @@ -37,7 +46,7 @@ public: private: void initWattsRangeList(); simgrid::s4u::Host *host = nullptr; - std::vector power_range_watts_list; /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */ + std::vector 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 */