-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcalc-spec-qemu.sh
More file actions
executable file
·109 lines (96 loc) · 2.23 KB
/
Copy pathcalc-spec-qemu.sh
File metadata and controls
executable file
·109 lines (96 loc) · 2.23 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
# Script to compute SPEC CPU 2017 scores obtained by QEMU
# Copyright (C) 2023, 2024 Embecosm Limited
# Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
# SPDX-License-Identifier: GPL-3.0-or-later
# This script searches for generated instruction count (*.icount) files in the
# SPEC directory. This is converted to a time, on the basis of QEMU executing
# 10^9 instructions per second. Usage:
#
# calc-spec-qemu.sh [--csv|--md] [--specdir <SPEC dir>]
set -u
# Print out the help message
dohelp () {
echo "Usage: calc-spec-qemu.sh [--csv|--md]"
echo " [--speclog <log>]"
echo " [--help|-h]"
}
# Set default values
topdir="$(dirname $(cd $(dirname $0) && echo ${PWD}))"
tooldir="${topdir}/rise-rvv-tcg-qemu-tooling"
installdir="${topdir}/install"
tmpfile="$(mktemp -p /tmp calc-spec-qemu-XXXXXXXX)"
pformat=""
speclog=
specdir=
# Parse command line options
set +u
until
opt="$1"
case "${opt}"
in
--csv|--md)
pformat="$1"
;;
--speclog)
shift
if [ ! -e "$1" ]
then
echo "ERROR: non-existent SPEC log: exiting"
exit 1
else
speclog="$1"
specdir="$(sed -n -e 's/^specdir:[[:space:]]\+\(.*\)$/\1/p' < $1)"
if [ ! -d ${specdir} ]
then
"ERROR: non-existent SPEC directory \"${specdir}\""
exit 1
fi
fi
;;
--help|-h)
dohelp
exit 0
;;
?*)
echo "Unknown argument '$1'"
dohelp
exit 1
;;
esac
[ "x${opt}" = "x" ]
do
shift
done
set -u
if [ "x${specdir}" = "x" ]
then
dohelp
exit 1
fi
# Work out which base data set to use
datasize=$(grep '^size: ' ${speclog} | head -1 | sed -e 's/size:[[:space:]]\+//')
case ${datasize}
in
test)
basedata="${tooldir}/specbasedata-test.txt"
;;
ref)
basedata="${tooldir}/specbasedata-ref.txt"
;;
*)
echo "Unsupported size: ${size}"
exit 1
;;
esac
# Total the workloads for each benchmark
rm -f ${tmpfile}
touch ${tmpfile}
for icf in $(find ${specdir} -name '*.icount' -print)
do
bm=$(basename ${icf} | sed -e 's/-.*//')
ic="$(sed -n -e 's/total insns: //p' < ${icf})"
printf "%-15s %15d\n" ${bm} ${ic} >> ${tmpfile}
done
awk -f ${tooldir}/collate-times.awk ${pformat} ${basedata} < ${tmpfile}
rm ${tmpfile}