-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_all.sh
More file actions
executable file
·156 lines (133 loc) · 4.19 KB
/
run_all.sh
File metadata and controls
executable file
·156 lines (133 loc) · 4.19 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
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
#!/usr/bin/env bash
set -euo pipefail
# Run from the directory that contains these folders:
# LULESH-intel-translation/LULESH-openmp
# HeCBench-lulesh-omp
# LULESH-codex-translation/LULESH-openmp
# LULESH-codex-optimization/LULESH-openmp
# LULESH-openacc
# lulesh-cuda
#
# Output:
# lulesh_bench_summary.md
# lulesh_bench_results.csv
# lulesh_bench_runs.log
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPS="${REPS:-5}"
SIZES=(100 150 200 250 300)
# label -> relative dir
declare -A DIRS=(
["intel_translation"]="LULESH-intel-translation/LULESH-openmp"
["hecbench_openmp"]="HeCBench-lulesh-omp"
["codex_translation"]="LULESH-codex-translation/LULESH-openmp"
["codex_optimization"]="LULESH-codex-optimization/LULESH-openmp"
["openacc"]="LULESH-openacc"
["cuda"]="lulesh-cuda"
)
# Keep a fixed order for reporting
IMPLS=("openacc" "intel_translation" "codex_translation" "codex_optimization" "hecbench_openmp" "cuda")
OUT_CSV="${ROOT}/lulesh_bench_results.csv"
OUT_MD="${ROOT}/lulesh_bench_summary.md"
OUT_LOG="${ROOT}/lulesh_bench_runs.log"
: > "$OUT_CSV"
: > "$OUT_MD"
: > "$OUT_LOG"
echo "impl,s,avg_time,rep_times" >> "$OUT_CSV"
# avg_times["impl,s"]=value
declare -A AVG
die() { echo "ERROR: $*" >&2; exit 1; }
pick_exe() {
if [[ -x "./lulesh" ]]; then
echo "./lulesh"
elif [[ -x "./lulesh2.0" ]]; then
echo "./lulesh2.0"
elif [[ -x "./lulesh-cuda" ]]; then
echo "./lulesh-cuda"
else
return 1
fi
}
extract_time() {
# Tries to parse a numeric time from common LULESH timing lines.
# Prints a single number on success, empty on failure.
awk '
function trim(s){gsub(/^[ \t]+|[ \t]+$/, "", s); return s}
BEGIN{t=""}
/Elapsed[[:space:]]+time|Elapsed[[:space:]]+Time|Total[[:space:]]+time|Total[[:space:]]+Time/{
# Try "something = number ..."
n=split($0, parts, "=")
if (n>=2) {
rhs=trim(parts[2])
split(rhs, tok, /[ \t]/)
if (tok[1] ~ /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/) {print tok[1]; exit}
}
# Fallback: last token that looks like a number
for (i=NF; i>=1; --i) {
if ($i ~ /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/) {print $i; exit}
}
}
'
}
build_dir() {
local d="$1"
echo "==> Building in: $d" | tee -a "$OUT_LOG"
( cd "$d" && make clean && make ) >> "$OUT_LOG" 2>&1
}
run_bench() {
local impl="$1"
local d="$2"
( cd "$d" && {
local exe
exe="$(pick_exe)" || die "No executable ./lulesh (or ./lulesh2.0 or ./lulesh-cuda) in $d after build"
for s in "${SIZES[@]}"; do
local sum="0"
local rep_times=()
for rep in $(seq 1 "$REPS"); do
echo "==> [$impl] s=$s rep=$rep : $exe -i 100 -s $s" | tee -a "$OUT_LOG"
out="$($exe -i 100 -s "$s" 2>&1 | tee -a "$OUT_LOG")"
t="$(printf "%s\n" "$out" | extract_time | head -n1 || true)"
[[ -n "$t" ]] || die "Failed to parse timing for [$impl] s=$s rep=$rep in $d. Check $OUT_LOG."
rep_times+=("$t")
sum="$(awk -v a="$sum" -v b="$t" 'BEGIN{printf "%.12f", a+b}')"
done
avg="$(awk -v a="$sum" -v n="$REPS" 'BEGIN{printf "%.6f", a/n}')"
AVG["$impl,$s"]="$avg"
# Join rep times with ';'
joined="$(IFS=';'; echo "${rep_times[*]}")"
echo "${impl},${s},${avg},\"${joined}\"" >> "$OUT_CSV"
done
}
)
}
# Build + run all
for impl in "${IMPLS[@]}"; do
d_rel="${DIRS[$impl]}"
[[ -d "${ROOT}/${d_rel}" ]] || die "Missing directory: ${ROOT}/${d_rel}"
build_dir "${ROOT}/${d_rel}"
run_bench "$impl" "${ROOT}/${d_rel}"
done
# Write a compact markdown table
{
echo "# LULESH Benchmark Summary"
echo
echo "Command: \`./lulesh -i 100 -s {100,150,200,250,300}\`"
echo "Repetitions per size: ${REPS}"
echo
echo "| Implementation | s=100 | s=150 | s=200 | s=250 | s=300 |"
echo "|---|---:|---:|---:|---:|---:|"
for impl in "${IMPLS[@]}"; do
printf "| %s " "$impl"
for s in "${SIZES[@]}"; do
v="${AVG[$impl,$s]:-NA}"
printf "| %s " "$v"
done
echo "|"
done
echo
echo "Raw per-run data: \`$(basename "$OUT_CSV")\`"
echo "Full logs: \`$(basename "$OUT_LOG")\`"
} > "$OUT_MD"
echo "Done."
echo "Wrote: $OUT_MD"
echo "Wrote: $OUT_CSV"
echo "Wrote: $OUT_LOG"