forked from NVIDIA-Merlin/HugeCTR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·265 lines (230 loc) · 9.8 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
#
# Copyright (c) 2021, 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.17)
project(HugeCTR LANGUAGES CXX CUDA)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CUDA_STANDARD 17)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
option(CLANGFORMAT "Setup clangformat target" ON)
if(CLANGFORMAT)
include(ClangFormat)
file(GLOB_RECURSE HUGECTR_SRC
${PROJECT_SOURCE_DIR}/HugeCTR/*.hpp
${PROJECT_SOURCE_DIR}/HugeCTR/*.cpp
${PROJECT_SOURCE_DIR}/HugeCTR/*.cu
${PROJECT_SOURCE_DIR}/HugeCTR/*.cuh
${PROJECT_SOURCE_DIR}/test/utest/*.hpp
${PROJECT_SOURCE_DIR}/test/utest/*.cpp
${PROJECT_SOURCE_DIR}/test/utest/*.cu
${PROJECT_SOURCE_DIR}/test/utest/*.cuh
${PROJECT_SOURCE_DIR}/tools/*.hpp
${PROJECT_SOURCE_DIR}/tools/*.cpp
${PROJECT_SOURCE_DIR}/tools/*.cu
${PROJECT_SOURCE_DIR}/tools/*.cuh
)
set(clangformat_srcs ${HUGECTR_SRC})
clangformat_setup("${clangformat_srcs}")
endif()
option(DISABLE_A2A_WARMUP "Disable nccl a2a warm up" OFF)
if (DISABLE_A2A_WARMUP)
message(STATUS "-- DISABLE_A2A_WARMUP is ON")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDISABLE_A2A_WARMUP")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDISABLE_A2A_WARMUP")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -DDISABLE_A2A_WARMUP")
endif()
option(DISABLE_CUDF "Disable cudf: disable parquet format related features" OFF)
if (DISABLE_CUDF)
message(STATUS "-- DISABLE_CUDF is ON")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DDISABLE_CUDF")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDISABLE_CUDF")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -DDISABLE_CUDF")
else()
find_package(Parquet PATHS /usr/lib/cmake/arrow/ NO_DEFAULT_PATH)
if(Parquet_FOUND)
message (STATUS "Arrow Parquet is found")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_ARROW_PARQUET")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_ARROW_PARQUET")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -DENABLE_ARROW_PARQUET")
endif()
endif()
option(SHARP_A2A "Enable SHARP All2All" OFF)
if (SHARP_A2A)
message (STATUS "-- SHARP_A2A is ON")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSHARP_A2A")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSHARP_A2A")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -DSHARP_A2A")
endif()
find_package(CUDA REQUIRED)
find_package(CUDNN REQUIRED)
find_package(NCCL REQUIRED)
find_package(OpenMP REQUIRED)
find_package(Threads)
option(ENABLE_MULTINODES "Enable multi-nodes training" OFF)
if(ENABLE_MULTINODES)
message(STATUS "Multi Node Enabled")
find_package(MPI)
find_package(UCX)
find_package(HWLOC)
find_package(SHARP)
endif()
set(CUDA_SEPARABLE_COMPILATION ON)
if (OPENMP_FOUND)
message(STATUS "OPENMP FOUND")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
set(JSON_BuildTests OFF CACHE INTERNAL "")
option(KEY_HIT_RATIO "Verbose mode of embedding training cache: print out the key hit ratio" OFF)
if (KEY_HIT_RATIO)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DKEY_HIT_RATIO")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DKEY_HIT_RATIO")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -DKEY_HIT_RATIO")
endif()
# setting compiler flags
foreach(arch_name ${SM})
if (arch_name STREQUAL 90 OR
arch_name STREQUAL 80 OR
arch_name STREQUAL 75 OR
arch_name STREQUAL 70 OR
arch_name STREQUAL 61 OR
arch_name STREQUAL 60)
list(APPEND cuda_arch_list ${arch_name})
message(STATUS "-- Assign GPU architecture (sm=${arch_name})")
else()
message(FATAL_ERROR "-- Unknown or unsupported GPU architecture (set sm=70)")
endif()
endforeach()
list(LENGTH cuda_arch_list cuda_arch_list_length)
if(${cuda_arch_list_length} EQUAL 0)
list(APPEND cuda_arch_list "70")
endif()
list(REMOVE_DUPLICATES cuda_arch_list)
foreach(arch_name ${cuda_arch_list})
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -gencode arch=compute_${arch_name},code=sm_${arch_name}")
endforeach()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -Wno-maybe-uninitialized -Wno-format-truncation -Wno-sign-compare -Wno-error=stringop-overflow=")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wno-unknown-pragmas -Wno-sign-compare -Wno-stringop-overflow -Wno-maybe-uninitialized")
#TODO: the warning should not be suppresed in the long term
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -rdc=true -Xcompiler -Wall,-Werror,-Wno-error=cpp,-Wno-error=parentheses -Xcudafe --display_error_number -Xcudafe --diag_suppress=177")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g -Wall -Werror -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -Wno-maybe-uninitialized -Wno-format-truncation -Wno-sign-compare -Wno-error=stringop-overflow=")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g -Wall -Werror -Wno-unknown-pragmas -Wno-sign-compare -Wno-stringop-overflow -Wno-maybe-uninitialized")
set(CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -O0 -G -Xcompiler -Wall,-Werror,-Wno-error=cpp,-Wno-error=parentheses,-Wno-sign-compare")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --expt-extended-lambda --expt-relaxed-constexpr")
# setting output folder
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
if(ENABLE_MULTINODES)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_MPI")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_MPI")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -DENABLE_MPI")
include_directories(${MPI_INCLUDE_PATH})
include_directories(${HWLOC_INC_PATHS})
include_directories(${UCX_INC_PATHS})
link_directories(/opt/hpcx/ompi/lib)
endif()
configure_file(${PROJECT_SOURCE_DIR}/HugeCTR/include/config.hpp.in ${PROJECT_SOURCE_DIR}/HugeCTR/include/config.hpp)
# building
include_directories(
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/test
${PROJECT_SOURCE_DIR}/HugeCTR/include
$ENV{CONDA_PREFIX}/include
$ENV{CONDA_PREFIX}/include/libcudf/libcudacxx
${CUDA_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/third_party/cuml/cpp
${PROJECT_SOURCE_DIR}/third_party/cuml/cpp/include
${PROJECT_SOURCE_DIR}/third_party/cuml/cpp/src_prims
${PROJECT_SOURCE_DIR}/HugeCTR
${PROJECT_SOURCE_DIR}/HugeCTR/include
${PROJECT_SOURCE_DIR}/third_party
${PROJECT_SOURCE_DIR}/third_party/argparse/include
${PROJECT_SOURCE_DIR}/third_party/cutlass
${PROJECT_SOURCE_DIR}/third_party/cpptqdm
${PROJECT_SOURCE_DIR}/third_party/googletest/googletest/include
${PROJECT_SOURCE_DIR}/third_party/googletest/googlemock/include
${PROJECT_SOURCE_DIR}/third_party/json/single_include
${PROJECT_SOURCE_DIR}/third_party/parallel-hashmap
${PROJECT_SOURCE_DIR}/third_party/xxhash
${PROJECT_SOURCE_DIR}/third_party/redis_pp/src
${PROJECT_SOURCE_DIR}/third_party/redis_pp/src/sw/redis++/no_tls
${PROJECT_SOURCE_DIR}/third_party/redis_pp/src/sw/redis++/cxx17
${PROJECT_SOURCE_DIR}/third_party/rocksdb/include
${PROJECT_SOURCE_DIR}/third_party/librdkafka/src
${PROJECT_SOURCE_DIR}/gpu_cache/include
${PROJECT_SOURCE_DIR}/HugeCTR/embedding_storage/dynamic_embedding_table
${CUDNN_INC_PATHS}
${NCCL_INC_PATHS}
${HWLOC_INC_PATHS}
${UCX_INC_PATHS}
${SHARP_INC_PATHS})
if (CUDA_VERSION_MAJOR LESS 11)
include_directories(${PROJECT_SOURCE_DIR}/third_party/cub)
endif()
if(OPENMP_FOUND)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler -fopenmp")
message(STATUS "add -fopenmp to compiler")
else()
message(FATAL_ERROR "without openmp the multi-node all2all will fail")
endif()
link_directories(
${CUDNN_LIB_PATHS}
${PARQUET_LIB_PATHS}
${NCCL_LIB_PATHS}
${HWLOC_LIB_PATHS}
${UCX_LIB_PATHS}
${SHARP_LIB_PATHS}
$ENV{CONDA_PREFIX}/lib)
#install dependencies
add_subdirectory(third_party)
#setting python interface file install path
install(DIRECTORY ${CMAKE_BINARY_DIR}/lib DESTINATION hugectr)
#install inference header files
install(DIRECTORY ${PROJECT_SOURCE_DIR}/HugeCTR/include/inference DESTINATION hugectr/include)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/HugeCTR/include/hps DESTINATION hugectr/include)
add_subdirectory(third_party/json)
install(DIRECTORY ${CMAKE_BINARY_DIR}/bin DESTINATION hugectr)
add_subdirectory(gpu_cache/src)
add_subdirectory(gpu_cache/test)
option(ENABLE_HDFS "Enable HDFS" OFF)
if(ENABLE_HDFS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_HDFS")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_HDFS")
# Build and Install Hadoop
include(SetupHadoop)
hadoop_setup()
endif()
option(ENABLE_INFERENCE "Enable Inference" OFF)
if(ENABLE_INFERENCE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_INFERENCE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_INFERENCE")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -DENABLE_INFERENCE")
add_subdirectory(third_party/googletest)
add_subdirectory(HugeCTR/src/hps)
add_subdirectory(HugeCTR/src/inference)
add_subdirectory(HugeCTR/src/cpu)
add_subdirectory(test/utest/hps)
add_subdirectory(test/utest/inference)
else()
#setting binary files install path
add_subdirectory(HugeCTR/src)
option(ENABLE_HCTR "Build core HCTR backend" ON)
add_subdirectory(HugeCTR/core)
add_subdirectory(HugeCTR/embedding)
add_subdirectory(third_party/googletest)
add_subdirectory(test/utest)
add_subdirectory(tools)
endif()