blob: 3c109973fc5822125e3737cd2d6acfa16e28528a (
plain)
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
|
#!/bin/bash
set -e
rundir=`pwd -P`
mydir="$(dirname $0)"
cd "${mydir}"
mydir="$(pwd)"
cd ${rundir}
usage()
{
cat <<EOF
Usage: $0 --bench bench_names --config config --nodename nodename [OPT]
Options:
--ccprefix prefix
--cflags cflags
--clean_older_than days
--extension {O2|O2g|O3|O3g|etc}
--hw_tag {tk1_32|tx1_64|tx1_32|etc}
--forceinstall true/false
--ignore_errors true/false
--input_size {test|ref}
--iterations N
--nosudo
--resultsdest host:/path/
--run_profile {parallel3x3|parallel3x1|serial1}
--sysroot sysroot_url
--toolchain {gnu|llvm}
--verbose true/false
EOF
exit 1
}
benches=
ccprefix=
cflags=
ldflags="default"
clean_older_than=
config=
extension="O2g"
hw_tag=
forceinstall=false
ignore_errors=false
input_size="test"
iterations="1"
nodename=
nosudo=false
resultsdest=
run_profile="parallel3x3"
sysroot=
toolchain=
verbose=false
while [ $# -ge 1 ]
do
case $1 in
--bench)
benches="${benches} $2"
shift
;;
--ccprefix)
ccprefix="$2"
shift
;;
--cflags)
cflags="$2"
shift
;;
--ldflags)
ldflags="$2"
shift
;;
--clean_older_than)
clean_older_than="$2"
shift
;;
--config)
config="$2"
shift
;;
--extension)
extension="$2"
shift
;;
--hw_tag)
hw_tag="$2"
shift
;;
--forceinstall)
forceinstall=$2
shift
;;
--ignore_errors)
ignore_errors="$2"
shift
;;
--input_size)
input_size="$2"
shift
;;
--iterations)
iterations="$2"
shift
;;
--nodename)
nodename="$2"
shift
;;
--nosudo)
nosudo=true
;;
--resultsdest)
resultsdest="$2"
shift
;;
--run_profile)
run_profile="$2"
shift
;;
--sysroot)
sysroot="$2"
shift
;;
--toolchain)
toolchain="$2"
shift
;;
--verbose)
verbose="$2"
shift
;;
*)
echo "ERROR: Wrong argument: $1"
usage
;;
esac
shift
done
if $verbose; then
verbose="set -x"
else
verbose="set +x"
fi
$verbose
# Sanity checks
[ x"${benches}" = x ] && usage
[ x"${config}" = x ] && usage
[ x"${hw_tag}" = x ] && usage
[ x"${resultsdest}" = x ] && usage
[ x"${nodename}" = x ] && usage
case ${toolchain} in
llvm|gnu) ;;
*) usage ;;
esac
case ${forceinstall} in
true|false) ;;
*)
echo ERROR: Wrong value for --forceinstall: $forceinstall
usage ;;
esac
if $ignore_errors; then
ignore_errors_opt="--ignore_errors"
else
ignore_errors_opt=""
fi
declare -A bmks
# Build list of benchmarks to run per cpu
case "$run_profile" in
serial)
bmks[1]="$benches"
;;
parallel)
read -a benches_arr < <(echo $benches)
n_cores=$(nproc --all)
if [ ${#benches_arr[@]} -ge $n_cores ]; then
# Try to leave CPU #0 to housekeeping tasks
cpu=0
else
cpu=1
fi
while [ ${#benches_arr[@]} -gt 0 ]; do
# Number of benchmarks to run serially per core
N=$(((${#benches_arr[@]} + $n_cores - 1) / $n_cores))
bmks[$cpu]="${benches_arr[*]:0:$N}"
benches_arr=("${benches_arr[@]:$N}")
n_cores=$((n_cores-1))
cpu=$(($cpu+1))
done
;;
esac
cpus=("${!bmks[@]}")
installdir=$HOME/$nodename
mkdir -p ${installdir}
# Clean old results if requested (to make some free space)
for spec in $installdir/cpu2006-*; do
if [ x"$clean_older_than" != x"" ] && [ -d $spec/result ]; then
find $spec/result -depth "(" -type f -o -type l ")" -mtime +$clean_older_than -exec rm {} \;
find $spec/result -depth -empty -delete # removes empty dirs
fi
# Remove SPEC installs with no results (i.e., stale unused versions).
if ! [ -d $spec/result ]; then
needed=false
for cpu in "${cpus[@]}"; do
if [ x"$spec" = x"$installdir/cpu2006-$hw_tag-$cpu" ]; then
needed=true
fi
done
if ! $needed; then
rm -rf $spec
fi
fi
done
sha1=$(git ls-remote ssh://dev-private-git.linaro.org/restricted-benchmarks/CPU2006 refs/heads/master | cut -f 1)
pids=()
for cpu in "${cpus[@]}"; do
delete=$forceinstall
if [ -d $installdir/cpu2006-$hw_tag-$cpu ] \
&& [ x"$(git -C $installdir/cpu2006-$hw_tag-$cpu rev-parse HEAD)" \
!= x"$sha1" ]; then
delete=true
fi
if $delete; then
rm -rf ${installdir}/cpu2006-$hw_tag-$cpu
fi
if [ ! -d ${installdir}/cpu2006-$hw_tag-$cpu ]; then
${mydir}/spec2xxx-install -v \
-d ${installdir}/cpu2006-$hw_tag-$cpu \
-s cpu2006 &
pids+=($!)
# Avoid bashing on the git server too much
sleep 10
fi
done
status=0
echo "Note: Waiting for cpu2006-$hw_tag-* to install"
for pid in "${pids[@]}"; do
result=0; wait $pid || result=$?
if [ $result != 0 ]; then
status=1
fi
done
if [ $status != 0 ]; then
echo "ERROR: Failed installing cpu2006-$hw_tag-*"
exit $status
fi
if [ x"$sysroot" != x"" ]; then
sysroot_remote=${sysroot%:*}
sysroot_dir=${sysroot##*:}
sysroot_host="$(echo $sysroot_remote | cut -d: -f 1)"
sysroot_port="$(echo $sysroot_remote | cut -s -d: -f 2)"
rsync -a --del -e "ssh ${sysroot_port:+-p$sysroot_port}" \
"$sysroot_host:$sysroot_dir/" "$HOME/sysroot/"
sysroot_opt="--sysroot $HOME/sysroot"
else
sysroot_opt=""
fi
$nosudo || sudo ${mydir}/prepare-board.sh --action start_docker \
--hw_tag "$hw_tag" --verbose
case "$hw_tag" in
apm_*)
# APMs run at 2.4GHz, but they have no cpufreq driver, so we
# can't query core frequency.
perf_cycles_period="240000000"
;;
tk1_*|tx1_*)
# We sample at 10HZ, but, due to perf_hack workaround we need
# double that.
perf_cycles_period="20HZ"
;;
sq_*)
# SynQuacers run at 1GHz, but they have no cpufreq driver, so we
# can't query core frequency.
perf_cycles_period="100000000"
;;
esac
# Configure the benchmarks
for cpu in "${cpus[@]}"
do
${mydir}/spec2xxx-config --config $config --ccprefix $ccprefix \
--ccflags "$cflags" --ldflags "$ldflags" --bind $cpu \
--perf-bin "/usr/lib/linux-tools/$hw_tag/perf" \
--helpercpu 0 --profiler perf \
-e cycles/period=$perf_cycles_period/u \
--perf-buildid-dir local --save-temps $sysroot_opt \
--toolchain $toolchain -v ${installdir}/cpu2006-$hw_tag-$cpu
done
# Build the benchmarks
pids=()
for cpu in "${cpus[@]}"
do
# If nothing to run on this cpu, continue
[ x"${bmks[${cpu}]}" = x ] && continue
(
cd ${installdir}/cpu2006-$hw_tag-$cpu
set +x
. shrc
$verbose
runspec -c $config -e $extension -a build ${ignore_errors_opt} ${bmks[$cpu]} &
result=0 && wait $! || result=$?
${mydir}/spec2xxx-result -v --dest $resultsdest --tag $config --part .build.$cpu --extension $extension ./
exit $result
) &
pids+=($!)
done
echo "Note: Waiting for builds to finish"
for pid in "${pids[@]}"; do
result=0; wait $pid || result=$?
if [ $result != 0 ]; then
status=1
fi
done
# Close ssh connection used for building
for cpu in "${cpus[@]}"; do
cleanup=${installdir}/cpu2006-$hw_tag-$cpu/bin/ssh-$config-finish_build
if [ -e $cleanup ]; then
$cleanup
fi
done
if $ignore_errors; then
# Remove failed-to-build benchmarks from run lists.
# Otherwise we will try to build them again.
for cpu in "${cpus[@]}"; do
failed_csv="${installdir}/cpu2006-$hw_tag-$cpu/result/failed.$config.csv.build.$cpu"
if [ ! -f "$failed_csv" ]; then
continue
fi
read -a build_bmks < <(echo "${bmks[$cpu]}")
bmks[$cpu]=""
for bmk in "${build_bmks[@]}"; do
if ! grep -q "^$bmk," "$failed_csv"; then
bmks[$cpu]="${bmks[$cpu]} $bmk"
fi
done
done
elif [ $status != 0 ]; then
# Skip running benchmarks, and execute prepare-board.sh cleanups.
cpus=()
fi
# Run the benchmarks
pids=()
for cpu in "${cpus[@]}"; do
# If nothing to run on this cpu, continue
[ x"${bmks[${cpu}]}" = x ] && continue
(
cd ${installdir}/cpu2006-$hw_tag-$cpu
set +x
. shrc
$verbose
taskset -c 0 runspec -c $config -e $extension -a run -n $iterations -i $input_size ${ignore_errors_opt} ${bmks[$cpu]} &
result=0 && wait $! || result=$?
${mydir}/spec2xxx-result -v --dest ${resultsdest} --tag $config --part .run.$cpu --extension $extension ./
exit $result
) &
pids+=($!)
done
echo "Note: Waiting for runs to finish"
for pid in "${pids[@]}"; do
result=0; wait $pid || result=$?
if [ $result != 0 ]; then
status=1
fi
done
echo "Note: Runs finished"
$nosudo || sudo ${mydir}/prepare-board.sh --action stop_docker --verbose &
result=0 && wait $! || result=$?
if [ $result != 0 ]; then
echo "Warning: prepare-board.sh did not finish cleanly"
fi
if $ignore_errors && [ $status != 0 ]; then
echo "Ignoring build and/or run failures with status $status and exiting with 0"
exit 0
fi
exit $status
|