-
Notifications
You must be signed in to change notification settings - Fork 7
/
stabilityTester.sh
executable file
·114 lines (96 loc) · 3.5 KB
/
stabilityTester.sh
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
112
#!/bin/bash
XHPLBINARY="xhpl64"
MINFREQUENCY=640000 #Only test frequencies from this point.
MAXFREQUENCY=1200000 #Only test frequencies upto this point.
COOLDOWNTEMP=55000 #Cool down after a test to mC degrees
COOLDOWNFREQ=640000 # Set to this speed when cooling down
CPUFREQ_HANDLER="/sys/devices/system/cpu/cpu0/cpufreq/";
SCALINGAVAILABLEFREQUENCIES="scaling_available_frequencies";
SCALINGMINFREQUENCY="scaling_min_freq";
SCALINGMAXFREQUENCY="scaling_max_freq";
SOCTEMPCMD="/sys/class/thermal/thermal_zone0/temp"
REGULATOR_HANDLER="/sys/class/regulator/regulator.2/"
REGULATOR_MICROVOLT="microvolts"
ROOT=$(pwd)
declare -A VOLTAGES=()
# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
trap "{ killall ${ROOT}/${XHPLBINARY}; exit 0; }" SIGINT SIGTERM
if [ ! -d "${ROOT}/results" ];
then
echo "Create";
mkdir ${ROOT}/results;
fi
if [ ! -f "/usr/lib/libmpich.so.12" ];
then
echo "You need libmpich-dev to run xhpl"
echo "Install using sudo apt install libmpich-dev"
exit 1
fi
AVAILABLEFREQUENCIES=$(cat ${CPUFREQ_HANDLER}${SCALINGAVAILABLEFREQUENCIES})
for FREQUENCY in $AVAILABLEFREQUENCIES
do
if [ $FREQUENCY -ge $MINFREQUENCY ] && [ $FREQUENCY -le $MAXFREQUENCY ];
then
echo "Testing frequency ${FREQUENCY}";
if [ $FREQUENCY -gt $(cat ${CPUFREQ_HANDLER}${SCALINGMAXFREQUENCY}) ];
then
echo $FREQUENCY > ${CPUFREQ_HANDLER}${SCALINGMAXFREQUENCY}
echo $FREQUENCY > ${CPUFREQ_HANDLER}${SCALINGMINFREQUENCY}
else
echo $FREQUENCY > ${CPUFREQ_HANDLER}${SCALINGMINFREQUENCY}
echo $FREQUENCY > ${CPUFREQ_HANDLER}${SCALINGMAXFREQUENCY}
fi
${ROOT}/$XHPLBINARY > ${ROOT}/results/xhpl_${FREQUENCY}.log &
echo -n "Soc temp:"
while pgrep -x $XHPLBINARY > /dev/null
do
SOCTEMP=$(cat ${SOCTEMPCMD})
CURFREQ=$(cat ${CPUFREQ_HANDLER}${SCALINGMINFREQUENCY})
CURVOLT=$(cat ${REGULATOR_HANDLER}${REGULATOR_MICROVOLT})
echo -ne "\rSoc temp: ${SOCTEMP} \tCPU Freq: ${CURFREQ} \tCPU Core: ${CURVOLT} \t"
if [ $CURFREQ -eq $FREQUENCY ];
then
VOLTAGES[$FREQUENCY]=$CURVOLT
fi
sleep 1;
done
echo -ne "\r"
echo -n "Cooling down"
echo $COOLDOWNFREQ > ${CPUFREQ_HANDLER}${SCALINGMINFREQUENCY}
echo $COOLDOWNFREQ > ${CPUFREQ_HANDLER}${SCALINGMAXFREQUENCY}
while [ $SOCTEMP -gt $COOLDOWNTEMP ];
do
SOCTEMP=$(cat ${SOCTEMPCMD})
echo -ne "\rCooling down: ${SOCTEMP}"
sleep 1;
done
echo -ne "\n"
fi
done
echo -e "\nDone testing stability:"
for FREQUENCY in $AVAILABLEFREQUENCIES
do
if [ $FREQUENCY -ge $MINFREQUENCY ] && [ $FREQUENCY -le $MAXFREQUENCY ];
then
FINISHEDTEST=$(grep -Ec "PASSED|FAILED" ${ROOT}/results/xhpl_${FREQUENCY}.log )
SUCCESSTEST=$(grep -Ec "PASSED" ${ROOT}/results/xhpl_${FREQUENCY}.log )
DIFF=$(grep -E 'PASSED|FAILED' ${ROOT}/results/xhpl_${FREQUENCY}.log)
#echo $DIFF
DIFF="${DIFF#*=}"
DIFF="${DIFF#* }"
#echo $DIFF
RESULTTEST="${DIFF% .*}"
VOLTAGE=${VOLTAGES[$FREQUENCY]}
if [ $FINISHEDTEST -eq 1 ];
then
echo -ne "Frequency: ${FREQUENCY}\t"
echo -ne "Voltage: ${VOLTAGE}\t"
echo -ne "Success: ${SUCCESSTEST}\t"
echo -ne "Result: ${RESULTTEST}\n"
fi
fi
done