-
Notifications
You must be signed in to change notification settings - Fork 4
/
hotspot_flow.m
111 lines (105 loc) · 3.45 KB
/
hotspot_flow.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
% Sherief Reda (Brown University) and Adel Belouchrani (ENP)
% "Blind Identification of Power Sources in Processors", in IEEE/ACM Design, Automation & Test in Europe, 2017.
% "Blind Identification of Thermal Models and Power Sources from Thermal Measurements ," in IEEE Journal on Sensors,
% sherief_reda@Brown.edu and adel.belouchrani@enp.edu.dz
clear
errors=[];
num_cores=4;
n_samples=280;
% offline-learning
% sampling rate is 1 second per sample
% estimate steady-state matrix R from steady_state data
% find matrix A : T[k]=AT[k-1]+Bp[k]
A = find_A('DATA_HOTSPOT_4CORES/nat_trace_', n_samples-1, 0);
% find matrix B : T[k]=AT[k-1]+Bp[k]
R = find_R('DATA_HOTSPOT_4CORES/steady_state.txt', n_samples-1, 0);
B=(eye(size(A))-A)*R;
% prep the data for online evaluation
eval_data=load('DATA_HOTSPOT_4CORES/eval_cores');
% this is the actual power data used to generate the thermal traces
p_act=eval_data(:, 1:num_cores);
% this is the resultant thermal measurements from Hotspot
MS=size(eval_data(:, num_cores+1:2*num_cores));
% create a trace for power estimation that has 1) total power consumption
% 2) thermal measurements
trace=[sum(eval_data(:, 1:num_cores), 2), eval_data(:, num_cores+1:2*num_cores)];
% write it down in a temporary file
dlmwrite('DATA_HOTSPOT_4CORES/eval_cores_temp', trace, 'delimiter', '\t', 'precision','%.4f');
% on-line evaluation: use the model to identify p; only use temporary file
p=eval_runtime('DATA_HOTSPOT_4CORES/eval_cores_temp', A, B);
p = p';
err=0;
err_perc=0;
maxp=max(p_act(:));
for j=1:size(p, 2)
err = err+mean(abs(p_act(2:end, j)-p(:, j)));
err_perc = err_perc+mean(abs(p_act(2:end, j)-p(:, j)))/maxp;
end
num_cores=size(p,2);
err=err/num_cores;
err_perc=err_perc/num_cores;
errors=[errors; err 100*err_perc]
% plot power and thermal traces
T_amb=25;
n_samples = 280;
X1=eval_data(:, 5:8);
t=1:length(eval_data);
figure
subplot(5, 1, 1);
plot(t,X1+T_amb, 'linewidth', 2);
grid on;
ylabel('Temperature (C)');
xlabel('time (s)');
legend('core 1', 'core 2', 'core 3', 'core 4')
xlim([0 1500]);
t=t(1:end-1);
title('(a) thermal simulation results from HotSpot', 'fontsize', 10);
subplot(5, 1, 2);
plot(t, p(:,1), 'b', 'linewidth', 2);
grid on;
ylabel('Power(W)');
xlabel('time (s)');
title('(b) estimated and actual power consumption of core 1', 'fontsize', 10);
hold on;
ylim([0 30]);
xlim([0 1500]);
plot(t, p_act(2:end,1), '--r', 'linewidth', 2);
grid on;
legend('estimated', 'actual')
subplot(5, 1, 3);
plot(t, p(:,2), 'b', 'linewidth', 2);
grid on;
ylabel('Power(W)');
xlabel('time (s)');
title('(c) estimated and actual power consumption of core 2', 'fontsize', 10);
hold on;
xlim([0 1500]);
ylim([0 30]);
plot(t, p_act(2:end,2), '--r', 'linewidth', 2);
grid on;
legend('estimated', 'actual')
subplot(5, 1, 4);
plot(t, p(:,3), 'b', 'linewidth', 2);
grid on;
legend('estimated', 'actual')
ylim([0 30]);
hold on;
plot(t, p_act(2:end,3), '--r', 'linewidth', 2);
grid on;
title('(d) estimated and actual power consumption of core 3', 'fontsize', 10);
ylim([0 30]);
ylabel('Power(W)');
xlabel('time (s)');
xlim([0 1500]);
legend('estimated', 'actual')
subplot(5, 1, 5);
plot(t, p(:,4), 'b', 'linewidth', 2);
grid on;
hold on;
title('(e) estimated and actual power consumption of core 4', 'fontsize', 10);
plot(t, p_act(2:end,4), '--r', 'linewidth', 2);
ylim([0 30]);
ylabel('Power(W)');
xlabel('time (s)');
xlim([0 1500]);
legend('estimated', 'actual')