-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathCMakeLists.txt
193 lines (149 loc) · 7.42 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
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
## GENERAL PROJECT SETTINGS
cmake_minimum_required(VERSION 3.8)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release" "Debug")
project("genie"
VERSION 0.1
LANGUAGES C CXX CUDA)
enable_testing()
include(CheckCXXCompilerFlag)
include(ExternalProject)
option(GENIE_COMPR "Build compression module" OFF)
option(GENIE_SIMDCAI "Build SIMDCAIR library (from Daniel Lemire) and related tests (COMPR must be ON)" OFF)
option(GENIE_DISTRIBUTED "Build distributed GENIE" OFF)
option(GENIE_EXAMPLES "Build GENIE examples" ON)
option(BUILD_SHARED_LIBS OFF)
# If the user does not specify PREFIX, we default to ${CMAKE_BINARY_DIR} instead of system directory /usr
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Default install path (prefix)" FORCE)
endif()
## COMPILERS
set(CMAKE_CXX_STANDARD 11)
if (NOT ${CMAKE_COMPILER_IS_GNUCXX})
message(FATAL_ERROR "Only GNU compilers are supported")
endif()
set(genie_warnings "-Wall -Wextra -Wno-unused-parameter -Wno-unused-variable") #-Werror
set(CMAKE_C_FLAGS "${genie_warnings}")
set(CMAKE_CXX_FLAGS "${genie_warnings}")
set(CMAKE_CUDA_FLAGS "--std c++11 --generate-code arch=compute_35,code=sm_35 --generate-code arch=compute_52,code=sm_52 --relocatable-device-code true --Werror cross-execution-space-call")
# Disable cudafe warning: "type qualifier is meaningless on cast type" occuring in boost::archive
# https://stackoverflow.com/questions/14831051/how-to-disable-compiler-warnings-with-nvcc
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} \
-Xcudafe --diag_suppress=cast_to_qualified_type,--diag_suppress=integer_sign_change,--diag_suppress=set_but_not_used")
# Boost 1.64 has a bug with Cuda 7.5 and 8.0, where compilation fails on static assert from g++ standard library
# https://svn.boost.org/trac10/ticket/13049
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -DBOOST_NO_CXX11_NOEXCEPT")
set(CMAKE_CUDA_FLAGS_DEBUG "--debug --device-debug --generate-line-info")
set(CMAKE_CUDA_FLAGS_RELEASE "--optimize 3 --generate-line-info -DNDEBUG")
# set(CUDA_NVCC_FLAGS_RELWITHDEBUGINFO "--optimize 2 --generate-line-info")
set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER})
set(CUDA_SEPARABLE_COMPILATION ON)
## DEPENDENCIES
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
### Boost
set(Boost_USE_STATIC_LIBS ON)
set(Boost_COMPONETNS iostreams serialization program_options)
# WARNING: CMake may issue a warning: Imported targets not available for Boost version 106400
# This happens when CMake doesn't recognize too new version of Boost, for example CMake 3.7 doesn't recognize Boost
# 1.64, but CMake 3.8 already does. The warning causes missing Boost components dependencies, but may be ignored.
find_package(Boost 1.63.0 REQUIRED COMPONENTS ${Boost_COMPONETNS})
### Thrust
find_package(Thrust REQUIRED)
include_directories(${THRUST_INCLUDE_DIR})
### MPI & OpenMP
if (GENIE_DISTRIBUTED)
# WORKAROUND: Unset all variables for FindMPI. There are no input variables for FindMPI for MPI home directory.
# Unsetting MPI_HOME (undocumented variable FindMPI uses) is not sufficient.
set(_FINDMPI_CACHED_VARIABLES MPIEXEC MPIEXEC_MAX_NUMPROCS MPIEXEC_NUMPROC_FLAG MPIEXEC_POSTFLAGS MPIEXEC_PREFLAGS
MPI_CXX_COMPILER MPI_CXX_COMPILE_FLAGS MPI_CXX_INCLUDE_PATH MPI_CXX_LIBRARIES MPI_CXX_LINK_FLAGS MPI_C_COMPILER
MPI_C_COMPILE_FLAGS MPI_C_INCLUDE_PATH MPI_C_LIBRARIES MPI_C_LINK_FLAGS MPI_EXTRA_LIBRARY MPI_LIBRARY)
foreach (_FINDMPI_VAR ${_FINDMPI_CACHED_VARIABLES})
unset(${_FINDMPI_VAR} CACHE)
endforeach()
find_package(MPI REQUIRED) # Use MPI_HOME or env(MPI_HOME) to define root directory of MPI installation
message(STATUS "Found mpiexec: ${MPIEXEC}")
# Check for correct OpenMPI and version
if (NOT MPIEXEC OR NOT MPI_C_FOUND OR NOT MPI_CXX_FOUND)
message(FATAL_ERROR "OpenMPI not found!")
endif()
execute_process(COMMAND ${MPI_C_COMPILER} "--showme:version" OUTPUT_VARIABLE MPI_VERSION ERROR_VARIABLE MPI_VERSION_ERR)
if (MPI_VERSION STREQUAL "")
set(MPI_VERSION ${MPI_VERSION_ERR})
endif()
if (NOT ${MPI_VERSION} MATCHES ".*Open MPI.*")
message(FATAL_ERROR "MPI not OpenMPI!")
endif()
if(NOT ${MPI_VERSION} MATCHES ".* 1\\.[7-9]\\..*| .*1\\.10\\..*| .* 2\\.[0-9]+\\..*")
message(FATAL_ERROR "OpenMPI has unknown or too low version! Required OpenMPI 1.7 or higher.")
endif()
find_package(OpenMP REQUIRED)
message(STATUS "Distributed GENIE module enabled")
include_directories(${MPI_INCLUDE_PATH})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
## Bzip2
find_package(BZip2 REQUIRED)
## COMPRESSION MODULE
if (GENIE_COMPR)
message(STATUS "Compression module enabled")
if (GENIE_SIMDCAI)
# Add external project lemire/SIMDCompressionAndIntersection - this is used for reference implementations of
# integer compression, delta encoding and intersections of posting lists
ExternalProject_Add(
SIMDCAI_PROJ # Name for custom target
PREFIX "simdcai" # Root dir for entire project
GIT_REPOSITORY https://github.com/lemire/SIMDCompressionAndIntersection # URL of git repo
UPDATE_COMMAND "" # Source work-tree update command
PATCH_COMMAND bash -c "patch --directory=${PROJECT_BINARY_DIR}/simdcai/src/SIMDCAI_PROJ --strip=1 --forward --quiet < ${PROJECT_SOURCE_DIR}/simdcai.patch" # Patch SIMDCAI_PROJ source for NVCC
CONFIGURE_COMMAND "" # Build tree configuration command
BUILD_COMMAND make "-j4" # Command to drive the native build
BUILD_IN_SOURCE 1 # Use source dir for build dir
INSTALL_COMMAND "" # Command to drive install after build
TEST_AFTER_INSTALL 1 # Add test step executed after install step
TEST_COMMAND "./unit" # Command to drive test
)
# Retrieve the in-source build location of SIMDCAI
ExternalProject_Get_Property(SIMDCAI_PROJ BINARY_DIR)
set(SIMDCAI_PROJ_INSTALL_DIR ${BINARY_DIR})
SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")
include_directories(SYSTEM "${SIMDCAI_PROJ_INSTALL_DIR}/include" ${PROJECT_SOURCE_DIR}/simdcai/src)
endif()
else()
message(STATUS "Compression module disabled")
if (GENIE_SIMDCAI)
message(SEND_ERROR "SIMDCAI cannot be enabled without COMPR!" )
endif()
endif()
## INCLUDES AND LINK DIRECTORIES
include_directories(${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src ${Boost_INCLUDE_DIR})
link_directories(${PROJECT_BINARY_DIR}/lib ${Boost_LIBRARY_DIR})
## HELPER FUNCTIONS
function(genie_add_simple_executable TARGET)
add_executable(${TARGET} ${ARGN})
add_dependencies(${TARGET} ${PROJECT_NAME})
set_property(TARGET ${TARGET} PROPERTY LINK_DEPENDS ${PROJECT_BINARY_DIR}/lib/libgenie.a)
target_link_libraries(${TARGET}
${PROJECT_NAME}
${CUDA_cudadevrt_LIBRARY})
install(TARGETS ${TARGET}
RUNTIME DESTINATION bin)
endfunction()
## OUTPUT OPTIONS
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
## CMAKE SUBDIRECTORIES
add_subdirectory(doc)
if (GENIE_EXAMPLES)
add_subdirectory(example)
endif()
add_subdirectory(src)
if (GENIE_DISTRIBUTED)
add_subdirectory(src/dist_genie)
endif()
add_subdirectory(src/genie_cli)
if (GENIE_COMPR)
add_subdirectory(src/perf_toolkit)
endif()
add_subdirectory(static)
add_subdirectory(test)
add_subdirectory(utility)