-
Notifications
You must be signed in to change notification settings - Fork 1
/
runBenchmarksLoop.sh
executable file
·512 lines (488 loc) · 16.4 KB
/
runBenchmarksLoop.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
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
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
#!/bin/bash
## File to build and run all benchmark containers
# Help Menu
help_menu() {
echo "Help Menu: "
echo "Use the following options with runBenchmarksLoop script:"
echo "-e to remove all images/instances and exit"
echo "-r to rebuild all container images for benchmakrs mentioned after"
echo "-t to define runtime"
echo "-l to run linpack benchmark"
echo "-n to run noploop benchmark"
echo "-u to run unixbench benchmark"
echo "-y to run y-cruncher benchmark"
echo "-b to run bonnie++ benchmark"
# echo "-c to run cachebench benchmark"
echo "-s to run sysbench benchmark"
echo "After choosing benchamark to run, please provide repetitions as 'x y z'"
echo "Here, x is number of parallel runs, y is number of containers in serial, and z is number of runs in each container"
echo "The exception is sysbench where an extra argument is required as 'x y z isCpu'. isCPU is a boolean value such that 'true' will run CPU tests"
echo "and false will run memory tests"
exit
}
clean() {
# Stopping docker containers
running_docker_containers=$(sudo docker ps -a | grep -E '.*(capstone+)+.*' | awk '{print $1}')
if [ -n "$running_docker_containers" ]; then
# echo "---------- Stopping Docker containers ----------"
for container_id in $running_docker_containers; do
sudo docker stop $container_id >/dev/null
sudo docker rm $container_id >/dev/null
done
fi
#echo "---------- Displaying all running Docker instances after cleanup ----------"
#echo sudo docker ps -a
}
run_linpack() {
# Linpack Benchmark
arr=$1
numContainerInstances=${arr[1]}
runtime=${arr[4]}
logFile=${arr[6]}
logEntry=$2
logEntry+=",$(date +%s)"
x=1
while [ $x -le $numContainerInstances ]; do
# echo "Running serial container: $x"
# At this point the container image should exist so we sim+ply run the benchmark
sudo docker run --runtime=$runtime -v ./finalResults:/finalResults -e LINPACK_ARRAY_SIZE=600 --memory="4000m" --cpus="2" capstone_linpack "${arr[@]}"
x=$(($x + 1))
done
logEntry+=",$(date +%s)"
echo $logEntry >>$logFile
}
run_linpack_parallel() {
echo "Running Linpack benchmark"
x=1
arr=$1
numParallelRuns=${arr[0]}
rebuild=${arr[3]}
runtime=${arr[4]}
# Check if Linpack container image exists or if rebuild is requested
linpack_docker_images=$(sudo docker images | grep -E '.*(capstone_linpack)+.*' | awk '{print $1}')
if [ ! -n "$linpack_docker_images" ] || [ "$rebuild" = "true" ]; then
echo "Building Linpack container"
sh ./buildContainers.sh --linpack
fi
currTimeStamp=$(date +%s)
subFolderName="finalResults/Linpack_${currTimeStamp}_${runtime}_${numParallelRuns}_${arr[1]}_${arr[2]}"
mkdir $subFolderName
logFile="${subFolderName}/Linpack_RunLog.txt"
arr+=($subFolderName $logFile)
touch $logFile
echo "ParallelBranch,StartTime,EndTime" >$logFile
while [ $x -le $numParallelRuns ]; do
echo "Running in parallel branch: $x"
run_linpack $arr $x &
PID="$!"
PID_LIST+="$PID "
x=$(($x + 1))
done
wait
cp "linpack/mergeMergedCSV.py" "${subFolderName}/mergeMergedCSV.py"
cd $subFolderName
python3 mergeMergedCSV.py
cd ../..
}
run_noploop() {
# Noploop Benchmark
arr=$1
numContainerInstances=${arr[1]}
runtime=${arr[4]}
logFile=${arr[6]}
logEntry=$2
logEntry+=",$(date +%s)"
x=1
while [ $x -le $numContainerInstances ]; do
# echo "Running serial container: $x"
# At this point the container image should exist so we simply run the benchmark
sudo docker run --runtime=$runtime -v ./finalResults:/finalResults --memory="4000m" --cpus="2" capstone_noploop "${arr[@]}"
x=$(($x + 1))
done
logEntry+=",$(date +%s)"
echo $logEntry >>$logFile
}
run_noploop_parallel() {
echo "Running Noploop benchmark"
x=1
arr=$1
numParallelRuns=${arr[0]}
rebuild=${arr[3]}
runtime=${arr[4]}
# Check if Noploop container image exists or if rebuild is requested
noploop_docker_images=$(sudo docker images | grep -E '.*(capstone_noploop)+.*' | awk '{print $1}')
if [ ! -n "$noploop_docker_images" ] || [ "$rebuild" = "true" ]; then
echo "Building Noploop container"
sh ./buildContainers.sh --noploop
fi
currTimeStamp=$(date +%s)
subFolderName="finalResults/Noploop_${currTimeStamp}_${runtime}_${numParallelRuns}_${arr[1]}_${arr[2]}"
mkdir $subFolderName
logFile="${subFolderName}/Noploop_RunLog.txt"
arr+=($subFolderName $logFile)
touch $logFile
echo "ParallelBranch,StartTime,EndTime" >$logFile
while [ $x -le $numParallelRuns ]; do
echo "Running in parallel branch: $x"
run_noploop $arr $x &
PID="$!"
PID_LIST+="$PID "
x=$(($x + 1))
done
wait
cp "noploop/mergeMergedCSV.py" "${subFolderName}/mergeMergedCSV.py"
cd $subFolderName
python3 mergeMergedCSV.py
cd ../..
}
run_unixbench() {
# Unixbench Benchmark
arr=$1
numContainerInstances=${arr[1]}
runtime=${arr[4]}
logFile=${arr[6]}
logEntry=$2
logEntry+=",$(date +%s)"
x=1
while [ $x -le $numContainerInstances ]; do
# echo "Running serial container: $x"
# At this point the container image should exist so we simply run the benchmark
sudo docker run --runtime=$runtime -v ./finalResults:/finalResults --memory="4000m" --cpus="2" capstone_unixbench "${arr[@]}"
x=$(($x + 1))
done
logEntry+=",$(date +%s)"
echo $logEntry >>$logFile
}
run_unixbench_parallel() {
echo "Running Unixbench benchmark"
x=1
arr=$1
numParallelRuns=${arr[0]}
rebuild=${arr[3]}
runtime=${arr[4]}
# Check if Unixbench container image exists or if rebuild is requested
unixbench_docker_images=$(sudo docker images | grep -E '.*(capstone_unixbench)+.*' | awk '{print $1}')
if [ ! -n "$unixbench_docker_images" ] || [ "$rebuild" = "true" ]; then
echo "Building Unixbench container"
sh ./buildContainers.sh --unixbench
fi
currTimeStamp=$(date +%s)
subFolderName="finalResults/Unixbench_${currTimeStamp}_${runtime}_${numParallelRuns}_${arr[1]}_${arr[2]}"
mkdir $subFolderName
logFile="${subFolderName}/Unixbench_RunLog.txt"
arr+=($subFolderName $logFile)
touch $logFile
echo "ParallelBranch,StartTime,EndTime" >$logFile
while [ $x -le $numParallelRuns ]; do
echo "Running in parallel branch: $x"
run_unixbench $arr $x &
PID="$!"
PID_LIST+="$PID "
x=$(($x + 1))
done
wait
# cp "unixbench/mergeMergedCSV.py" "${subFolderName}/mergeMergedCSV.py"
# cd $subFolderName
# python3 mergeMergedCSV.py
# cd ../..
}
run_sysbench() {
# Sysbench Benchmark
#TODO: Currently does not support running the benchmark n times in each container. This is because the container image is pulled from the internet
arr=$1
numContainerInstances=${arr[1]}
runtime=${arr[5]}
logFile=${arr[7]}
logEntry=$2
logEntry+=",$(date +%s)"
x=1
while [ $x -le $numContainerInstances ]; do
# echo "Running serial container: $x"
# At this point the container image should exist so we simply run the benchmark
sudo docker run --runtime=$runtime -v ./finalResults:/finalResults --memory="4000m" --cpus="2" capstone_sysbench "${arr[@]}"
x=$(($x + 1))
done
logEntry+=",$(date +%s)"
echo $logEntry >>$logFile
}
run_sysbench_parallel() {
echo "Running Sysbench benchmark"
x=1
arr=$1
numParallelRuns=${arr[0]}
rebuild=${arr[4]}
runtime=${arr[5]}
# Check if Sysbench container image exists or if rebuild is requested
sysbench_docker_images=$(sudo docker images | grep -E '.*(capstone_sysbench)+.*' | awk '{print $1}')
if [ ! -n "$sysbench_docker_images" ] || [ "$rebuild" = "true" ]; then
echo "Building Sysbench container"
sh ./buildContainers.sh --sysbench
fi
currTimeStamp=$(date +%s)
subFolderName="finalResults/Sysbench_${currTimeStamp}_${runtime}_${numParallelRuns}_${arr[1]}_${arr[2]}"
mkdir $subFolderName
logFile="${subFolderName}/Sysbench_RunLog.txt"
arr+=($subFolderName $logFile)
touch $logFile
echo "ParallelBranch,StartTime,EndTime" >$logFile
while [ $x -le $numParallelRuns ]; do
echo "Running in parallel branch: $x"
run_sysbench $arr $x &
PID="$!"
PID_LIST+="$PID "
x=$(($x + 1))
done
wait
cp "sysbench/mergeMergedCSV.py" "${subFolderName}/mergeMergedCSV.py"
cd $subFolderName
python3 mergeMergedCSV.py
cd ../..
}
run_ycruncher() {
# Y-Cruncher Benchmark
arr=$1
numContainerInstances=${arr[1]}
runtime=${arr[4]}
logFile=${arr[6]}
logEntry=$2
logEntry+=",$(date +%s)"
x=1
while [ $x -le $numContainerInstances ]; do
# echo "Running serial container: $x"
# At this point the container image should exist so we simply run the benchmark
sudo docker run --runtime=$runtime -v ./finalResults:/finalResults --memory="4000m" --cpus="2" capstone_ycruncher "${arr[@]}"
x=$(($x + 1))
done
logEntry+=",$(date +%s)"
echo $logEntry >>$logFile
}
run_ycruncher_parallel() {
echo "Running Y-Cruncher benchmark"
x=1
arr=$1
numParallelRuns=${arr[0]}
rebuild=${arr[3]}
runtime=${arr[4]}
# Check if Y-Cruncher container image exists or if rebuild is requested
ycruncher_docker_images=$(sudo docker images | grep -E '.*(capstone_ycruncher)+.*' | awk '{print $1}')
if [ ! -n "$ycruncher_docker_images" ] || [ "$rebuild" = "true" ]; then
echo "Building Y-Cruncher container"
sh ./buildContainers.sh --ycruncher
fi
currTimeStamp=$(date +%s)
subFolderName="finalResults/YCruncher_${currTimeStamp}_${runtime}_${numParallelRuns}_${arr[1]}_${arr[2]}"
mkdir $subFolderName
logFile="${subFolderName}/Ycruncher_RunLog.txt"
arr+=($subFolderName $logFile)
touch $logFile
echo "ParallelBranch,StartTime,EndTime" >$logFile
while [ $x -le $numParallelRuns ]; do
echo "Running in parallel branch: $x"
run_ycruncher $arr $xs &
PID="$!"
PID_LIST+="$PID "
x=$(($x + 1))
done
wait
cp "ycruncher/mergeMergedCSV.py" "${subFolderName}/mergeMergedCSV.py"
cd $subFolderName
python3 mergeMergedCSV.py
cd ../..
}
run_bonnie() {
# Bonnie++ Benchmark
arr=$1
numContainerInstances=${arr[1]}
runtime=${arr[4]}
logFile=${arr[6]}
logEntry=$2
logEntry+=",$(date +%s)"
x=1
while [ $x -le $numContainerInstances ]; do
# echo "Running serial container: $x"
# At this point the container image should exist so we simply run the benchmark
sudo docker run --runtime=$runtime -v ./finalResults:/finalResults --memory="4000m" --cpus="2" capstone_bonnie "${arr[@]}"
x=$(($x + 1))
done
logEntry+=",$(date +%s)"
echo $logEntry >>$logFile
}
run_bonnie_parallel() {
echo "Running Bonnie++ benchmark"
x=1
arr=$1
numParallelRuns=${arr[0]}
rebuild=${arr[3]}
runtime=${arr[4]}
# Check if Bonnie++ container image exists or if rebuild is requested
bonnie_docker_images=$(sudo docker images | grep -E '.*(capstone_bonnie)+.*' | awk '{print $1}')
if [ ! -n "$bonnie_docker_images" ] || [ "$rebuild" = "true" ]; then
echo "Building Bonnie++ container"
sh ./buildContainers.sh --bonnie
fi
currTimeStamp=$(date +%s)
subFolderName="finalResults/Bonnie_${currTimeStamp}_${runtime}_${numParallelRuns}_${arr[1]}_${arr[2]}"
mkdir $subFolderName
logFile="${subFolderName}/Bonnie_RunLog.txt"
arr+=($subFolderName $logFile)
touch $logFile
echo "ParallelBranch,StartTime,EndTime" >$logFile
while [ $x -le $numParallelRuns ]; do
echo "Running in parallel branch: $x"
run_bonnie $arr $x &
PID="$!"
PID_LIST+="$PID "
x=$(($x + 1))
done
wait
# cp "bonnie/mergeMergedCSV.py" "${subFolderName}/mergeMergedCSV.py"
# cd $subFolderName
# python3 mergeMergedCSV.py
# cd ../..
}
run_stream() {
# Stream Benchmark
arr=$1
numContainerInstances=${arr[1]}
runtime=${arr[4]}
logFile=${arr[6]}
logEntry=$2
logEntry+=",$(date +%s)"
x=1
while [ $x -le $numContainerInstances ]; do
# echo "Running serial container: $x"
# At this point the container image should exist so we sim+ply run the benchmark
sudo docker run --runtime=$runtime -v ./finalResults:/finalResults --memory="4000m" --cpus="2" capstone_stream "${arr[@]}"
x=$(($x + 1))
done
logEntry+=",$(date +%s)"
echo $logEntry >>$logFile
}
run_stream_parallel() {
echo "Running Stream benchmark"
x=1
arr=$1
numParallelRuns=${arr[0]}
rebuild=${arr[3]}
runtime=${arr[4]}
# Check if Linpack container image exists or if rebuild is requested
stream_docker_images=$(sudo docker images | grep -E '.*(capstone_stream)+.*' | awk '{print $1}')
if [ ! -n "$stream_docker_images" ] || [ "$rebuild" = "true" ]; then
echo "Building Stream container"
sh ./buildContainers.sh --stream
fi
currTimeStamp=$(date +%s)
subFolderName="finalResults/Stream_${currTimeStamp}_${runtime}_${numParallelRuns}_${arr[1]}_${arr[2]}"
mkdir $subFolderName
logFile="${subFolderName}/Stream_RunLog.txt"
arr+=($subFolderName $logFile)
touch $logFile
echo "ParallelBranch,StartTime,EndTime" >$logFile
while [ $x -le $numParallelRuns ]; do
echo "Running in parallel branch: $x"
run_stream $arr $x &
PID="$!"
PID_LIST+="$PID "
x=$(($x + 1))
done
wait
cp "stream/mergeMergedCSV.py" "${subFolderName}/mergeMergedCSV.py"
cd $subFolderName
python3 mergeMergedCSV.py
cd ../..
}
run_cachebench() {
# Cachebench Benchmark
echo "Running Cachebench benchmark"
# Check if Cachebench container image exists or if rebuild is requested
cachebench_docker_images=$(sudo docker images | grep -E '.*(capstone_cachebench)+.*' | awk '{print $1}')
if [ ! -n "$cachebench_docker_images" ] || [ "$1" = "true" ]; then
sh ./buildContainers.sh --cachebench
fi
# At this point the container image should exist so we simply run the benchmark
sudo docker run --rm capstone_cachebench
# Extract report files from container
running_llcbench_container=$(sudo docker ps -a | grep -E '.*(capstone_cachebench+)+.*' | awk '{print $1}')
for container_id in $running_llcbench_container; do
sudo docker cp "$container_id:/llcbench/llcbench/results ./llcbench/resultsFromDocker/"
done
}
if [ "$#" = "0" ]; then
help_menu
exit
fi
clean
rebuild="false"
runtime="runc"
while getopts ":ert:l:n:s:c:u:y:b:a:" option; do
case $option in
e)
echo "Cleaning container images and instances"
sh ./buildContainers.sh --clean
exit
;;
r)
rebuild="true"
echo "Forced rebuild enabled"
;;
t)
runtime="$OPTARG"
echo "Runtime changed to: $runtime"
;;
l)
numRuns="$OPTARG"
arr=($numRuns $rebuild $runtime)
run_linpack_parallel "$arr"
;;
n)
numRuns="$OPTARG"
arr=($numRuns $rebuild $runtime)
run_noploop_parallel "$arr"
;;
u)
numRuns="$OPTARG"
arr=($numRuns $rebuild $runtime)
run_unixbench_parallel "$arr"
;;
s)
numRuns="$OPTARG" # Here numruns should also have an extra param choosing between cpu and memory test
arr=($numRuns $rebuild $runtime)
run_sysbench_parallel "$arr"
;;
y)
numRuns="$OPTARG"
arr=($numRuns $rebuild $runtime)
run_ycruncher_parallel "$arr"
;;
b)
numRuns="$OPTARG"
arr=($numRuns $rebuild $runtime)
run_bonnie_parallel "$arr"
;;
a)
numRuns="$OPTARG"
arr=($numRuns $rebuild $runtime)
run_stream_parallel "$arr"
;;
c)
numRuns="$OPTARG"
x=1
while [ $x -le numRuns ]; do
echo "Running iteration: $x"
run_cachebench "$rebuild"
if [ "$x" = "1" ]; then
rebuild="false"
exit
fi
x=$(($x + 1))
done
;;
*)
echo "Unsupported option passed: $option"
help_menu
;;
esac
done
clean
echo "---------- Displaying active Docker containers ----------"
sudo docker ps -a