-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeasure.sh
More file actions
executable file
·255 lines (215 loc) · 7.19 KB
/
measure.sh
File metadata and controls
executable file
·255 lines (215 loc) · 7.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
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
#!/usr/bin/env bash
export SCRIPTDIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
# Include our support libraries
source "$SCRIPTDIR/utils/continuation.inc.sh"
source "$SCRIPTDIR/utils/logging.inc.sh"
source "$SCRIPTDIR/utils/printing.inc.sh"
now=$(date "+%y%m%d_%H%M%S")
printf "HARP Benchmark Suite\n -- Measure Script --\n\n"
if [ ! -e "${SCRIPTDIR}/config.inc.sh" ]; then
printf "Missing config file 'config.inc.sh'!\n"
exit 1;
fi
printf "Sourcing the main configuration file\n"
success=1
source "$SCRIPTDIR/config.inc.sh"
if [ -z "${scenarios+x}" ]; then
printf "Missing configuration option 'scenarios'\n"
success=0
fi
if [ -z "${runs+x}" ]; then
printf "Missing configuration option 'runs'\n"
success=0
fi
if [ -z "${modes+x}" ]; then
printf "Missing configuration option 'modes'\n"
success=0
fi
if [ $success -ne 1 ]; then
printf "Incomplete benchmark configuration, check your 'config.inc.sh'\n"
exit 1;
fi
# Initialize all optional configuration options
result_dir=${result_dir:-"${now}/results"}
log_dir=${log_dir:-"${now}/logs"}
trace_dir=${trace_dir:-"${now}/traces"}
learn_dir=${learn_dir:-"${now}/learn-db"}
printf "Running the following configuration:\n"
printf " platform: ${platform_name}\n"
printf " ${#scenarios[@]} scenario(s): ${scenarios[*]}\n"
printf " ${runs} run(s)\n"
printf " ${#modes[@]} mode(s): ${modes[*]}\n"
printf "Output Directories:\n"
printf " - results: ${result_dir}\n"
printf " - logs: ${log_dir}\n"
printf " - traces: ${trace_dir}\n"
printf " - learning DB: ${learn_dir}\n"
printf "Sourcing mode configurations:\n"
success=1
for m in ${modes[@]}; do
printf " -> $m"
if [ ! -e "${SCRIPTDIR}/modes/${m}.inc.sh" ]; then
printf " XX Missing mode config file 'modes/${m}.inc.sh' !!\n"
success=0
else
printf " success\n"
source "${SCRIPTDIR}/modes/${m}.inc.sh"
fi
done
if [ $success -ne 1 ]; then
printf "Incomplete modes configuration!\n"
exit 1;
fi
printf "Checking the system configuration:\n"
success=1
printf " - Access to energy sensors "
get_energy 1>/dev/null 2>&1
if [ $? -ne 0 ]; then
printf "NO!\n"
success=0
else
printf "Yes\n"
fi
printf " - Access to perf "
if [ $UID -ne 0 -a $(cat /proc/sys/kernel/perf_event_paranoid) -ne -1 ]; then
printf "NO!\n"
success=0
else
printf "Yes\n"
fi
printf " - Platform specific checks "
failure=$(${platform_routines[check]})
if [ $failure -eq 1 ]; then
printf "NO!\n"
success=0
else
printf "Yes\n"
fi
printf " - Access to all tools of the benchmarking modes\n"
for m in ${modes[@]}; do
printf " - $m "
result=$(check_$m)
if [ $result -eq 1 ]; then
printf "NO!\n"
success=0
else
printf "Yes\n"
fi
done
printf " - Access to all scenario binaries\n"
for s in ${scenarios[@]}; do
printf " - $(human_readable $s) "
IFS='|' read -r -a progs <<< "$s"
all_good=1
for p in ${progs[@]}; do
p_name=$(save_name $p)
if [ ! -x "${BINDIR}/${p_name}" ]; then
all_good=0
printf "NO! $p_name missing!\n"
break
fi
if [[ "$p" == \?* ]]; then
if [ ! -e "${BINDIR}/${p_name}.args" ]; then
all_good=0
printf "NO! $p_name args missing!\n"
break
fi
fi
done
if [ $all_good -eq 1 ]; then
printf "Yes\n"
else
success=0
break
fi
done
if [ $success -ne 1 ]; then
printf "Incomplete system configuration!\nDid you run the prepare script??\n"
exit 1;
fi
continuation=${continuation:-0}
if [ $continuation -eq 1 ]; then
printf "Trying to restore previous run …\n"
restore
else
# Create the necessary output directories
mkdir -p "$result_dir"
mkdir -p "$log_dir"
mkdir -p "$trace_dir"
mkdir -p "$learn_dir"
fi
step=1
total_step=${#scenarios[@]}
for s in ${scenarios[@]}; do
pname="$(human_readable $s)"
printf "(${step}/${total_step}) $pname\n"
measure_result_file="${result_dir}/$(save_name $s).csv"
learning_result_file="${result_dir}/learning_$(save_name $s).csv"
scenario_log_dir="${log_dir}/$(save_name $s)"
scenario_trace_dir="${trace_dir}/$(save_name $s)"
scenario_learn_dir="${learn_dir}/$(save_name $s)"
for m in ${modes[@]}; do
printf " => ${m}: ";
if [[ $m =~ "learning" ]]; then
this_result_file="$learning_result_file"
if [ ! -e "$this_result_file" ]; then
echo "iteration;time_ms;energy_uj;stages" > "$this_result_file"
fi
else
this_result_file="$measure_result_file"
if [ ! -e "$this_result_file" ]; then
echo "mode;time_ms;energy_uj" > "$this_result_file"
fi
fi
# Initialize and create output directories
this_log_dir_base="${scenario_log_dir}/${m}"
this_trace_dir_base="${scenario_trace_dir}/${m}"
this_learn_dir="${scenario_learn_dir}/${m}"
mkdir -p "${this_learn_dir}"
warmup_log_dir="${this_log_dir_base}/warmup"
warmup_trace_dir="${this_trace_dir_base}/warmup"
mkdir -p "$warmup_log_dir"
mkdir -p "$warmup_trace_dir"
# Before making the measurements call the warmup function of the mode
printf "WU ";
success=$(warmup_${m} "$s" "$warmup_log_dir" "$warmup_trace_dir" "$this_learn_dir")
if [ $success -eq 1 ]; then
# Warm up is done, do the actual measurements now
if [[ $m =~ "learning" ]]; then
run_${m} "$s" "$this_result_file" "$this_log_dir_base" "$this_trace_dir_base" "$this_learn_dir"
else
for r in $(seq 1 $runs); do
tries=0
success=0
while [ $success -ne 1 ]; do
printf "$r "
# Initialize the output directories for this run
this_log_dir="${this_log_dir_base}/run_$r-$tries"
this_trace_dir="${this_trace_dir_base}/run_$r-$tries"
mkdir -p "${this_log_dir}"
mkdir -p "${this_trace_dir}"
success=$(run_${m} "$s" "$this_result_file" "$this_log_dir" "$this_trace_dir" "$this_learn_dir")
if [ $success -ne 1 ]; then
printf "!! "
tries=$((tries + 1))
fi
done
checkpoint "$s" "$m" "$r"
done
fi
else
printf "Failure!"
fi
printf "\n"
done
# Compress the directory containing the logs and other debugging data when done with the scenario
printf " -> Compressing debug data ("
printf "logs "
tar -caf "${scenario_log_dir}.tar.gz" -C "$log_dir" "$(save_name $s)" && rm -rf "${scenario_log_dir}"
printf "traces "
tar -caf "${scenario_trace_dir}.tar.gz" -C "$trace_dir" "$(save_name $s)" && rm -rf "${scenario_trace_dir}"
printf "learndb)"
tar -caf "${scenario_trace_dir}.tar.gz" -C "$learn_dir" "$(save_name $s)" && rm -rf "${scenario_learn_dir}"
printf " DONE\n"
step=$((step + 1))
done