-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
160 lines (135 loc) · 5.81 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
cmake_minimum_required(VERSION 3.16)
project(perma-bench)
include(ExternalProject)
include(FetchContent)
include(CheckCXXSourceCompiles)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -pthread")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
message("-- Release mode, all optimizations enabled")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG")
endif ()
set(INCLUDE_HINTS ${CMAKE_INCLUDE_PATH} "/usr/include" "/usr/local/include")
set(LIB_HINTS "/usr/local/lib64" "/usr/local/lib" "/usr/lib" "/usr/lib64")
# CI
option(IS_CI_BUILD "Set true if this is a CI build.")
##################### AVX ####################
# Use this short program to check if AVX-512 is supported. For now, we only use AVX-512 or not.
# This might need to be adapted in the future to support different SSE/AVX instructions.
include(CheckCSourceRuns)
set(avx512_prog "int main() { asm volatile(\"vmovdqu64 %zmm0, %zmm1\"); return 0; }")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -mavx512f")
check_c_source_runs("${avx512_prog}" HAS_AVX)
if (${HAS_AVX})
# Set HAS_AVX so we can use it to enable all explicit AVX instructions.
add_definitions("-DHAS_AVX")
message(STATUS "System supports AVX-512.")
else ()
if (${IS_CI_BUILD})
message(STATUS "System does not supports AVX-512. This is okay only in a CI build.")
else ()
message(FATAL_ERROR "System does not support AVX-512.")
endif ()
endif ()
# Backup of actual required flags
set(BASE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
##################### CLWB ####################
set(clwb_prog "#include <immintrin.h>\n int main() { _mm_clwb((void*)0); return 0; }")
set(CMAKE_REQUIRED_FLAGS "${BASE_CMAKE_REQUIRED_FLAGS} -mclwb")
check_cxx_source_compiles("${clwb_prog}" HAS_CLWB)
if (${HAS_CLWB})
# Set HAS_CLWB so we can use it to enable all explicit CLWB instructions.
add_definitions("-DHAS_CLWB")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mclwb")
message(STATUS "System supports CLWB.")
else ()
message(STATUS "System does not support CLWB.")
endif ()
##################### CLFLUSHOPT ####################
set(clflush_prog "#include <immintrin.h>\n int main() { _mm_clflushopt((void*)0); return 0; }")
set(CMAKE_REQUIRED_FLAGS "${BASE_CMAKE_REQUIRED_FLAGS} -mclflushopt")
check_cxx_source_compiles("${clflush_prog}" HAS_CLFLUSHOPT)
if (${HAS_CLFLUSHOPT})
# Set HAS_CLFLUSHOPT so we can use it to enable all explicit CLFLUSHOPT instructions.
add_definitions("-DHAS_CLFLUSHOPT")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mclflushopt")
message(STATUS "System supports CLFLUSHOPT.")
else ()
message(STATUS "System does not support CLFLUSHOPT.")
endif ()
################### NUMA ####################
set(NUMA_INCLUDE_PATH "" CACHE STRING "Path to custom NUMA include files")
set(NUMA_LIBRARY_PATH "" CACHE STRING "Path to custom NUMA library")
set(NUMA_INCLUDE_HINTS ${NUMA_INCLUDE_PATH} ${INCLUDE_HINTS})
set(NUMA_LIB_HINTS ${NUMA_LIBRARY_PATH})
find_path(NUMA_INCLUDE_DIRS numa.h HINTS ${NUMA_INCLUDE_HINTS})
find_library(NUMA_LIBRARIES NAMES numa libnuma HINTS ${NUMA_LIB_HINTS})
set(NUMA_FOUND true)
if (NOT NUMA_INCLUDE_DIRS OR "${NUMA_INCLUDE_DIRS}" STREQUAL "")
message(STATUS "WARNING: numa include directory not found. Not using NUMA in this build.")
set(NUMA_FOUND false)
endif ()
if (NOT NUMA_LIBRARIES OR "${NUMA_LIBRARIES}" STREQUAL "")
message(STATUS "WARNING: libnuma not found. Not using NUMA in this build.")
set(NUMA_FOUND false)
endif ()
if (${NUMA_FOUND})
include_directories(${NUMA_INCLUDE_DIRS})
message(STATUS "NUMA provided. Including ${NUMA_INCLUDE_DIRS} and linking ${NUMA_LIBRARIES}.")
add_definitions("-DHAS_NUMA")
message(STATUS "Using libnuma in this build.")
endif()
##################### YAML ####################
set(YAML_CPP_BUILD_TESTS OFF CACHE INTERNAL "")
set(YAML_CPP_INSTALL OFF CACHE INTERNAL "")
set(YAML_CPP_BUILD_TOOLS OFF CACHE INTERNAL "")
FetchContent_Declare(
yaml_cpp
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
GIT_TAG yaml-cpp-0.6.3
)
FetchContent_MakeAvailable(yaml_cpp)
##################### JSON ####################
set(JSON_VERSION v3.10.5)
set(JSON_DOWNLOAD_PATH https://github.com/nlohmann/json/releases/download/${JSON_VERSION}/json.hpp)
set(JSON_DIR ${CMAKE_CURRENT_BINARY_DIR}/json)
set(JSON_INCLUDE_PATH ${JSON_DIR}/json.hpp)
file(DOWNLOAD ${JSON_DOWNLOAD_PATH} ${JSON_INCLUDE_PATH})
include_directories(${JSON_DIR})
################### Hdr Histogram ####################
set(HDR_HISTOGRAM_BUILD_PROGRAMS OFF CACHE INTERNAL "")
FetchContent_Declare(
hdr_histogram
GIT_REPOSITORY https://github.com/HdrHistogram/HdrHistogram_c.git
GIT_TAG 0.11.2
)
FetchContent_MakeAvailable(hdr_histogram)
################### spdlog ####################
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.9.2
)
FetchContent_MakeAvailable(spdlog)
################### CLI11 ####################
set(CLI11_VERSION v2.1.2)
set(CLI11_DOWNLOAD_PATH https://github.com/CLIUtils/CLI11/releases/download/${CLI11_VERSION}/CLI11.hpp)
set(CLI11_DIR ${CMAKE_CURRENT_BINARY_DIR}/cli11)
set(CLI11_INCLUDE_PATH ${CLI11_DIR}/CLI11.hpp)
file(DOWNLOAD ${CLI11_DOWNLOAD_PATH} ${CLI11_INCLUDE_PATH})
include_directories(${CLI11_DIR})
##################### PerMA ####################
add_custom_target(copy_configs
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/workloads ${CMAKE_CURRENT_BINARY_DIR}/workloads)
include_directories(src)
add_subdirectory(src)
##################### Test ####################
option(BUILD_TEST "Set true if tests should be built and run.")
if (${BUILD_TEST})
message(STATUS "Tests are included in this build.")
enable_testing()
add_subdirectory(test)
endif ()