-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmarks.sh
executable file
·827 lines (723 loc) · 32 KB
/
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
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
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $(basename $0) [intel|amd] [basic|advanced|amd-v-intel|blocked-v-triangular|reference|gcc-v-clang|mpts|data_variance|cache_analysis|manhattan|all]"
exit 1
fi
if [ ! -z $1 ] && [ $1 != "amd" ] && [ $1 != "intel" ]; then
echo "Invalid argument: $1" >&2
echo ""
echo "Usage: $(basename $0) [intel|amd] [basic|advanced|amd-v-intel|blocked-v-triangular|reference|gcc-v-clang|mpts|data_variance|cache_analysis|manhattan|all]"
exit 1
fi
# extend here with different test names
if [ ! -z $2 ] && [ $2 != "basic" ] && [ $2 != "advanced" ] && \
[ $2 != "amd-v-intel" ] && [ $2 != "blocked-v-triangular" ] && \
[ $2 != "reference" ] && [ $2 != "gcc-v-clang" ] && [ $2 != "mpts" ] && \
[ $2 != "dimensions" ] && [ $2 != "data_variance" ] && [ $2 != "cache_analysis" ] && \
[ $2 != "manhattan" ] && [ $2 != "all" ]; then
echo "Invalid argument: $2" >&2
echo ""
echo "Usage: $(basename $0) [intel|amd] [basic|advanced|amd-v-intel|blocked-v-triangular|reference|gcc-v-clang|mpts|data_variance|cache_analysis|manhattan|all]"
exit 1
fi
AMD=0
if [ $1 = "amd" ]; then
AMD=1
fi
TIME=$(date +%Y%m%d_%H%M%S)
# C_COMPILER=/usr/bin/clang
# CXX_COMPILER=/usr/bin/clang++
C_COMPILER=clang-11
CXX_COMPILER=clang++-11
# data creation here first
rm -rf build
# create build dir
mkdir -p build
mkdir -p plots/${TIME}
##########################################################
######## Total Comparison of all optimizations ########
##########################################################
# Total Comparison flops/cycles
# TEST
# N=3
# NFIX=3
# D=32
# BENCHMARKING
N=12
NFIX=7
D=64
# Basic everything
if [ $2 = "basic" ] || [ $2 = "advanced" ] || [ $2 = "reference" ] || [ $2 = "mpts" ] || [ $2 = "amd-v-intel" ] || [ $2 = "all" ]; then
python helper_scripts/generate_clusters.py data 6 ${D}
fi
##########################################################
######## Reference ##########
##########################################################
if [ $2 = "reference" ] || [ $2 = "all" ]; then
cd references/hdbscan-cpp && make clean
if [ $1 = "amd" ]; then
make CXX=${CXX_COMPILER} CPPFLAGS="-DBENCHMARK_AMD -march=native"
else
make CXX=${CXX_COMPILER} CPPFLAGS="-march=native"
fi
cd ../..
# a bit hacky, but our script assumes binary is in build
./run_perf_measurements.sh reference_hdbscan ./references/hdbscan-cpp/main perf_data_d${D} ${N} ${TIME}
fi
################################################################################
### Plot with mpts on the x axis
################################################################################
if [ $2 = "mpts" ] || [ $2 = "all" ]; then
cd build && cmake -G Ninja .. \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_FLAGS="-O3 -march=native" \
-DPACKLEFT_WLOOKUP=1 \
-DBENCHMARK_AMD=${AMD} \
-DHDBSCAN_TEST=0 \
-DHDBSCAN_QUICKSELECT=0 &&
ninja build_bench &&
ninja build_bench_vec &&
cd ..
./run_perf_measurements.sh quickselect_baseline ./build/bin/hdbscan_benchmark perf_data_d${D} ${NFIX} ${TIME} 5
./run_perf_measurements.sh bubbleselect ./build/bin/hdbscan_benchmark_distvec_quickvec perf_data_d${D} ${NFIX} ${TIME} 5
for i in $(seq 10 10 100); do
./run_perf_measurements.sh quickselect_baseline ./build/bin/hdbscan_benchmark perf_data_d${D} ${NFIX} ${TIME} ${i}
./run_perf_measurements.sh bubbleselect ./build/bin/hdbscan_benchmark_distvec_quickvec perf_data_d${D} ${NFIX} ${TIME} ${i}
done
cd build && cmake -G Ninja .. \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_FLAGS="-O3 -march=native" \
-DPACKLEFT_WLOOKUP=1 \
-DBENCHMARK_AMD=${AMD} \
-DHDBSCAN_TEST=0 \
-DHDBSCAN_QUICKSELECT=1 &&
ninja build_bench_vec &&
cd ..
./run_perf_measurements.sh quickselect_vectorized ./build/bin/hdbscan_benchmark_distvec_quickvec perf_data_d${D} ${NFIX} ${TIME} 5
for i in $(seq 10 10 100); do
./run_perf_measurements.sh quickselect_vectorized ./build/bin/hdbscan_benchmark_distvec_quickvec perf_data_d${D} ${NFIX} ${TIME} ${i}
done
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files quickselect_baseline.csv \
bubbleselect.csv \
quickselect_vectorized.csv \
--save-path plots/${TIME}/cycles_mpts.pdf \
--metric=cycles \
--x-scale=linear
fi
if [ $2 != "mpts" ]; then
cd build && cmake -G Ninja .. \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_FLAGS="-O3 -march=native" \
-DPACKLEFT_WLOOKUP=1 \
-DHDBSCAN_QUICKSELECT=0 \
-DHDBSCAN_TEST=0 \
-DBENCHMARK_AMD=${AMD} &&
ninja build_bench &&
ninja build_bench_vec &&
cd ..
fi
##########################################################
######## Algorithm with basic prim algorithm ##########
##########################################################
if [ $2 = "basic" ] || [ $2 = "all" ]; then
# No optimizations
./run_perf_measurements.sh basic ./build/bin/hdbscan_basic_benchmark perf_data_d${D} ${N} ${TIME}
# Adding optimized distance computations (computation of adjacency matrix)
./run_perf_measurements.sh basic_distvec ./build/bin/hdbscan_basic_benchmark_distvec perf_data_d${D} ${N} ${TIME}
# Adding optimized quickselect algorithm
./run_perf_measurements.sh basic_distvec_quickvec ./build/bin/hdbscan_basic_benchmark_distvec_quickvec perf_data_d${D} ${N} ${TIME}
# Adding optimized prim algorithm
./run_perf_measurements.sh basic_distvec_quickvec_primvec ./build/bin/hdbscan_basic_benchmark_distvec_quickvec_primvec perf_data_d${D} ${N} ${TIME}
# Plot result
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files basic.csv \
basic_distvec.csv \
basic_distvec_quickvec_primvec.csv \
--save-path plots/${TIME}/performance_basic.pdf
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files basic.csv \
basic_distvec.csv \
basic_distvec_quickvec_primvec.csv \
--save-path plots/${TIME}/performance_basic_linear.pdf \
--x-scale=linear
fi
##########################################################
######## Algorithm with advanced prim algorithm ##########
##########################################################
if [ $2 = "advanced" ] || [ $2 = "all" ]; then
# No optimizations
./run_perf_measurements.sh advprim ./build/bin/hdbscan_benchmark perf_data_d${D} ${N} ${TIME}
# Adding optimized distance computation (computation of core_distances)
./run_perf_measurements.sh advprim_distvec ./build/bin/hdbscan_benchmark_distvec perf_data_d${D} ${N} ${TIME}
# Adding optimized quickselect algorithm
./run_perf_measurements.sh advprim_distvec_quickvec ./build/bin/hdbscan_benchmark_distvec_quickvec perf_data_d${D} ${N} ${TIME}
# Adding optimized prim algorithm
./run_perf_measurements.sh advprim_distvec_quickvec_primvec ./build/bin/hdbscan_benchmark_distvec_quickvec_primvec perf_data_d${D} ${N} ${TIME}
# Plot result
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files advprim.csv \
advprim_distvec.csv \
advprim_distvec_quickvec_primvec.csv \
--save-path plots/${TIME}/performance_advprim.pdf
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files advprim.csv \
advprim_distvec.csv \
advprim_distvec_quickvec_primvec.csv \
--save-path plots/${TIME}/performance_advprim_linear.pdf \
--x-scale=linear
fi
##########################################################
######## Plots showing cycles of each binary \ ##########
######## for basic & advanced prim ##########
##########################################################
if [ $2 = "basic" ] || [ $2 = "all" ]; then
# Plot basic
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files basic.csv \
basic_distvec.csv \
basic_distvec_quickvec_primvec.csv \
--save-path plots/${TIME}/cycles_basic.pdf \
--metric=cycles \
--x-scale=linear
fi
if [ $2 = "advanced" ] || [ $2 = "all" ]; then
# Plot advprim
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files advprim.csv \
advprim_distvec.csv \
advprim_distvec_quickvec_primvec.csv \
--save-path plots/${TIME}/cycles_advprim.pdf \
--metric=cycles \
--x-scale=linear
fi
if [ $2 = "all" ]; then
# Plot basic vs advprim
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files basic.csv \
basic_distvec_quickvec_primvec.csv \
advprim.csv \
advprim_distvec.csv \
--save-path plots/${TIME}/performance_basic_vs_advanced.pdf \
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files basic.csv \
basic_distvec_quickvec_primvec.csv \
advprim.csv \
advprim_distvec.csv \
--save-path plots/${TIME}/performance_basic_vs_advanced_linear.pdf \
--x-scale=linear
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files basic.csv \
basic_distvec_quickvec_primvec.csv \
advprim.csv \
advprim_distvec.csv \
--save-path plots/${TIME}/cycles_basic_vs_advanced.pdf \
--metric=cycles \
--x-scale=linear
# Plot reference vs ours
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files reference_hdbscan.csv \
basic.csv basic_distvec_quickvec_primvec.csv \
basic_distvec.csv \
advprim.csv \
advprim_distvec.csv \
--save-path plots/${TIME}/cycles_ref_vs_ours.pdf --x-scale=linear --metric=cycles
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files reference_hdbscan.csv \
basic.csv basic_distvec_quickvec_primvec.csv \
basic_distvec.csv \
advprim.csv \
advprim_distvec.csv \
--save-path plots/${TIME}/performance_ref_vs_ours.pdf --x-scale=linear
fi
##########################################################
######## Comparison between Intel and AMD ########
######## with focus on the vectorization ########
######## of the partition function ########
##########################################################
if [ $2 = "amd-v-intel" ] || [ $2 = "all" ]; then
printf "Running amd-v-intel benchmarks. Creating data...\n"
# First with the version where `pext` and `pdep` are used
cd build && cmake -G Ninja .. \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_FLAGS="-O3 -march=native" \
-DPACKLEFT_WLOOKUP=0 \
-DHDBSCAN_QUICKSELECT=1 \
-DHDBSCAN_TEST=0 \
-DBENCHMARK_AMD=${AMD} &&
ninja build_bench &&
ninja build_bench_vec &&
cd ..
printf "Running amd-v-intel benchmarks. Run benchmark with pext/pdep partitioning...\n"
# Best performing
./run_perf_measurements.sh $1_pext_partition ./build/bin/hdbscan_benchmark_distvec_quickvec perf_data_d4 ${N} ${TIME}
# Then the optimized version for AMD, using a lookup table
cd build && cmake -G Ninja .. \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_FLAGS="-O3 -march=native" \
-DPACKLEFT_WLOOKUP=1 \
-DHDBSCAN_QUICKSELECT=1 \
-DHDBSCAN_TEST=0 \
-DBENCHMARK_AMD=${AMD} &&
ninja build_bench &&
ninja build_bench_vec &&
cd ..
printf "Running amd-v-intel benchmarks. Run benchmark with LUT partitioning...\n"
# Best performing
./run_perf_measurements.sh $1_lut_partition ./build/bin/hdbscan_benchmark_distvec_quickvec perf_data_d4 ${N} ${TIME}
printf "Running amd-v-intel benchmarks. Run benchmark without vectorization...\n"
./run_perf_measurements.sh $1_no_vec ./build/bin/hdbscan_benchmark perf_data_d4 ${N} ${TIME}
# Plot like this here (should be done with second machine, i.e.
# benchmarks have been copied)
: ' python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files amd_pext_partition.csv \
amd_lut_partition.csv \
intel_pext_partition.csv \
intel_lut_partition.csv \
--save-path plots/perf_amd_vs_intel.pdf \
--metric=cycles
--x-scale=linear
'
fi
if [ $2 = "basic" ] || [ $2 = "advanced" ] || [ $2 == "reference" ] || [ $2 = "mpts" ] || [ $2 = "amd-v-intel" ] || [ $2 = "all" ]; then
# Clean up datasets used for this part
rm ./data/perf_data_d${D}_*
fi
#######################################################################################
######## Comparison between basic, triangular and blocked distance computation ########
#######################################################################################
# Total Comparison flops/cycles d=128
if [ $2 = "blocked-v-triangular" ] || [ $2 = "all" ]; then
printf "Running blocked-v-triangular benchmarks. Creating data...\n"
python helper_scripts/generate_clusters.py data 6 20
cd build && cmake -G Ninja .. \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_FLAGS="-O3 -march=native -DHDBSCAN_BLOCK_SIZE=20" \
-DPACKLEFT_WLOOKUP=0 \
-DHDBSCAN_PRECOMPUTE_DIST_TRIANG=0 \
-DHDBSCAN_PRECOMPUTE_DIST_BLOCKED=0 \
-DHDBSCAN_VERBOSE=0 \
-DHDBSCAN_QUICKSELECT=0 \
-DHDBSCAN_TEST=0 \
-DBENCHMARK_AMD=${AMD} &&
ninja build_bench &&
cd ..
printf "Running blocked-v-triangular benchmarks. Run benchmark basic version...\n"
# Basic
./run_perf_measurements.sh distance_matrix_basic ./build/bin/hdbscan_basic_benchmark perf_data_d20 ${N} ${TIME}
./run_perf_measurements.sh distance_matrix_triangular ./build/bin/hdbscan_basic_benchmark_triang perf_data_d20 ${N} ${TIME}
./run_perf_measurements.sh distance_matrix_blocked_20 ./build/bin/hdbscan_basic_benchmark_blocked perf_data_d20 ${N} ${TIME}
cd build && cmake -G Ninja .. \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_FLAGS="-O3 -march=native -DHDBSCAN_BLOCK_SIZE=40" \
-DPACKLEFT_WLOOKUP=0 \
-DHDBSCAN_PRECOMPUTE_DIST_TRIANG=0 \
-DHDBSCAN_PRECOMPUTE_DIST_BLOCKED=0 \
-DHDBSCAN_VERBOSE=0 \
-DHDBSCAN_TEST=0 \
-DBENCHMARK_AMD=${AMD} &&
ninja build_bench &&
cd ..
./run_perf_measurements.sh distance_matrix_blocked_40 ./build/bin/hdbscan_basic_benchmark_blocked perf_data_d20 ${N} ${TIME}
cd build && cmake -G Ninja .. \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_FLAGS="-O3 -march=native -DHDBSCAN_BLOCK_SIZE=80" \
-DPACKLEFT_WLOOKUP=0 \
-DHDBSCAN_PRECOMPUTE_DIST_TRIANG=0 \
-DHDBSCAN_PRECOMPUTE_DIST_BLOCKED=0 \
-DHDBSCAN_VERBOSE=0 \
-DHDBSCAN_TEST=0 \
-DBENCHMARK_AMD=${AMD} &&
ninja build_bench &&
cd ..
./run_perf_measurements.sh distance_matrix_blocked_80 ./build/bin/hdbscan_basic_benchmark_blocked perf_data_d20 ${N} ${TIME}
cd build && cmake -G Ninja .. \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_FLAGS="-O3 -march=native -DHDBSCAN_BLOCK_SIZE=100" \
-DPACKLEFT_WLOOKUP=0 \
-DHDBSCAN_PRECOMPUTE_DIST_TRIANG=0 \
-DHDBSCAN_PRECOMPUTE_DIST_BLOCKED=0 \
-DHDBSCAN_VERBOSE=0 \
-DHDBSCAN_TEST=0 \
-DBENCHMARK_AMD=${AMD} &&
ninja build_bench &&
cd ..
./run_perf_measurements.sh distance_matrix_blocked_100 ./build/bin/hdbscan_basic_benchmark_blocked perf_data_d20 ${N} ${TIME}
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files distance_matrix_basic.csv \
distance_matrix_triangular.csv \
distance_matrix_blocked_20.csv \
distance_matrix_blocked_40.csv \
distance_matrix_blocked_80.csv \
distance_matrix_blocked_100.csv \
--save-path=plots/triangular_v_blocked.pdf \
--metric=cycles \
--x-scale=linear
# Remove data used for this experiment
rm -f ./data/perf_data_d20_*
fi
########################################################################
######## Comparison of gcc vs. clang on most optimized versions ########
########################################################################
if [ $2 = "gcc-v-clang" ] || [ $2 = "all" ]; then
# Generate data
python helper_scripts/generate_clusters.py data 6 ${D}
# clang-11
cd build && cmake -G Ninja .. \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_FLAGS="-O3 -march=native -ffast-math" \
-DPACKLEFT_WLOOKUP=1 \
-DHDBSCAN_QUICKSELECT=0 \
-DHDBSCAN_TEST=0 \
-DBENCHMARK_AMD=${AMD} &&
ninja build_bench &&
ninja build_bench_vec &&
cd ..
./run_perf_measurements.sh clang_basic_autovec ./build/bin/hdbscan_basic_benchmark perf_data_d${D} ${N} ${TIME}
./run_perf_measurements.sh clang_advprim_autovec ./build/bin/hdbscan_benchmark perf_data_d${D} ${N} ${TIME}
cd build && cmake -G Ninja .. \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_FLAGS="-O3 -march=native" \
-DPACKLEFT_WLOOKUP=1 \
-DHDBSCAN_QUICKSELECT=0 \
-DHDBSCAN_TEST=0 \
-DBENCHMARK_AMD=${AMD} &&
ninja build_bench &&
ninja build_bench_vec &&
cd ..
./run_perf_measurements.sh clang_basic_best ./build/bin/hdbscan_basic_benchmark_distvec_quickvec_primvec perf_data_d${D} ${N} ${TIME}
./run_perf_measurements.sh clang_advprim_best ./build/bin/hdbscan_benchmark_distvec_quickvec perf_data_d${D} ${N} ${TIME}
# gcc
# Needed, otherwise problems with compiling with new compiler
rm -rf build
mkdir -p build
cd build && cmake -G Ninja .. \
-DCMAKE_C_COMPILER=gcc-11 \
-DCMAKE_CXX_COMPILER=g++-11 \
-DCMAKE_CXX_FLAGS="-O3 -march=native -ffast-math" \
-DPACKLEFT_WLOOKUP=1 \
-DHDBSCAN_QUICKSELECT=0 \
-DHDBSCAN_TEST=0 \
-DBENCHMARK_AMD=${AMD} &&
ninja build_bench &&
ninja build_bench_vec &&
cd ..
./run_perf_measurements.sh gcc_basic_autovec ./build/bin/hdbscan_basic_benchmark perf_data_d${D} ${N} ${TIME}
./run_perf_measurements.sh gcc_advprim_autovec ./build/bin/hdbscan_benchmark perf_data_d${D} ${N} ${TIME}
cd build && cmake -G Ninja .. \
-DCMAKE_C_COMPILER=gcc-11 \
-DCMAKE_CXX_COMPILER=g++-11 \
-DCMAKE_CXX_FLAGS="-O3 -march=native" \
-DPACKLEFT_WLOOKUP=1 \
-DHDBSCAN_QUICKSELECT=0 \
-DHDBSCAN_TEST=0 \
-DBENCHMARK_AMD=${AMD} &&
ninja build_bench &&
ninja build_bench_vec &&
cd ..
./run_perf_measurements.sh gcc_basic_best ./build/bin/hdbscan_basic_benchmark_distvec_quickvec_primvec perf_data_d${D} ${N} ${TIME}
./run_perf_measurements.sh gcc_advprim_best ./build/bin/hdbscan_benchmark_distvec_quickvec perf_data_d${D} ${N} ${TIME}
# Plotting
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files gcc_basic_best.csv \
gcc_advprim_best.csv \
gcc_basic_autovec.csv \
gcc_advprim_autovec.csv \
clang_basic_best.csv \
clang_advprim_best.csv \
clang_basic_autovec.csv \
clang_advprim_autovec.csv \
--save-path plots/${TIME}/gcc_v_clang.pdf
rm -rf build
mkdir -p build
fi
#####################################################
######## Comparison for different dimensions ########
#####################################################
if [ $2 = "dimensions" ] || [ $2 = "all" ]; then
D=8
cd build && cmake -G Ninja .. \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_FLAGS="-O3 -march=native" \
-DPACKLEFT_WLOOKUP=1 \
-DHDBSCAN_QUICKSELECT=0 \
-DHDBSCAN_TEST=0 \
-DSPECIALIZED_DISTANCE=0 \
-DBENCHMARK_AMD=${AMD} &&
ninja build_bench_vec &&
cd ..
for i in $(seq 1 ${D}); do
d=$((2 ** ${i}))
python helper_scripts/generate_clusters.py data 6 ${d}
printf "running for d = ${d}...\n"
./run_perf_measurements.sh advprim_distvec_quickvec_dims ./build/bin/hdbscan_benchmark_distvec_quickvec perf_data_d${d} ${NFIX} ${TIME} 4
done
cd build && cmake -G Ninja .. \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_FLAGS="-O3 -march=native" \
-DPACKLEFT_WLOOKUP=1 \
-DHDBSCAN_QUICKSELECT=0 \
-DHDBSCAN_TEST=0 \
-DSPECIALIZED_DISTANCE=1 \
-DBENCHMARK_AMD=${AMD} &&
ninja build_bench_vec &&
cd ..
for i in $(seq 1 ${D}); do
d=$((2 ** ${i}))
printf "running for d = ${d}...\n"
./run_perf_measurements.sh advprim_distvec_quickvec_dims_spec ./build/bin/hdbscan_benchmark_distvec_quickvec perf_data_d${d} ${NFIX} ${TIME} 4
./run_perf_measurements.sh advprim_distvec_quickvec_dims${d} ./build/bin/hdbscan_benchmark_distvec_quickvec perf_data_d${d} ${N} ${TIME}
rm ./data/perf_data_d${d}_*
done
python helper_scripts/plot_performance_dims.py --system $1 \
--data-path data/timings/${TIME} \
--files advprim_distvec_quickvec_dims2.csv \
advprim_distvec_quickvec_dims4.csv \
advprim_distvec_quickvec_dims8.csv \
advprim_distvec_quickvec_dims16.csv \
advprim_distvec_quickvec_dims32.csv \
advprim_distvec_quickvec_dims64.csv \
advprim_distvec_quickvec_dims128.csv \
advprim_distvec_quickvec_dims256.csv \
--save-path plots/${TIME}/perf_dims_heatmap.pdf
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files advprim_distvec_quickvec_dims.csv \
advprim_distvec_quickvec_dims_spec.csv \
--save-path plots/${TIME}/cycles_dims.pdf \
--metric=cycles
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files advprim_distvec_quickvec_dims.csv \
advprim_distvec_quickvec_dims_spec.csv \
--save-path plots/${TIME}/perf_dims.pdf
fi
if [ $2 = "manhattan" ] || [ $2 = "all" ]; then
D=8
cd build && cmake -G Ninja .. \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_FLAGS="-O3 -march=native" \
-DPACKLEFT_WLOOKUP=1 \
-DHDBSCAN_QUICKSELECT=0 \
-DHDBSCAN_TEST=0 \
-DSPECIALIZED_DISTANCE=0 \
-DHDBSCAN_MANHATTAN=1 \
-DBENCHMARK_AMD=${AMD} &&
ninja build_bench_vec &&
cd ..
for i in $(seq 1 ${D}); do
d=$((2 ** ${i}))
python helper_scripts/generate_clusters.py data 6 ${d}
printf "running for d = ${d}...\n"
./run_perf_measurements.sh advprim_distvec_quickvec_dims_manhattan ./build/bin/hdbscan_benchmark_distvec_quickvec perf_data_d${d} ${NFIX} ${TIME} 4
done
cd build && cmake -G Ninja .. \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_FLAGS="-O3 -march=native" \
-DPACKLEFT_WLOOKUP=1 \
-DHDBSCAN_QUICKSELECT=0 \
-DHDBSCAN_TEST=0 \
-DHDBSCAN_MANHATTAN=1 \
-DSPECIALIZED_DISTANCE=1 \
-DBENCHMARK_AMD=${AMD} &&
ninja build_bench_vec &&
cd ..
for i in $(seq 1 ${D}); do
d=$((2 ** ${i}))
printf "running for d = ${d}...\n"
./run_perf_measurements.sh advprim_distvec_quickvec_dims_manhattan_spec ./build/bin/hdbscan_benchmark_distvec_quickvec perf_data_d${d} ${NFIX} ${TIME} 4
rm ./data/perf_data_d${d}_*
done
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files advprim_distvec_quickvec_dims_manhattan.csv \
advprim_distvec_quickvec_dims_manhattan_spec.csv \
--save-path plots/${TIME}/cycles_dims_manhattan.pdf \
--metric=cycles
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files advprim_distvec_quickvec_dims_manhattan.csv \
advprim_distvec_quickvec_dims_manhattan_spec.csv \
--save-path plots/${TIME}/perf_dims_manhattan.pdf
fi
if [ $2 = "all" ]; then
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files advprim_distvec_quickvec_dims.csv \
advprim_distvec_quickvec_dims_spec.csv \
advprim_distvec_quickvec_dims_manhattan.csv \
advprim_distvec_quickvec_dims_manhattan_spec.csv \
--save-path plots/${TIME}/cycles_dims_euclid_manhattan.pdf \
--metric=cycles
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files advprim_distvec_quickvec_dims.csv \
advprim_distvec_quickvec_dims_spec.csv \
advprim_distvec_quickvec_dims_manhattan.csv \
advprim_distvec_quickvec_dims_manhattan_spec.csv \
--save-path plots/${TIME}/perf_dims_euclid_manhattan.pdf
fi
#####################################################
######## Comparison for different data ########
#####################################################
if [ $2 = "data_variance" ] || [ $2 = "all" ]; then
K=4
cd build && cmake -G Ninja .. \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_FLAGS="-O3 -march=native" \
-DPACKLEFT_WLOOKUP=1 \
-DHDBSCAN_QUICKSELECT=0 \
-DHDBSCAN_TEST=0 \
-DSPECIALIZED_DISTANCE=0 \
-DHDBSCAN_MANHATTAN=0 \
-DBENCHMARK_AMD=${AMD} &&
ninja build_bench_vec &&
cd ..
for i in $(seq 1 ${K}); do
python helper_scripts/generate_clusters.py data ${i} ${D}
printf "running for i = ${i} blobs...\n"
./run_perf_measurements.sh advprim_vec_blobs${i} ./build/bin/hdbscan_benchmark_distvec_quickvec perf_data_d${D} ${N} ${TIME}
./run_perf_measurements.sh basic_best_blobs${i} ./build/bin/hdbscan_basic_benchmark_distvec_quickvec_primvec perf_data_d${D} ${N} ${TIME}
done
rm ./data/perf_data_d${D}*
python helper_scripts/plot_performance_alt.py --system $1 \
--data-path data/timings/${TIME} \
--files advprim_vec_blobs1.csv \
advprim_vec_blobs2.csv \
advprim_vec_blobs3.csv \
advprim_vec_blobs4.csv \
basic_best_blobs1.csv \
basic_best_blobs2.csv \
basic_best_blobs3.csv \
basic_best_blobs4.csv \
--save-path plots/${TIME}/performance_data_variance.pdf \
--x-scale=linear
fi
if [ $2 = "cache_analysis" ] || [ $2 = "all" ]; then
N=10
D=64
rm -rf build
mkdir -p build
cd build && cmake -G Ninja .. \
-DCMAKE_C_COMPILER=${C_COMPILER} \
-DCMAKE_CXX_COMPILER=${CXX_COMPILER} \
-DCMAKE_CXX_FLAGS="-O3 -march=native -DHDBSCAN_BLOCK_SIZE=80" \
-DPACKLEFT_WLOOKUP=1 \
-DHDBSCAN_QUICKSELECT=0 \
-DHDBSCAN_PRECOMPUTE_DIST_TRIANG=0 \
-DHDBSCAN_PRECOMPUTE_DIST_BLOCKED=0 \
-DHDBSCAN_VERBOSE=0 \
-DHDBSCAN_TEST=0 &&
ninja &&
cd ..
#cd build && ninja && cd ..
# build reference binary separately
cd references/hdbscan-cpp && make clean
if [ $1 = "amd" ]; then
make CXX=${CXX_COMPILER} CPPFLAGS="-DBENCHMARK_AMD -march=native"
else
make CXX=${CXX_COMPILER} CPPFLAGS="-march=native"
fi
cd ../..
declare -a basic_arr=("hdbscan_basic"
"hdbscan_basic_distvec"
"hdbscan_basic_distvec_quickvec_primvec"
)
declare -a advprim_arr=("hdbscan"
"hdbscan_distvec"
"hdbscan_distvec_quickvec_primvec"
)
declare -a blocked_v_distvec_arr=("hdbscan_basic_blocked"
"hdbscan_basic_triang"
)
save_dir="./data/timings/${TIME}/"
mkdir -p ${save_dir}
#python helper_scripts/generate_clusters.py data 3 4
#python helper_scripts/generate_clusters.py data 6 20
python helper_scripts/generate_clusters.py data 6 ${D}
echo ===============
echo Basic binaries:
echo ===============
for D in 64; do
outfile="${save_dir}basic_cg_N${N}_d${D}.out"
touch ${outfile}
for i in "${basic_arr[@]}"; do
printf "Running Cache analysis for $i\n\n" >> $outfile
valgrind --tool=cachegrind --cachegrind-out-file=cg.out ./build/bin/$i data/perf_data_d${D}_${N}.csv 2>> $outfile
printf "\n////////////////////////////////////////////////////////////////////////////////////\n\n" >> $outfile
done
done
echo =======================
echo Advanced Prim binaries:
echo =======================
for D in 64; do
outfile="${save_dir}advprim_cg_N${N}_d${D}.out"
touch $outfile
for i in "${advprim_arr[@]}"; do
printf "Running Cache analysis for $i\n\n" >> $outfile
valgrind --tool=cachegrind --cachegrind-out-file="cg.out" ./build/bin/${i} data/perf_data_d${D}_${N}.csv 2>> $outfile
printf "\n////////////////////////////////////////////////////////////////////////////////////\n\n" >> $outfile
done
done
echo ===============
echo Blocked-v-Triang binaries:
echo ===============
for D in 64; do
outfile="${save_dir}blocked_v_triang_cg_N${N}_d${D}.out"
touch $outfile
for i in "${blocked_v_distvec_arr[@]}"; do
printf "Running Cache analysis for $i\n\n" >> $outfile
valgrind --tool=cachegrind --cachegrind-out-file="cg.out" ./build/bin/$i data/perf_data_d${D}_${N}.csv 2>> $outfile
printf "\n////////////////////////////////////////////////////////////////////////////////////\n\n" >> $outfile
done
done
cd references/hdbscan-cpp && make clean
if [ $1 = "amd" ]; then
make CXX=${CXX_COMPILER} CPPFLAGS="-DBENCHMARK_AMD -DRUN_ONCE -march=native"
else
make CXX=${CXX_COMPILER} CPPFLAGS="-march=native -DRUN_ONCE"
fi
cd ../..
echo ===============
echo Reference binary:
echo ===============
# a bit hacky, but our script assumes binary is in build
for D in 64; do
outfile="${save_dir}reference_cg_N${N}_d${D}.out"
touch $outfile
printf "Running Cache analysis for reference implementation\n\n" >> $outfile
valgrind --tool=cachegrind --cachegrind-out-file="cg.out" ./references/hdbscan-cpp/main -i data/perf_data_d${D}_${N}.csv 2>> $outfile
printf "\n////////////////////////////////////////////////////////////////////////////////////\n\n" >> $outfile
done
fi