-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathgather_results.sh
executable file
·122 lines (104 loc) · 2.8 KB
/
gather_results.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
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
function usage
{
echo "$0 [-a sse|avx2|avx512|avx512bw|avx512vbmi|avx512vl] [-n name] [-k]"
}
BASENAME=results
ARCHITECTURE=sse
TARGET=benchmark
KEEP=0
while getopts ":a:n:hk" o
do
case "${o}" in
a)
ARCHITECTURE=${OPTARG}
if [[ ${ARCHITECTURE} == "sse" ]]
then
TARGET=benchmark
elif [[ ${ARCHITECTURE} == "avx2"
|| ${ARCHITECTURE} == "avx512"
|| ${ARCHITECTURE} == "avx512bw"
|| ${ARCHITECTURE} == "avx512vl"
|| ${ARCHITECTURE} == "avx512vbmi" ]]
then
TARGET=benchmark_${ARCHITECTURE}
else
echo "Wrong architecture ${ARCHITECTURE}"
usage
exit 1
fi
;;
n)
BASENAME=${OPTARG}
;;
k)
KEEP=1
;;
h)
usage
exit 0
;;
esac
done
ENCODE_RESULTS_PATH=encode_${BASENAME}.txt
DECODE_RESULTS_PATH=decode_${BASENAME}.txt
ENCODE_TABLE_PATH=encode_${BASENAME}.table
DECODE_TABLE_PATH=decode_${BASENAME}.table
META_PATH=${BASENAME}.meta
ARCHIVE_PATH=${BASENAME}.tgz
function build_benchmark
{
make -C encode ${TARGET}
make -C decode ${TARGET}
}
function run_benchmark
{
local ALGORITHM=$1
local RESULTS_PATH=$2
local LOOPS=3
echo "Running ${ALGORITHM} benchmark..."
rm -f ${RESULTS_PATH}
for i in `seq ${LOOPS}`
do
./${ALGORITHM}/${TARGET} >> ${RESULTS_PATH}
done
}
function get_metadata
{
CPUINFO=$(awk -F: '/^model name/ {
gsub(/^[ ]+/, "", $2); # remove leading spaces
gsub(/[ ]+$/, "", $2); # remove trailing spaces
gsub(/[ ]+/, " ", $2); # normalize spaces
print $2;
exit # print just 1st CPU
}' < /proc/cpuinfo)
GCCVERSION=$(gcc --version | head -n1)
rm -f ${META_PATH}
echo "CPU: ${CPUINFO}" >> ${META_PATH}
echo "GCC: ${GCCVERSION}" >> ${META_PATH}
}
function create_table
{
local RESULTS_PATH=$1
local TABLE_PATH=$2
python scripts/format.py ${RESULTS_PATH} > ${TABLE_PATH}
}
function create_archive
{
local files="${META_PATH} ${ENCODE_RESULTS_PATH} ${ENCODE_TABLE_PATH} ${DECODE_RESULTS_PATH} ${DECODE_TABLE_PATH}"
if [[ ${KEEP} == 1 ]]
then
tar -czf ${ARCHIVE_PATH} ${files}
echo "File '${ARCHIVE_PATH}' was created"
else
tar --remove-files -czf ${ARCHIVE_PATH} ${files}
echo "Files ${files} moved to archive ${ARCHIVE_PATH}"
fi
}
build_benchmark
run_benchmark encode ${ENCODE_RESULTS_PATH}
run_benchmark decode ${DECODE_RESULTS_PATH}
create_table ${ENCODE_RESULTS_PATH} ${ENCODE_TABLE_PATH}
create_table ${DECODE_RESULTS_PATH} ${DECODE_TABLE_PATH}
get_metadata
create_archive