Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
New property: watt_off to denote the disipation when the host is off
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 3 Feb 2015 22:07:52 +0000 (23:07 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 3 Feb 2015 22:07:52 +0000 (23:07 +0100)
ChangeLog
examples/msg/energy/e2/e2.c
examples/msg/energy/e2/energy_consumption.tesh
examples/msg/energy/e3/concurrent_tasks.tesh
examples/platforms/energy_platform.xml
examples/smpi/energy/energy.tesh
examples/smpi/energy/f77/energy.tesh
examples/smpi/energy/f90/energy.tesh
src/surf/plugins/energy.cpp
src/surf/plugins/energy.hpp

index 73adeb9..e4d2474 100644 (file)
--- 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 
index 8adac10..2d46b2b 100644 (file)
@@ -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;
 }
 
index ad3cd31..574fde4 100644 (file)
@@ -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
index f017848..3dcfbf5 100644 (file)
@@ -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
index 837545b..7799229 100644 (file)
@@ -8,9 +8,11 @@
         <!--  List of min_power:max_power pairs (in Watts) corresponding to the power consumed when the processor is idle and when it is fully loaded -->
         <!--  The list must contain one power pair for each previously defined pstate-->
         <prop id="watt_per_state" value="95.0:200.0, 93.0:170.0, 90.0:150.0" />
+        <prop id="watt_off" value="10" />
   </host>
   <host id="MyHost2" power="100.0Mf" >
-        <prop id="watt_per_state" value="95.0:200.0" />
+        <prop id="watt_per_state" value="100.0:200.0" />
+        <prop id="watt_off" value="10" />
   </host>
 
   <link id="link1" bandwidth="100kBps" latency="0"/>
index 6a67aeb..2f21266 100644 (file)
@@ -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
index 7cd737e..825c29c 100644 (file)
@@ -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     
index 4e0b208..da687b9 100644 (file)
@@ -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     
index 1ade83f..3badfdf 100644 (file)
@@ -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;
 }
 
index 5839da8..682ae46 100644 (file)
@@ -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;