Report
Report
Lab 1 Report
Group-8
Supervisor:
Prof. Massimo Poncino
Candidates:
Diego Porto (s313169)
A.Y. 2024/25
Table of Contents
1
1. Timeout Policy................................................................................................................................................3
1.3.1 Examples...................................................................................................................................................13
2. History Policy................................................................................................................................................15
2.2. Conclusion:...................................................................................................................................................16
2
1. Timeout Policy
In the first part of timeout policy where will run the simulator using the two given workloads from
two different sensor response’s with the default timeout policy. With transition constrain only
between **RUN** and **IDLE** states are allowed. The PSM file used is
`dpm-simulator/example/psm.txt`.
The differences in the sensor's response times between workload_1.txt and workload_2.txt can
significantly impact the DPM policy's effectiveness and behaviour.
For example, fast Sensor (workload_1.txt): With a response time of 4ms, it’s better to the system
to stay in RUN for state compared to transition to IDLE, due to the overhead in the transitions, but
in case the time out is 0 to 1, it may better to move to idle since there is saving energy 80-30 mJ.
Slow Sensor (workload_2.txt): With a response time of 100ms, it's convenient to the system to
switch to IDLE in the meantime, because it could happen that the overhead due to transition is still
better than stay in RUN state all the time.
Shorter timeout values (especially the most energy efficient one (0)) may be more effective in
managing power consumption, as the system can quickly transition to low-power states when the
sensors are not in use. But we have also avoid frequent transitions, which can be counterproductive
due to the high transition overhead.
This workload uses "fast" sensors, so the value is returned in 4 ms. the file contains two values on each
line: the first value is the arrival time of the task, and the second value represents the duration of that
task. the following 4 different timeout values: 0ms, 1ms, 20ms, 40ms, 60ms the command to run the
first workload with a timeout of 1ms is:
The command to run the first workload with a timeout of 1ms is:
The results of the simulation are stored in the folder results, divided by workload. In the output, the
[sim] section provides detailed results of the simulation: Active and Inactive Time: The total time the
system spent in active and inactive states. Total Time: The total simulation time, both with and without
DPM. State Times: The total time spent in each state (Run, Idle, Sleep). Timeout Waiting Time: The time
spent waiting for the timeout to expire. Transitions Time: The total time spent in state transitions.
Number of Transitions: The total number of state transitions. Energy for Transitions: The total energy
consumed during state transitions. Total Energy: The total energy consumption with and without DPM.
3
The results for Different Timeout Values In this first workload, we can observe the following values:
Timeout 1ms:
Number of Transitions: 138
Total Energy with DPM: 0.6997882530J
Timeout Waiting Time: 0.086400s
Timeout 20ms:
Number of Transitions: 18
Total Energy with DPM: 0.7070946960J
Timeout Waiting Time: 0.400100s
Timeout 40ms:
Number of Transitions: 18
Total Energy with DPM: 0.7119600960J
Timeout Waiting Time: 0.580100s
Timeout 60ms:
Number of Transitions: 18
Total Energy with DPM: 0.7168254960J
Timeout Waiting Time: 0.760100s
As it’s shown, different timeout values affect the number of state transitions, total energy consumption, and
The time spent in each state. Shorter timeouts lead to more frequent transitions and overall
Lower energy consumption, while longer timeouts result in fewer transitions and higher energy consumption. Th
Because the overhead caused by the transition between the RUN and IDLE states has a lower impact on energy
Consumption compared to staying in the RUN state during that time.
Conclusion Overall, from the results, we observed that lower timeout values lead to more frequent state transitio
also lead to lower overall energy consumption. On the other hand, higher timeout values result in fewer
Transitions, which means lower transition times and energy consumption, but they also lead to higher overall
Energy consumption. Given these results, for the first workload (workload_1, fast sensors), despite the high
Number of transitions, it is better to keep the timeout threshold at lower values, such as 1ms.
This workload uses "slow" sensors, meaning the value is returned in 100 ms. the file workload_2.txt contains two
for the duration of that task. Due to the higher response time of the sensors, the timeout values will differ from
4
Those used in Workload 1. Timeouts: 80ms 100ms 120ms 140ms 160ms 180ms 200ms.
Number of Transitions:
State Transitions and Energy Consumption:
timeout_80ms: Number of transitions = 194 Energy for transitions = 0.0019400000J
timeout_100ms: Number of transitions = 56 Energy for transitions = 0.0005600000J
timeout_120ms, timeout_140ms, timeout_160ms, timeout_180ms, timeout_200ms:
Number of transitions = 20 Energy for transitions = 0.0002000000J
5
timeout_80ms: Timeout waiting time = 7.922800s
timeout_100ms: Timeout waiting time = 9.421700s
timeout_120ms: Timeout waiting time = 9.759200s
timeout_140ms: Timeout waiting time = 9.959200s
timeout_160ms: Timeout waiting time = 10.159200s
timeout_180ms: Timeout waiting time = 10.359200s
timeout_200ms: Timeout waiting time = 10.559200s
Conclusion Optimal Timeout Value: As the timeout value increases, the total energy consumption with DPM
Slightly increases. For instance, the energy consumption with DPM is 0.9073J at 80ms and increases to 0.9769J
at 200ms. This indicates that shorter timeout values are more energy-efficient. Number of Transitions:
The number of state transitions decreases significantly as the timeout value increases. For example, there are
194 transitions at 80ms compared to only 20 transitions at 200ms. While fewer transitions can reduce the
Overhead and energy consumption associated with state changes, it is still beneficial to switch to the IDLE state
Despite the transition overhead. Timeout Waiting Time: The timeout waiting time increases with higher timeout
Values. This suggests that higher timeout values lead to longer periods of inactivity before transitioning to
A low-power state.
Final Conclusion: With workload_2, similar to workload_1, shorter timeouts lead to more frequent transitions
But overall lower energy consumption. On the other hand, longer timeouts result in fewer transitions but
Higher energy consumption. Additionally, as expected, the energy consumed with DPM is significantly lower
Than without DPM across all timeout values for both workloads.
Modify the timeout policy to enable transitions also to *SLEEP*. To do this it is necessary to modify
the `dpm_decide_state` function inside `dpm_policies.c` changing to the next macros
"PSM_STATE_SLEEP” which in psm.h file, as well as changing the struct of “dpm_timeout_params”
in “dpm_policies.h" and create array of two double numbers which will contain timeout_0 and
timeout_1 for run and sleep “ psm_time_t timeout[2]” plus edit the in file “utilities.h” and edit the
struct of what has been done “dpm_policies.h”. the editing in the code in the three file is attached
done as well as Let's compare the results the results/workload_2 folder. We will focus on the energy
consumption and the time spent in different states.
6
“psm.h”
typedef struct {
psm_time_t timeout[2];
} dpm_timeout_params;
“utilities.h”
tparams->timeout[0] = atof(argv[++cur]);
tparams->timeout[1] = atof(argv[++cur]);
“dpm_policies.c”
*next_state = PSM_STATE_SLEEP;
*next_state = PSM_STATE_IDLE;
else {
*next_state = PSM_STATE_RUN;}
break;
7
Comparison for workload_2 with IDLE and SLEEP
Timeout_0ms vs timeout_0ms_sleep
Transitions Time
timeout_0ms: 0.079200s
timeout_0ms_sleep: 0.495000s
Number of Transitions
timeout_0ms: 198transitions.
timeout_0ms_sleep: 198 transitions.
Timeout_80ms vs timeout_80ms_sleep
Transitions Time
timeout_80ms: 0.077600s
timeout_80ms_sleep: 0.460000s
Number of Transitions
timeout_80ms: 194 transitions.
timeout_80ms_sleep: 184 transitions.
8
Energy for Transitions
timeout_80ms: 0.0019400000J
timeout_80ms_sleep: 0.1858400000J
Timeout_100ms vs timeout_100ms_sleep:
Transitions Time
timeout_100ms: 0.022400s
timeout_100ms_sleep: 0.140000s
Number of Transitions
timeout_100ms: 56 transitions.
timeout_100ms_sleep: 56 transitions.
Timeout_0ms vs timeout_0ms_sleep:
Transitions Time
timeout_0ms: 0.068000s
timeout_0ms_sleep: 0.205000s
9
Number of Transitions
timeout_0ms: 170 transitions.
timeout_0ms_sleep: 82 transitions.
Timeout_1ms vs timeout_1ms_sleep:
Transitions Time
timeout_1ms: 0.055200s
timeout_1ms_sleep: 0.190000s
Number of Transitions
timeout_1ms: 138 transitions.
timeout_1ms_sleep: 76 transitions.
Timeout_4ms vs timeout_4ms_sleep:
Transitions Time
timeout_4ms: 0.007200s
timeout_4ms_sleep: 0.045000sv
10
Number of Transitions
timeout_4ms: 18 transitions.
timeout_4ms_sleep: 18 transitions.
Timeout_20ms vs timeout_20ms_sleep:
Transitions Time
timeout_20ms: 0.007200s
timeout_20ms_sleep: 0.045000s
Number of Transitions
timeout_20ms: 18 transitions.
timeout_20ms_sleep: 18 transitions.
Timeout_40ms vs timeout_40ms_sleep:
11
Transitions Time
timeout_40ms: 0.007200s
timeout_40ms_sleep: 0.045000s
Number of Transitions
timeout_40ms: 18 transitions.
timeout_40ms_sleep: 18 transitions.
Timeout_60ms vs timeout_60ms_sleep:
Transitions Time
timeout_60ms: 0.007200s
timeout_60ms_sleep: 0.045000s
Number of Transitions
timeout_60ms: 18 transitions.
timeout_60ms_sleep: 18 transitions.
12
The simulations with the "sleep" parameter (timeout_4ms) show significantly lowest total energy
consumption with DPM compared to their counterparts without the "sleep" parameter.
The simulations with the "IDLE" parameter (timeout_0ms) show significantly lowest total energy
consumption with DPM compared to their counterparts without the "IDLE" parameter.
Therefore the best value for timeout for Sleep mode with respect to workload_1 is 4 ms and this is
very convenient when know that average response is 4 ms for fast sensor response.
The time out value for IDLE state is also convenient to be zero to that be logic to transit from run to
idle and save energy overall BUT also the 4 ms for IDLE is also can better more than zero if we take
into consideration number of transition is 18 not 82, the 0 for idle timeout and 4 ms for sleep
timeout has been tested therefore this result is based on the experiment. Overall
4ms/sleep-4ms/idle or 4ms sleep/ 0 idle.
The simulations with the "sleep" parameter (timeout_0ms_sleep) show significantly lowest total
energy consumption with DPM compared to their counterparts without the "sleep" parameter.
The simulations with the "IDLE" parameter (timeout_0ms_IDLE) show as well significantly lowest
total energy consumption with DPM compared to their counterparts without the "IDLE" parameter.
1.3.1 Examples
For example and as practical example when the result for best value for sleep 4 ms and 4ms idle
or 4 ms sleep and 0 idle for workload_1, and when insert in the three state system the value for idle
timeout 0 and for the sleep 4ms the result will be as follows :
13
Total time in state Sleep = 1079.376200s
Total time in state Idle = 0.170100s
Total time in state Run = 2.930800s
And as at shown the value of energy resulting will be lower than putting the system in sleep mode in
idleness time with time out 4 ms which save energy to be timeout_4ms_sleep: 0.2022010260J or to put
the system in 0 for idle time out which save energy till 0.6979953200J.
The second example is for workload 2 when the value for sleep and idle is 0 when pass the value to
three state machine the result will be as the PSM is always in sleep mode, but the result always good or
at least like sleep mode. The result of 0/0 will be the same like 0 in sleep mode for workload_2.
*next_state = PSM_STATE_SLEEP;
else {
*next_state = PSM_STATE_RUN;}
{ *next_state = PSM_STATE_IDLE;
else {
*next_state = PSM_STATE_RUN;}
} else {
14
2. History Policy
The History Policy is a predictive policy. it estimates the time to transition based on the previous
workload pattern. The computed value Tpred is compared to the time to Idle and Sleep thresholds. After
a decision is taken the system is able to reach any one of the low-power states independently.
In the code section that is related to DPM history in dpm_policies.c , the implementation of the
code as follow is it inside the inactive time ? Yes? Ok, start to calculate the Tpred which method? In the
code as it’s shown there is two methods the polynomial and regression which everyone can be
activated through #ifdef macros after that and once time prediction is calculated, it goes to the
second step where the time prediction has to select to go to sleep or idle and this must be done
through achieving these terms for example in order to go to sleep state it should time prediction be
higher time breakeven, time of threshold sleep as well as the priority to sleep than idle so the sleep
must be higher than idle threshold if its so then the next state will be sleep otherwise it goes for
second priority idle and the time prediction has to validate these terms firstly must be higher than
time breakeven of idle as well as threshold of idle time otherwise failing to meet terms of the sleep or
idle makes the next stage moving to run since the transition must be from sleep to run or idle to run
and vice versa. The code is edited with the way to move from the three states.
N. of transitions = 82
The result is pretty fine in general and close to the result of three state time out policy the changing
in the coefficient lead to more saving or increasing to DPM energy but from practical examples in case
4ms/sleep and 0ms it’s around 0.25 to 0.27 J
Example two since the predictive three state machine can also work as binary machine run to idle
and vice versa or sleep to run and vice versa, repeating threshold equal to 1 ms for idle period
15
With predictive history DPM and ignoring threshold of sleep for example disable it “0” so the
machine can olny trigger between idle and run with using the last coefficients k1,0.9 k2,0.80 k3,.70
k4,.60 k5, .50 it results as follows
timeout_1ms: 0.6997882530J
timeout_1ms_sleep: 0.2559152120J
With workload_1 the result of predictive is close to timeout policy, and better from point of idle
threshold then time out idle policy while isn’t better than timeout sleep policy but it gives close
results.
For workload_2 using the same coefficient the result for threshold idle and sleep is better than using
time out policy for idle or sleep for example
Predcitve_80ms_idle :0.7203257410J
Predcitve_80ms_sleep: 0.3670321360J
timeout_80ms: 0.9073267669J
timeout_80ms_sleep: 0.5716452409J
Predcitve_100ms_idle : 0.7203257410J
Predcitve_100ms_sleep: 0.3670321360J
timeout_100ms: 0.9464934979J
timeout_100ms_sleep: 0.4822010109J
2.2. Conclusion:
In workload_1 using threshold idle with predictive policy is better than using threshold idle with time
out policy but using threshold sleep with time out policy better than use predictive policy in threshold
sleep.
In workload_2 using the predictive of both threshold sleep/idle gives better in saving energy than
using predictive policy, the predictive policy result for both idle and sleep still acceptable but not
better than time out policy.
16
if(t_curr > t_inactive_start)
{
#ifdef T_Pre_Poly
for( int i =0; i < DPM_HIST_WIND_SIZE; i++)
{
T_Pre += hparams.alpha[i] * pow(history[i],i);
}
#endif
#ifdef T_Pre_N_Reg
for( int i =1; i < DPM_HIST_WIND_SIZE; i++)
{
T_Pre += hparams.alpha[i]*(history[DPM_HIST_WIND_SIZE-(i)]);
}
T_Pre += hparams.alpha[0];
#endif
if((T_Pre >= T_B_E_S) && (T_Pre >= Thr_Sleep) && (Thr_Sleep > Thr_Idle ))
{
if((prev_state == PSM_STATE_SLEEP) || (prev_state == PSM_STATE_RUN) )
{
*next_state = PSM_STATE_SLEEP;
}
else {
*next_state = PSM_STATE_RUN;}
}
*next_state = PSM_STATE_IDLE;
}
else {
*next_state = PSM_STATE_RUN;}
}
}
else {
*next_state = PSM_STATE_RUN;
}
break;
#endif
17