-
Notifications
You must be signed in to change notification settings - Fork 2
/
sombrero.sh
executable file
·83 lines (73 loc) · 2.3 KB
/
sombrero.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
#!/bin/bash
# Run each of the benchmarks and calculate an average
# Create a new tempfile for a copy of the output
tmpfile=$(mktemp /tmp/sombrero_XXXXXXXXX)
# Clean finish
function finish {
rm -rf "$tmpfile"
}
trap finish EXIT
# Print usage and quit
function usage {
echo "./sombrero.sh { -n <num-cores> | -H <hostfile> } [ -w ] [ -s small | medium | large | very_large ]" >&2
exit 1
}
# safe run
trap "exit 1" TERM
export TOP_PID=$$
function safe_run {
$@
if [ $? -ne 0 ]; then
kill -s TERM $TOP_PID
fi
}
#### main
# check arguments
shopt -s extglob
while getopts 'n:H:s:whl:p:' opt ; do
case "$opt" in
n)
case "$OPTARG" in
(+([0-9])) nodes="-n $OPTARG " ;;
"") usage ;;
esac ;;
H)
case "$OPTARG" in
"") usage ;;
*) nodes="-hostfile $OPTARG " ;;
esac ;;
s)
case "$OPTARG" in
"small" | "medium" | "large" | "very_large") size="-s $OPTARG " ;;
*) usage ;;
esac ;;
l)
case "$OPTARG" in
"") usage ;;
*) size="-l $OPTARG " ;;
esac ;;
p)
case "$OPTARG" in
"") usage ;;
*) partition="-p $OPTARG " ;;
esac ;;
w) weak="-w " ;;
h|?) usage ;;
esac
done
# Run each of the benchmarks, copy output to stdout and the tempfile
safe_run mpirun $nodes sombrero/sombrero1 $weak $size $partition | tee $tmpfile
safe_run mpirun $nodes sombrero/sombrero2 $weak $size $partition -v result | tee -a $tmpfile
safe_run mpirun $nodes sombrero/sombrero3 $weak $size $partition -v result | tee -a $tmpfile
safe_run mpirun $nodes sombrero/sombrero4 $weak $size $partition -v result | tee -a $tmpfile
safe_run mpirun $nodes sombrero/sombrero5 $weak $size $partition -v result | tee -a $tmpfile
safe_run mpirun $nodes sombrero/sombrero6 $weak $size $partition -v result | tee -a $tmpfile
# Calculate the sums of the timings and the flop counts
grep RESULT $tmpfile | grep -v "Gflops/seconds" | \
awk '{
time+=$7;
Gflops+=$4;}
END {
printf("[RESULT] SUM %.2f Gflops in %.2f seconds\n", Gflops, time);
printf("[RESULT] SUM %.2f Gflops/seconds\n", Gflops/ time);
}'