-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_benchmarks.sh
executable file
·310 lines (288 loc) · 8.26 KB
/
run_benchmarks.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
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
#!/bin/bash
# run_benchmarks.sh
# This test script compiles each benchmark problem in serial and parallel
# then executes the parallel program in 2D. The length of the test can be
# controlled by selecting default (1,000 steps), long (5,000 steps), or
# extra long (25,000 steps). The resulting checkpoints are then converted
# to PNG images to spot check problems in the code or environment, including
# execution errors and numerical instabilities.
#
# Questions/comments to [email protected] (Trevor Keller)
# Valid flags are:
# --noexec build in serial and parallel, but do not execute
# --noviz do not convert data for visualization
# --force pass -B flag to make
# --np X pass mpirun X ranks (e.g., --np 3 yields mpirun -np 3)
# --short execute tests .1x default
# --long execute tests 5x longer than default
# --extra execute tests 25x longer than default
# --clean delete generated files (binaries, data, imges) after test completes
# Set output colors
RED='\033[0;31m'
GRN='\033[0;32m'
WHT='\033[0m' # No Color
# Initialize timer and completion counters
tstart=$(date +%s)
nSerErr=0
nParErr=0
nRunErr=0
nSerBld=0
nParBld=0
nParRun=0
MFLAG="-s"
# Set execution parameters
ITERS=4000
INTER=250
CORES=4
COREMAX=$(nproc)
if [[ $CORES -gt $COREMAX ]]
then
CORES=$COREMAX
fi
problems=$(pwd)
# Define the directories to execute, in order. Formatting matters.
exdirs=("periodic/" \
"no-flux/" \
"T-shape/")
exlabels=("a" \
"b" \
"c")
echo -n "Building problems in serial and parallel"
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--force)
echo -n ", forcing build"
MFLAG="-Bs"
;;
--clean)
echo -n ", cleaning up after"
CLEAN=true
;;
--noexec)
echo -n ", not executing"
NEXEC=true
;;
--short)
ITERS=$(($ITERS/10))
INTER=$ITERS
;;
--long)
ITERS=$((10*$ITERS))
INTER=$(($ITERS/10))
;;
--extra)
ITERS=$((100*$ITERS))
INTER=$(($ITERS/100))
;;
--steadystate)
ITERS=51200000
INTER=102400
;;
--noviz)
echo -n ", no PNG output"
NOVIZ=true
;;
--np)
shift
CORES=$1
;;
*)
echo "WARNING: Unknown option ${key}."
echo
;;
esac
shift # pop first entry from command-line argument list, reduce $# by 1
done
if [[ ! $NEXEC ]]
then
echo ", taking $ITERS steps $INTER at a time, using $CORES/$COREMAX MPI ranks"
else
echo
fi
if [[ ! $NOVIZ ]]
then
# Remove existing images first. If the test fails,
# no images in the directory is an obvious red flag.
rm -f test.*.png
if [[ $(which mmsp2png) == "" ]]
then
# Consult doc/MMSP.manual.pdf if this fails.
echo "mmsp2png utility not found. Please check your installation,"
echo " or pass --noviz flag to suppress PNG output."
fi
fi
echo "--------------------------------------------------------------------------"
rm -rf ./*/meta.yml ./*/error.log
codeversion=$(git submodule status | awk '{print $1}')
repoversion=$(git rev-parse --verify HEAD)
cpufreq=$(lscpu | grep "max MHz" | awk '{print $NF/1000}')
if [[ $cpufreq == "" ]]
then
cpufreq=$(grep -m1 MHz /proc/cpuinfo | awk '{print $NF/1000}')
fi
ndots=$(($ITERS / $INTER))
sumspace=$((32 - $ndots/2))
n=${#exdirs[@]}
for (( i=0; i<$n; i++ ))
do
exstart=$(date +%s)
j=$(($i+1))
printf "%s %-${sumspace}s" ${exlabels[$i]} ${exdirs[$i]}
cd $problems/${exdirs[$i]}
# Write simulation particulars. Should work on any Debian-flavored GNU/Linux OS.
echo "---" >>meta.yml
echo "benchmark:" >>meta.yml
echo " id: 1${exlabels[$i]}" >>meta.yml
echo " version: 1" >>meta.yml
echo "" >>meta.yml
echo "metadata:" >>meta.yml
echo " # Describe the runtime environment" >>meta.yml
echo " summary: MPI parallel Travis-CI benchmark with MMSP, ${exdirs[$i]/\//} domain" >>meta.yml
echo " author: Trevor Keller" >>meta.yml
echo " email: [email protected]" >>meta.yml
echo " timestamp: $(date -R)" >>meta.yml
echo " hardware:" >>meta.yml
echo " # Required hardware details" >>meta.yml
echo " architecture: $(uname -m)" >>meta.yml
echo " cores: ${CORES}" >>meta.yml
echo " # Optional hardware details" >>meta.yml
echo " details:" >>meta.yml
echo " - name: clock" >>meta.yml
echo " values: ${cpufreq}" >>meta.yml
echo " # unit: GHz" >>meta.yml
echo " software:" >>meta.yml
echo " name: mmsp" >>meta.yml
echo " version: \"5.2\"" >>meta.yml
echo " repo:" >>meta.yml
echo " url: https://github.com/mesoscale/mmsp/tree/develop" >>meta.yml
echo " version: \"${codeversion}\"" >>meta.yml
echo " implementation:" >>meta.yml
echo " end_condition: time limit, Travis CI runs die after 50 minutes total" >>meta.yml
echo " repo:" >>meta.yml
echo " url: https://github.com/mesoscale/MMSP-spinodal-decomposition-benchmark/tree/master/${exdirs[$i]}" >>meta.yml
echo " version: \"${repoversion}\"" >>meta.yml
echo " # badge: https://api.travis-ci.org/mesoscale/MMSP-spinodal-decomposition-benchmark.svg?branch=master" >>meta.yml
echo " details:" >>meta.yml
echo " - name: mesh" >>meta.yml
echo " values: uniform rectilinear" >>meta.yml
echo " - name: numerical_method" >>meta.yml
echo " values: explicit finite difference" >>meta.yml
echo " - name: compiler" >>meta.yml
echo " values: GNU mpic++" >>meta.yml
echo " - name: parallel_model" >>meta.yml
echo " values: MPI" >>meta.yml
echo "" >>meta.yml
if make $MFLAG
then
((nSerBld++))
else
((nSerErr++))
fi
if make $MFLAG parallel
then
((nParBld++))
else
((nParErr++))
fi
if [[ -f parallel ]] && [[ ! $NEXEC ]]
then
# Run the example in parallel, for speed.
rm -f test*.dat
# Note: final simulation time is written by the program,
# so this script finishes the partial runtime block output
(/usr/bin/time -f " \"time\": %e # seconds\n }\n ]\n - name: memory_usage\n values:\n [\n {\n \"value\": %M,\n \"unit\": KB\n }\n ]" bash -c \
"/usr/bin/mpirun.openmpi -np $CORES ./parallel --example 2 test.0000.dat 1>>meta.yml 2>>error.log && \
/usr/bin/mpirun.openmpi -np $CORES ./parallel test.0000.dat $ITERS $INTER 1>>meta.yml 2>>error.log") &>>meta.yml &
# Travis CI quits after 10 minutes with no CLI activity. Give it an indication that things are running.
sleep 15
SELF=$(whoami)
JOBID=$(pgrep -u $SELF mpirun.openmpi)
echo -n "•"
NFILES=$(ls -1 test.*.dat | wc -l)
while kill -0 "${JOBID}" &>/dev/null
do
sleep 15
CHKFILES=$(ls -1 test.*.dat | wc -l)
if [ "${CHKFILES}" -ne "${NFILES}" ]
then
# A checkpoint was written while we slept. Tell the terminal.
echo -n "•"
NFILES=$CHKFILES
fi
JOBID=$(pgrep -u $SELF mpirun.openmpi)
done
# Return codes are not reliable. Save errors to disk for postmortem.
if [[ -f error.log ]] && [[ $(wc -w error.log) > 1 ]]
then
for i in `seq 1 ${sumspace}`;
do
echo -n " "
done
echo -e "${RED} --FAILED--${WHT}"
((nRunErr++))
if [[ -f error.log ]]
then
echo " error.log has the details (head follows)"
head error.log | sed -e 's/^/ /'
fi
else
((nParRun++))
rm -f error.log
if [[ ! $NOVIZ ]]
then
# Show the result
for f in *.dat
do
mmsp2png --zoom $f 1>/dev/null 2>>error.log
done
fi
exfin=$(date +%s)
exlapse=$(echo "$exfin-$exstart" | bc -l)
printf "${GRN}%${sumspace}d seconds${WHT}\n" $exlapse
fi
else
exfin=$(date +%s)
exlapse=$(echo "$exfin-$exstart" | bc -l)
printf "${GRN}%${sumspace}d seconds${WHT}\n" $exlapse
fi
# Clean up binaries and images
if [[ $CLEAN ]]
then
make -s clean
rm -f test.*.dat
rm -f error.log
rm -f test.*.png
fi
done
cd ${problems}
tfinish=$(date +%s)
elapsed=$(echo "$tfinish-$tstart" | bc -l)
echo "--------------------------------------------------------------------------"
printf "Elapsed time: %52d seconds\n" $elapsed
echo
printf "%2d serial problems compiled successfully" $nSerBld
if [[ $nSerErr > 0 ]]
then
printf ", %2d failed" $nSerErr
fi
printf "\n%2d parallel problems compiled successfully" $nParBld
if [[ $nParErr > 0 ]]
then
printf ", %2d failed" $nParErr
fi
printf "\n%2d parallel problems executed successfully" $nParRun
if [[ $nRunErr > 0 ]]
then
printf ", %2d failed" $nRunErr
fi
echo
cd ${problems}
AllERR=$(echo "$nSerErr+$nParErr+$nRunErr" | bc -l)
if [[ $AllERR > 0 ]]
then
echo
echo "Build error(s) detected: ${AllERR} tests failed."
exit 1
fi