From: Martin Quinson Date: Tue, 3 Feb 2015 22:07:52 +0000 (+0100) Subject: New property: watt_off to denote the disipation when the host is off X-Git-Tag: v3_12~760^2~15 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/bcc86f131ebd6b12c9a0f6a5ba02eb532b830cc0 New property: watt_off to denote the disipation when the host is off --- diff --git a/ChangeLog b/ChangeLog index 73adeb9777..e4d2474514 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ SimGrid (3.12) NOT RELEASED; urgency=low cMSG: * Interface improvement: - Rename MSG_host_is_avail(h) to MSG_host_is_on(h) + - Massive cleanups in the functions related to the energy jMSG: * Interface improvement: - Rename Host.isAvail() to Host.isOn() @@ -53,6 +54,9 @@ SimGrid (3.12) NOT RELEASED; urgency=low - Better handling of precision flags in maxmin - Fix bug causing sometimes "Impossible" errors - Properly pass cluster properties to included hosts + * Improvement of the Energy plugin. + - Always update the consumption before returning that value + - New property: watt_off to denote the disipation when the host is off XBT * New functions - Add a xbt_heap_update function, to avoid costly xbt_heap_remove+xbt_heap_insert use diff --git a/examples/msg/energy/e2/e2.c b/examples/msg/energy/e2/e2.c index 8adac1047d..2d46b2b587 100644 --- a/examples/msg/energy/e2/e2.c +++ b/examples/msg/energy/e2/e2.c @@ -68,12 +68,21 @@ int dvfs(int argc, char *argv[]) MSG_host_get_current_power_peak(host), MSG_host_get_consumed_energy(host)); start = MSG_get_clock(); - XBT_INFO("Sleep for 10 seconds"); + XBT_INFO("Sleep for 4 seconds"); MSG_process_sleep(4); XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J", MSG_get_clock()-start, MSG_host_get_current_power_peak(host), MSG_host_get_consumed_energy(host)); + // =========== Turn the other host off ========== + XBT_INFO("Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 disipated %.0f J so far.", + MSG_host_get_consumed_energy(MSG_get_host_by_name("MyHost2")) ); + MSG_host_off(MSG_get_host_by_name("MyHost2")); + start = MSG_get_clock(); + MSG_process_sleep(10); + XBT_INFO("Done sleeping (duration: %.2f s). Current peak speed=%.0E flop/s; Energy dissipated=%.0f J", + MSG_get_clock()-start, + MSG_host_get_current_power_peak(host), MSG_host_get_consumed_energy(host)); return 0; } diff --git a/examples/msg/energy/e2/energy_consumption.tesh b/examples/msg/energy/e2/energy_consumption.tesh index ad3cd31b62..574fde4a20 100644 --- a/examples/msg/energy/e2/energy_consumption.tesh +++ b/examples/msg/energy/e2/energy_consumption.tesh @@ -13,8 +13,10 @@ $ $SG_TEST_EXENV energy/e2/e2$EXEEXT ${srcdir:=.}/../platforms/energy_platform.x > [ 11.000000] (1:dvfs_test@MyHost1) ========= Requesting pstate 2 (speed should be of 20000000.00 flop/s and is of 20000000.00 flop/s) > [ 11.000000] (1:dvfs_test@MyHost1) Run a task for 100E6 flops > [ 16.000000] (1:dvfs_test@MyHost1) Task done (duration: 5.00 s). Current peak speed=2E+07 flop/s; Energy dissipated=1900 J -> [ 16.000000] (1:dvfs_test@MyHost1) Sleep for 10 seconds -> [ 20.000000] (0:@) Total simulation time: 20.00 -> [ 20.000000] (0:@) Total energy of host MyHost1: 2260.000000 Joules -> [ 20.000000] (0:@) Total energy of host MyHost2: 1900.000000 Joules +> [ 16.000000] (1:dvfs_test@MyHost1) Sleep for 4 seconds > [ 20.000000] (1:dvfs_test@MyHost1) Done sleeping (duration: 4.00 s). Current peak speed=2E+07 flop/s; Energy dissipated=2260 J +> [ 20.000000] (1:dvfs_test@MyHost1) Turning MyHost2 off, and sleeping another 10 seconds. MyHost2 disipated 2000 J so far. +> [ 30.000000] (0:@) Total simulation time: 30.00 +> [ 30.000000] (0:@) Total energy of host MyHost1: 3160.000000 Joules +> [ 30.000000] (0:@) Total energy of host MyHost2: 2100.000000 Joules +> [ 30.000000] (1:dvfs_test@MyHost1) Done sleeping (duration: 10.00 s). Current peak speed=2E+07 flop/s; Energy dissipated=3160 J diff --git a/examples/msg/energy/e3/concurrent_tasks.tesh b/examples/msg/energy/e3/concurrent_tasks.tesh index f0178483c7..3dcfbf55a7 100644 --- a/examples/msg/energy/e3/concurrent_tasks.tesh +++ b/examples/msg/energy/e3/concurrent_tasks.tesh @@ -20,4 +20,4 @@ $ $SG_TEST_EXENV energy/e3/e3$EXEEXT ${srcdir:=.}/../platforms/energy_platform.x > [ 8.000000] (1:dvfs_test@MyHost1) Total energy (Joules): 1390.000000 > [ 8.000000] (0:@) Total simulation time: 8.000000e+00 > [ 8.000000] (0:@) Total energy of host MyHost1: 1390.000000 Joules -> [ 8.000000] (0:@) Total energy of host MyHost2: 760.000000 Joules +> [ 8.000000] (0:@) Total energy of host MyHost2: 800.000000 Joules diff --git a/examples/platforms/energy_platform.xml b/examples/platforms/energy_platform.xml index 837545b787..7799229b09 100644 --- a/examples/platforms/energy_platform.xml +++ b/examples/platforms/energy_platform.xml @@ -8,9 +8,11 @@ + - + + diff --git a/examples/smpi/energy/energy.tesh b/examples/smpi/energy/energy.tesh index 6a67aeb8d9..2f2126694a 100644 --- a/examples/smpi/energy/energy.tesh +++ b/examples/smpi/energy/energy.tesh @@ -17,4 +17,4 @@ $ ../../../smpi_script/bin/smpirun -np 2 -hostfile ${srcdir:=.}/hostfile -platf > [30.000000] [rank 0] Current pstate: 2; Current power: 20000000 > [80.000000] [rank 0] Energy consumed: 12900 Joules. > [80.000000] [surf_energy/INFO] Total energy of host MyHost1: 12900.000000 Joules -> [80.000000] [surf_energy/INFO] Total energy of host MyHost2: 8650.000000 Joules +> [80.000000] [surf_energy/INFO] Total energy of host MyHost2: 9000.000000 Joules diff --git a/examples/smpi/energy/f77/energy.tesh b/examples/smpi/energy/f77/energy.tesh index 7cd737e4bb..825c29c9c1 100644 --- a/examples/smpi/energy/f77/energy.tesh +++ b/examples/smpi/energy/f77/energy.tesh @@ -8,7 +8,7 @@ $ ../../../smpi_script/bin/smpirun -np 2 -hostfile ${srcdir:=.}/hostfile -platf > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'plugin' to 'Energy' > [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s) > [80.000000] [surf_energy/INFO] Total energy of host MyHost1: 12900.000000 Joules -> [80.000000] [surf_energy/INFO] Total energy of host MyHost2: 8650.000000 Joules +> [80.000000] [surf_energy/INFO] Total energy of host MyHost2: 9000.000000 Joules > [ 0.0000000000000000 ] [rank 0 ] 3 pstates available > [ 0.0000000000000000 ] [rank 1 ] 1 pstates available > [ 0.0000000000000000 ] [rank 0 ] Power: 100000000.00000000 diff --git a/examples/smpi/energy/f90/energy.tesh b/examples/smpi/energy/f90/energy.tesh index 4e0b208989..da687b9f6f 100644 --- a/examples/smpi/energy/f90/energy.tesh +++ b/examples/smpi/energy/f90/energy.tesh @@ -8,7 +8,7 @@ $ ../../../smpi_script/bin/smpirun -np 2 -hostfile ${srcdir:=.}/hostfile -platf > [0.000000] [xbt_cfg/INFO] Configuration change: Set 'plugin' to 'Energy' > [0.000000] [surf_config/INFO] Switching workstation model to compound since you changed the network and/or cpu model(s) > [80.000000] [surf_energy/INFO] Total energy of host MyHost1: 12900.000000 Joules -> [80.000000] [surf_energy/INFO] Total energy of host MyHost2: 8650.000000 Joules +> [80.000000] [surf_energy/INFO] Total energy of host MyHost2: 9000.000000 Joules > [ 0.0000000000000000 ] [rank 0 ] 3 pstates available > [ 0.0000000000000000 ] [rank 1 ] 1 pstates available > [ 0.0000000000000000 ] [rank 0 ] Power: 100000000.00000000 diff --git a/src/surf/plugins/energy.cpp b/src/surf/plugins/energy.cpp index 1ade83fb24..3badfdff6b 100644 --- a/src/surf/plugins/energy.cpp +++ b/src/surf/plugins/energy.cpp @@ -23,19 +23,32 @@ static void energyCpuCreatedCallback(CpuPtr cpu){ (*surf_energy)[cpu] = new CpuEnergy(cpu); } -static void update_consumption(CpuPtr cpu, CpuEnergyPtr cpu_energy) { +static void update_consumption_running(CpuPtr cpu, CpuEnergyPtr cpu_energy) { double cpu_load = lmm_constraint_get_usage(cpu->getConstraint()) / cpu->m_powerPeak; double start_time = cpu_energy->last_updated; double finish_time = surf_get_clock(); - double current_energy = cpu_energy->total_energy; - double action_energy = cpu_energy->getCurrentWattsValue(cpu_load)*(finish_time-start_time); + double previous_energy = cpu_energy->total_energy; + double energy_this_step = cpu_energy->getCurrentWattsValue(cpu_load)*(finish_time-start_time); - cpu_energy->total_energy = current_energy + action_energy; + cpu_energy->total_energy = previous_energy + energy_this_step; cpu_energy->last_updated = finish_time; XBT_DEBUG("[cpu_update_energy] period=[%.2f-%.2f]; current power peak=%.0E flop/s; consumption change: %.2f J -> %.2f J", - start_time, finish_time, cpu->m_powerPeak, current_energy, action_energy); + start_time, finish_time, cpu->m_powerPeak, previous_energy, energy_this_step); +} +static void update_consumption_off(CpuPtr cpu, CpuEnergyPtr cpu_energy) { + double start_time = cpu_energy->last_updated; + double finish_time = surf_get_clock(); + + double previous_energy = cpu_energy->total_energy; + double energy_this_step = cpu_energy->watts_off*(finish_time-start_time); + + cpu_energy->total_energy = previous_energy + energy_this_step; + cpu_energy->last_updated = finish_time; + + XBT_DEBUG("[cpu_update_energy] off period=[%.2f-%.2f]; consumption change: %.2f J -> %.2f J", + start_time, finish_time, previous_energy, energy_this_step); } static void energyCpuDestructedCallback(CpuPtr cpu){ @@ -43,7 +56,10 @@ static void energyCpuDestructedCallback(CpuPtr cpu){ xbt_assert(cpu_energy_it != surf_energy->end(), "The cpu is not in surf_energy."); CpuEnergyPtr cpu_energy = cpu_energy_it->second; - update_consumption(cpu, cpu_energy); + if (cpu->getState() == SURF_RESOURCE_OFF) + update_consumption_off(cpu, cpu_energy); + else + update_consumption_running(cpu, cpu_energy); XBT_INFO("Total energy of host %s: %f Joules", cpu->getName(), cpu_energy->getConsumedEnergy()); delete cpu_energy_it->second; @@ -55,7 +71,18 @@ static void energyCpuActionStateChangedCallback(CpuActionPtr action, e_surf_acti CpuEnergyPtr cpu_energy = (*surf_energy)[cpu]; if(cpu_energy->last_updated < surf_get_clock()) { - update_consumption(cpu, cpu_energy); + update_consumption_running(cpu, cpu_energy); + } +} + +static void energyStateChangedCallback(CpuPtr cpu, e_surf_resource_state_t oldState, e_surf_resource_state_t newState){ + CpuEnergyPtr cpu_energy = (*surf_energy)[cpu]; + + if(cpu_energy->last_updated < surf_get_clock()) { + if (oldState == SURF_RESOURCE_OFF) + update_consumption_off(cpu, cpu_energy); + else + update_consumption_running(cpu, cpu_energy); } } @@ -76,6 +103,7 @@ void sg_energy_plugin_init() { surf_callback_connect(cpuDestructedCallbacks, energyCpuDestructedCallback); surf_callback_connect(cpuActionStateChangedCallbacks, energyCpuActionStateChangedCallback); surf_callback_connect(surfExitCallbacks, sg_energy_plugin_exit); + surf_callback_connect(cpuStateChangedCallbacks, energyStateChangedCallback); } } @@ -88,6 +116,15 @@ CpuEnergy::CpuEnergy(CpuPtr ptr) total_energy = 0; power_range_watts_list = getWattsRangeList(); last_updated = surf_get_clock(); + + if (cpu->getProperties() != NULL) { + char* off_power_str = (char*)xbt_dict_get_or_null(cpu->getProperties(), "watt_off"); + if (off_power_str != NULL) + watts_off = atof(off_power_str); + else + watts_off = 0; + } + } CpuEnergy::~CpuEnergy(){ @@ -98,7 +135,6 @@ CpuEnergy::~CpuEnergy(){ xbt_dynar_free(&power_range_watts_list); } - /** * Computes the power consumed by the host according to the current pstate and processor load * @@ -135,6 +171,12 @@ double CpuEnergy::getCurrentWattsValue(double cpu_load) double CpuEnergy::getConsumedEnergy() { + if(last_updated < surf_get_clock()) { + if (cpu->getState() == SURF_RESOURCE_OFF) + update_consumption_off(cpu, this); + else + update_consumption_running(cpu, this); + } return total_energy; } diff --git a/src/surf/plugins/energy.hpp b/src/surf/plugins/energy.hpp index 5839da8b7c..682ae46d83 100644 --- a/src/surf/plugins/energy.hpp +++ b/src/surf/plugins/energy.hpp @@ -22,9 +22,10 @@ public: double getCurrentWattsValue(double cpu_load); double getConsumedEnergy(); - xbt_dynar_t getWattsRangeList(); - xbt_dynar_t power_range_watts_list; /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */ + xbt_dynar_t getWattsRangeList(); + xbt_dynar_t power_range_watts_list; /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */ + double watts_off; /*< Consumption when the machine is turned off (shutdown) */ double total_energy; /*< Total energy consumed by the host */ double last_updated; /*< Timestamp of the last energy update event*/ CpuPtr cpu;