-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
144 lines (117 loc) · 5.75 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.10)
project(
GCCBucketer
VERSION 0.5
LANGUAGES CXX
DESCRIPTION "BDGL bucketing with GCC intrinsics")
# ##############################################################################
# GTest
# ##############################################################################
add_subdirectory(googletest)
enable_testing()
include_directories(SYSTEM ${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
# ##############################################################################
# Find benchmark
# ##############################################################################
# We need GoogleBenchmark in most circumstances. For CI we turn this off. Uncomment it
# if you want microbenchmarks.
#find_package(benchmark REQUIRED)
# ##############################################################################
# Unit Tests
# ##############################################################################
set(LIB_ASAN -fno-omit-frame-pointer -fsanitize=address)
#Tsan)
# Reason for placing these here: easier removal from the flags if you can just
# delete a line here
set(WARNINGS
-Wall
-Wextra
-Wpedantic
-Wnon-virtual-dtor
-Wold-style-cast
-Wcast-align
-Wunused
-Woverloaded-virtual
-Wsign-conversion
-Wmisleading-indentation
-Wnull-dereference
-Wdouble-promotion
-Wformat=2
-Wcast-qual
-Wmissing-declarations
-Wsign-promo
-Wdisabled-optimization
# -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast
# Include -Wmismatched-tags if using GCC 10 or later (see e.g
# https://stackoverflow.com/questions/66550681/gcc-mismatched-tags-option-giving-unrecognized-command-line-option)
# -Wmismatched-tags
)
set(COVERAGE)# -fprofile-arcs -ftest-coverage)
#[[
Because we've listed these arguments as separate elements in a list, we need to concatenate
them into a nice string that'll essentially print them as if the arguments were concatenated into
a single string. This requires quoting them, but we only need to do this in the definition of
G_C_FLAGS
]]
#
list(JOIN WARNINGS " " WARNINGS)
list(JOIN COVERAGE " " COVERAGE)
# Global settings for great good The definition for G_C_FLAGS expands the
# warnings and coverage arguments from above.
set(G_C_NO_AVX2 "-g3 -flax-vector-conversions" "${G_C_NO_AVX2}" "${WARNINGS}" "${LIB_ASAN}" "${COVERAGE}")
set(G_C_FLAGS "-g3 -march=native -flax-vector-conversions " "${G_C_FLAGS}" "${WARNINGS}" "${LIB_ASAN}" "${COVERAGE}")
set(G_L_FLAGS "gtest gtest_main" "${LIB_ASAN}")
set(G_C_OPT_FLAGS "-Ofast -march=native -mtune=native -flto -ftree-vectorize")
# This splits them up into a form that CMAKE can deal with when passing to
# executables
separate_arguments(C_FLAGS UNIX_COMMAND "${G_C_FLAGS}")
separate_arguments(C_NO_AVX2_FLAGS UNIX_COMMAND "${G_C_NO_AVX2}")
separate_arguments(L_FLAGS UNIX_COMMAND "${G_L_FLAGS}")
add_executable(SimdGCCTests src/simd_gcc.t.cpp src/simd.cpp src/fht_lsh_old.cpp)
target_compile_options(SimdGCCTests PRIVATE ${C_FLAGS})
target_link_libraries(SimdGCCTests PRIVATE ${L_FLAGS})
set_target_properties(SimdGCCTests PROPERTIES CXX_STANDARD 17)
add_test(SimdGCCTests SimdGCCTests)
add_executable(SimdIntelTests src/simd_intel.t.cpp src/simd.cpp src/simd_intel.cpp src/fht_lsh_old.cpp)
target_compile_options(SimdIntelTests PRIVATE ${C_FLAGS})
target_link_libraries(SimdIntelTests PRIVATE ${L_FLAGS})
set_target_properties(SimdIntelTests PROPERTIES CXX_STANDARD 17)
add_test(SimdIntelTests SimdIntelTests)
add_executable(SimdIntelNoAVX2Tests src/simd_intel.t.cpp src/simd.cpp)
target_compile_options(SimdIntelNoAVX2Tests PRIVATE ${C_NO_AVX2_FLAGS})
target_link_libraries(SimdIntelNoAVX2Tests PRIVATE ${L_FLAGS})
set_target_properties(SimdIntelNoAVX2Tests PROPERTIES CXX_STANDARD 17)
add_test(SimdIntelNoAVX2Tests SimdIntelNoAVX2Tests)
# ##############################################################################
# Benchmarking
# ##############################################################################
# To begin, we use different compile flags. You won't want to run these
# benchmarks with assertions: what you *really* want to do is write benchmarks
# that show how fast the code will be in release mode.
# WARNING: funroll-loops seems to screw with Google benchmark. Leave it out for better results.
# NOTE: This is commented out because installing Google benchmark is confusing for GH actions.
# To enable these, remove the # [[ blocks
#[[
set(G_C_FLAGS_BENCH
"-Ofast -flax-vector-conversions -march=native -mtune=native -ftree-vectorize")
set(G_L_FLAGS_BENCH "benchmark::benchmark")
separate_arguments(C_FLAGS_BENCH UNIX_COMMAND "${G_C_FLAGS_BENCH}")
separate_arguments(L_FLAGS_BENCH UNIX_COMMAND "${G_L_FLAGS_BENCH}")
add_executable(SimdBench src/simd.b.cpp src/fht_lsh_old.cpp)
target_compile_options(SimdBench PRIVATE ${C_FLAGS_BENCH})
target_link_libraries(SimdBench PRIVATE ${L_FLAGS_BENCH})
set_target_properties(SimdBench PROPERTIES CXX_STANDARD 17)
# Turns out we should benchmark the bucketer too..
add_executable(BucketerBenchOld src/test_lsh_old.cpp src/fht_lsh_old.cpp)
target_compile_options(BucketerBenchOld PRIVATE ${C_FLAGS_BENCH})
target_link_libraries(BucketerBenchOld PRIVATE ${L_FLAGS_BENCH})
set_target_properties(BucketerBenchOld PROPERTIES CXX_STANDARD 17)
add_executable(BucketerBenchIntel src/test_lsh_intel.cpp src/fht_lsh.cpp)
target_compile_options(BucketerBenchIntel PRIVATE ${C_FLAGS_BENCH})
target_link_libraries(BucketerBenchIntel PRIVATE ${L_FLAGS_BENCH})
set_target_properties(BucketerBenchIntel PROPERTIES CXX_STANDARD 17)
add_executable(BucketerBenchGCC src/test_lsh_gcc.cpp src/fht_lsh.cpp)
target_compile_options(BucketerBenchGCC PRIVATE ${C_FLAGS_BENCH})
target_link_libraries(BucketerBenchGCC PRIVATE ${L_FLAGS_BENCH})
set_target_properties(BucketerBenchGCC PROPERTIES CXX_STANDARD 17)
#]]