-
Notifications
You must be signed in to change notification settings - Fork 66
/
CMakeLists.txt
267 lines (227 loc) · 8.85 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
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
# =============================================================================
# Copyright (c) 2022-2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under
# the License.
# =============================================================================
cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR)
include(../../../thirdparty/cudf/fetch_rapids.cmake)
include(rapids-cmake)
include(rapids-cpm)
include(rapids-cuda)
include(rapids-export)
include(rapids-find)
include(rapids-cpm)
rapids_cpm_init()
# Use GPU_ARCHS if it is defined
if(DEFINED GPU_ARCHS)
set(CMAKE_CUDA_ARCHITECTURES "${GPU_ARCHS}")
endif()
rapids_cuda_init_architectures(SPARK_RAPIDS_JNI)
project(
SPARK_RAPIDS_JNI
VERSION 23.06.00
LANGUAGES C CXX CUDA
)
# ##################################################################################################
# * build options ---------------------------------------------------------------------------------
option(CUDF_USE_PER_THREAD_DEFAULT_STREAM "Build with per-thread default stream" ON)
option(USE_GDS "Build with GPUDirect Storage (GDS)/cuFile support" OFF)
option(BUILD_TESTS "Configure CMake to build tests" OFF)
option(BUILD_BENCHMARKS "Configure CMake to build (google) benchmarks" OFF)
message(
VERBOSE "SPARK_RAPIDS_JNI: Build with per-thread default stream:
${CUDF_USE_PER_THREAD_DEFAULT_STREAM}"
)
message(VERBOSE "SPARK_RAPIDS_JNI: Configure CMake to build tests: ${BUILD_TESTS}")
message(VERBOSE "SPARK_RAPIDS_JNI: Configure CMake to build (nvbench) benchmarks: ${BUILD_BENCHMARKS}")
set(SPARK_RAPIDS_JNI_CXX_FLAGS "")
set(SPARK_RAPIDS_JNI_CUDA_FLAGS "")
set(SPARK_RAPIDS_JNI_CXX_DEFINITIONS "")
set(SPARK_RAPIDS_JNI_CUDA_DEFINITIONS "")
set(SPARK_RAPIDS_JNI_BUILD_TESTS ${BUILD_TESTS})
set(SPARK_RAPIDS_JNI_BUILD_BENCHMARKS ${BUILD_BENCHMARKS})
# Set RMM logging level
set(RMM_LOGGING_LEVEL
"INFO"
CACHE STRING "Choose the logging level."
)
set_property(
CACHE RMM_LOGGING_LEVEL PROPERTY STRINGS "TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" "OFF"
)
message(VERBOSE "SPARK_RAPIDS_JNI: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'.")
set(CUDF_INSTALL_DIR
"${PROJECT_BINARY_DIR}/../libcudf-install"
CACHE STRING "path to libcudf install root"
)
set(CMAKE_PREFIX_PATH ${CUDF_INSTALL_DIR})
set(CUDF_DIR
"${PROJECT_BINARY_DIR}/../../thirdparty/cudf"
CACHE STRING "path to cudf repository"
)
# Set a default build type if none was specified
rapids_cmake_build_type("Release")
# ##################################################################################################
# * compiler options ------------------------------------------------------------------------------
rapids_find_package(CUDAToolkit REQUIRED)
include(cmake/Modules/ConfigureCUDA.cmake) # set other CUDA compilation flags
# ##################################################################################################
# * dependencies ----------------------------------------------------------------------------------
# JNI
find_package(JNI REQUIRED)
if(JNI_FOUND)
message(STATUS "JDK with JNI in ${JNI_INCLUDE_DIRS}")
else()
message(FATAL_ERROR "JDK with JNI not found, please check your settings.")
endif()
# cudf
if(BUILD_TESTS)
rapids_find_package(cudf REQUIRED COMPONENTS testing)
else()
rapids_find_package(cudf REQUIRED)
endif()
# cudfjni
find_library(CUDFJNI_LIB "libcudfjni.a" REQUIRED NO_DEFAULT_PATH
HINTS "${PROJECT_BINARY_DIR}/../libcudfjni"
)
# parquet
find_library(PARQUET_LIB "libparquet.a" REQUIRED NO_DEFAULT_PATH
HINTS "${PROJECT_BINARY_DIR}/../libcudf-install/lib64"
HINTS "${PROJECT_BINARY_DIR}/../libcudf-install/lib"
)
# Internal parquet headers
set (GENERATED_PARQUET_INCLUDE
"${CUDF_DIR}/cpp/build/_deps/arrow-src/cpp/src/"
CACHE STRING "generated parquet thrift headers"
)
# thrift
find_library(THRIFT_LIB "libthrift.a" REQUIRED NO_DEFAULT_PATH
HINTS "${CUDF_DIR}/cpp/build/_deps/arrow-build/thrift_ep-install/lib/"
)
set(CUDFJNI_INCLUDE_DIRS
"${CUDF_DIR}/java/src/main/native/include"
"${CUDF_DIR}/java/src/main/native/src"
"${GENERATED_PARQUET_INCLUDE}"
"${CUDF_DIR}/cpp/build/_deps/arrow-build/thrift_ep-install/include/"
)
# ##################################################################################################
# * library targets -------------------------------------------------------------------------------
add_library(
spark_rapids_jni SHARED
src/CastStringJni.cpp
src/DecimalUtilsJni.cpp
src/MapUtilsJni.cpp
src/NativeParquetJni.cpp
src/RowConversionJni.cpp
src/SparkResourceAdaptorJni.cpp
src/ZOrderJni.cpp
src/cast_string.cu
src/cast_string_to_float.cu
src/decimal_utils.cu
src/map_utils.cu
src/row_conversion.cu
src/zorder.cu
)
set_target_properties(
spark_rapids_jni
PROPERTIES BUILD_RPATH "\$ORIGIN"
INSTALL_RPATH "\$ORIGIN"
# set target compile options
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS ON
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED ON
POSITION_INDEPENDENT_CODE ON
INTERFACE_POSITION_INDEPENDENT_CODE ON
CUDA_RUNTIME_LIBRARY Static
)
target_compile_options(
spark_rapids_jni PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${SPARK_RAPIDS_JNI_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${SPARK_RAPIDS_JNI_CUDA_FLAGS}>"
)
# Specify include paths for the current target and dependents
target_include_directories(
spark_rapids_jni
PRIVATE "${SPARK_RAPIDS_JNI_SOURCE_DIR}/src"
"${JNI_INCLUDE_DIRS}"
"${CUDFJNI_INCLUDE_DIRS}"
"${CUDAToolkit_INCLUDE_DIRS}"
)
target_compile_definitions(
spark_rapids_jni PUBLIC "$<$<COMPILE_LANGUAGE:CXX>:${SPARK_RAPIDS_JNI_CXX_DEFINITIONS}>"
"$<BUILD_INTERFACE:$<$<COMPILE_LANGUAGE:CUDA>:${SPARK_RAPIDS_JNI_CUDA_DEFINITIONS}>>"
)
# Per-thread default stream
if(CUDF_USE_PER_THREAD_DEFAULT_STREAM)
target_compile_definitions(
spark_rapids_jni PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM CUDF_USE_PER_THREAD_DEFAULT_STREAM
)
endif()
target_link_libraries(
spark_rapids_jni PRIVATE
-Wl,--whole-archive
${CUDFJNI_LIB}
cudf::cudf
-Wl,--no-whole-archive
${PARQUET_LIB}
${THRIFT_LIB}
)
set_target_properties(spark_rapids_jni PROPERTIES LINK_LANGUAGE "CXX")
# For backwards-compatibility with the cudf Java bindings and RAPIDS accelerated UDFs,
# all of the code is built into libcudf.so that is statically linked to the CUDA runtime library.
# libcudfjni.so is a stub library dynamically-linked to libcudf.so.
set_target_properties(spark_rapids_jni PROPERTIES OUTPUT_NAME "cudf")
add_library(cudfjnistub SHARED src/emptyfile.cpp)
set_target_properties(cudfjnistub PROPERTIES OUTPUT_NAME "cudfjni")
target_link_libraries(cudfjnistub -Wl,--no-as-needed $<TARGET_FILE:spark_rapids_jni> -Wl,--as-needed)
add_dependencies(cudfjnistub spark_rapids_jni)
# ##################################################################################################
# * cuFile JNI -------------------------------------------------------------------------------------
if(USE_GDS)
include(${CUDF_DIR}/cpp/cmake/Modules/FindcuFile.cmake)
find_library(CUFILEJNI_LIB "libcufilejni.a" REQUIRED NO_DEFAULT_PATH
HINTS "${PROJECT_BINARY_DIR}/../libcudfjni"
)
add_library(cufilejni SHARED src/emptyfile.cpp)
set_target_properties(
cufilejni
PROPERTIES BUILD_RPATH "\$ORIGIN"
INSTALL_RPATH "\$ORIGIN"
# set target compile options
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
)
target_link_libraries(
cufilejni PRIVATE
-Wl,--whole-archive
${CUFILEJNI_LIB}
-Wl,--no-whole-archive
spark_rapids_jni
${cuFile_LIBRARIES}
CUDA::cudart_static
)
endif()
# ##################################################################################################
# * add tests -------------------------------------------------------------------------------------
if(SPARK_RAPIDS_JNI_BUILD_TESTS)
# include CTest module -- automatically calls enable_testing()
include(CTest)
add_subdirectory(tests)
endif()
# ##################################################################################################
# * add benchmarks --------------------------------------------------------------------------------
if(SPARK_RAPIDS_JNI_BUILD_BENCHMARKS)
# Find or install NVBench
include(${rapids-cmake-dir}/cpm/nvbench.cmake)
rapids_cpm_nvbench()
add_subdirectory(benchmarks)
endif()
add_subdirectory(faultinj)