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()
- 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
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;
}
> [ 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
> [ 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
<!-- 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"/>
> [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
> [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
> [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
(*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){
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;
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);
}
}
surf_callback_connect(cpuDestructedCallbacks, energyCpuDestructedCallback);
surf_callback_connect(cpuActionStateChangedCallbacks, energyCpuActionStateChangedCallback);
surf_callback_connect(surfExitCallbacks, sg_energy_plugin_exit);
+ surf_callback_connect(cpuStateChangedCallbacks, energyStateChangedCallback);
}
}
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(){
xbt_dynar_free(&power_range_watts_list);
}
-
/**
* Computes the power consumed by the host according to the current pstate and processor 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;
}
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;