-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
207 lines (165 loc) · 5.84 KB
/
CMakeLists.txt
File metadata and controls
207 lines (165 loc) · 5.84 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
cmake_minimum_required(VERSION 3.16)
project(Benchmark-v700 LANGUAGES CXX)
##### tunable build parameters #####
option(SANITIZE "enable sanitizers
(compile and link with address and UB sanitizers)" OFF)
option(HARDENING "enable stdlib hardening
(use stdlib hard debug asserts)" OFF)
option(PAPI "enable PAPI" ON)
option(LIBNUMA "enable libnuma" ON)
option(OPENMP "enable OpenMP" ON)
option(OPTIMIZE "enable compiler optimizations (O3)" ON)
option(TIMELINES "enable measure timelines
(needed for tracing tracing)" OFF)
option(SKIP_VALIDATION "enable validation skipping
(validate data structure or not)" OFF)
option(TESTING "enable utility code testing
(compile target for testing workloads code)" OFF)
option(KEY_TOTAL_STAT "trace depth & search total stats" ON)
set(MAX_THREADS "512" CACHE STRING "declare max threads (should be power of 2)")
set(CPU_FREQ "2.1" CACHE STRING "declare freq for server clock")
##### compiler configuration #####
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
if(CMAKE_EXPORT_COMPILE_COMMANDS)
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES
${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
endif()
set(compilerOptions "")
set(compilerDefinitions "")
set(linkerOptions "")
list(APPEND compilerOptions -mrtm)
list(APPEND compilerOptions -Wno-volatile)
list(APPEND linkerOptions -ldl)
set(isGCC OFF)
set(isClang OFF)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(isGCC ON)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(isClang ON)
endif()
if(SANITIZE)
list(APPEND compilerOptions -fsanitize=undefined,address)
list(APPEND linkerOptions -fsanitize=undefined,address -static-libasan)
list(APPEND compilerOptions
-fno-sanitize-recover=all
-fno-optimize-sibling-calls
-fno-omit-frame-pointer
)
endif()
option(USE_TIMELINES "USE_TIMELINES" OFF)
if (USE_TIMELINES)
add_definitions("-DMEASURE_TIMELINE_STATS")
endif ()
option(NO_OPTIMIZE "NO_OPTIMIZE" OFF)
if (NO_OPTIMIZE)
add_definitions("-O0" "-fno-inline-functions" "-fno-inline")
else ()
add_definitions("-O3")
endif ()
option(SKIP_VALIDATION "SKIP_VALIDATION" OFF)
if (SKIP_VALIDATION)
add_definitions("-DSKIP_VALIDATION")
endif ()
# TODO support libc++
if(HARDENING)
list(APPEND compilerDefinitions _GLIBCXX_DEBUG)
endif()
##### Dependencies #####
include(cmake/Dependencies.cmake)
add_subdirectory(microbench)
include_directories(.)
include_directories(common)
include_directories(common/atomic_ops)
include_directories(common/atomic_ops/atomic_ops)
include_directories(common/dcss)
include_directories(common/descriptors)
include_directories(common/kcas)
include_directories(common/papi)
include_directories(common/recordmgr)
include_directories(common/rlu)
include_directories(common/rq)
include_directories(common/rq/snapcollector)
include_directories(common/urcu)
include_directories(ds/verlib_structs/include)
set(libs "")
find_package(nlohmann_json CONFIG REQUIRED)
list(APPEND libs nlohmann_json::nlohmann_json)
if(OPTIMIZE)
add_compile_definitions(DCMAKE_BUILD_TYPE=Release)
else()
add_compile_definitions(DCMAKE_BUILD_TYPE=Debug)
endif()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads)
list(APPEND libs Threads::Threads)
if(PAPI)
find_library(papi papi REQUIRED)
list(APPEND libs ${papi})
endif()
if(LIBNUMA)
find_library(libnuma numa REQUIRED)
list(APPEND libs ${libnuma})
endif()
if(OPENMP)
find_package(OpenMP REQUIRED)
list(APPEND libs OpenMP::OpenMP_CXX)
endif()
if(TIMELINES)
add_definitions("-DMEASURE_TIMELINE_STATS")
endif()
if(SKIP_VALIDATION)
add_definitions("-DSKIP_VALIDATION")
endif()
add_definitions("-DMAX_THREADS_POW2=${MAX_THREADS}")
add_definitions("-DCPU_FREQ_GHZ=${CPU_FREQ}")
if (KEY_TOTAL_STAT)
add_definitions(
"-DKEY_DEPTH_TOTAL_STAT"
"-DKEY_SEARCH_TOTAL_STAT"
)
endif()
# TODO: find out why this is needed and remove, if possible
add_definitions(
"-DMEMORY_STATS=if\(1\)" # purely hardcoded for trbot's code
"-DMEMORY_STATS2=if\(0\)" # purelu hardcoded for thbot's code
)
add_compile_options(${compilerOptions})
add_compile_definitions(${compilerDefinitions})
add_link_options(${linkerOptions})
##### configure data structures & other targets #####
set(DSDir "ds")
file(GLOB adapters ${DSDir}/*/adapter.h)
set(dataStructures "")
foreach(adapter ${adapters})
get_filename_component(dirPath ${adapter} DIRECTORY)
get_filename_component(dataStructure ${dirPath} NAME)
list(APPEND dataStructures ${dataStructure})
endforeach()
list(JOIN dataStructures "\n* " dataStructuresPP)
message(STATUS "Found data structures: \n* ${dataStructuresPP}")
set(reclaimers "")
list(APPEND reclaimers "debra")
foreach(dataStructure ${dataStructures})
foreach(reclaimer ${reclaimers})
set(target "${dataStructure}.${reclaimer}")
add_executable(${target} microbench/main.cpp)
target_include_directories(${target} PUBLIC ${DSDir}/${dataStructure})
target_link_libraries(${target} PUBLIC microbench::microbench ${libs})
if(${dataStructure} MATCHES "wang_openbwtree")
target_sources(${target} PUBLIC ${DSDir}/${dataStructure}/bwtree.cpp)
target_link_options(${target} PUBLIC -latomic)
endif()
if(${dataStructure} MATCHES "verlib.*")
target_include_directories(${target} PUBLIC parlay)
endif()
endforeach()
endforeach()
if(TESTING)
find_package(GTest CONFIG REQUIRED)
file(GLOB testSources tests/*.cpp)
add_executable(tests ${testSources})
target_link_libraries(tests microbench::microbench GTest::gtest GTest::gtest_main)
endif()