forked from ARM-software/ComputeLibrary
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtemp.py
More file actions
90 lines (77 loc) · 2.22 KB
/
Copy pathtemp.py
File metadata and controls
90 lines (77 loc) · 2.22 KB
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
import os
import time
import subprocess
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
from scipy.optimize import curve_fit
from os import environ
pp = "./build/release/examples/"
graphs = [
"graph_alexnet",
"graph_mobilenet",
"graph_resnet50",
]
cp = ["--target=NEON", "--threads=4"]
gp = ["--target=CL"]
sm = ["taskset", "-c", "0-3"]
bg = ["taskset", "-c", "4-7"]
targets = {
"cpu_big": lambda g: bg + [pp + g] + cp,
"cpu_small": lambda g: sm + [pp + g] + cp,
"gpu": lambda g: [pp + g] + gp
}
T = 5
dt = 0.1
temp_func = lambda t, q0, qi, tau: q0 + qi * (1 - np.exp(- t / tau))
def get_temp():
with open('/sys/class/thermal/thermal_zone0/temp') as f:
temp = int(f.readline())
return temp
def plot_temp(graph, target, x, y, popt, i):
fig = plt.figure()
plt.plot(x, y)
plt.plot(x, temp_func(x, *popt),
'r-',
label='fit: Q0=%5.3f, Qinf=%5.3f, Tau=%5.3f' % tuple(popt))
plt.axhline(65000, linestyle='--', color='r')
plt.xlabel('Time')
plt.ylabel('Temperature')
plt.title('Execution ' + graph + " " + target)
plt.legend(loc='best')
plt.savefig('temp_plots/' + graph + "_" + target + "_" + str(i) + ".png")
plt.close(fig)
def get_params(graph, target, x, y, i):
try:
popt, _ = curve_fit(temp_func, x, y, bounds=(0, np.inf))
print('> Q0=%5.3f, Qinf=%5.3f, Tau=%5.3f' % tuple(popt))
plot_temp(graph, target, x, y, popt, i)
return popt
except:
print("> Bad Graph")
return []
def find_params(graph, target, cmd, i):
x = []
y = []
t = 0
time.sleep(T)
p = subprocess.Popen(cmd, env=env)
while p.poll() == None:
x.append(t)
y.append(get_temp())
time.sleep(dt)
t += dt
x = np.array(x)
y = np.array(y)
return get_params(graph, target, x, y, i)
if __name__ == "__main__":
env = dict(os.environ)
env['LD_LIBRARY_PATH'] = './build/release'
RCs = {}
for graph in graphs:
print(graph)
for target in targets:
print(target)
for i in range(5):
RCs[(graph, target)] = find_params(graph, target, targets[target](graph), i)