-
Notifications
You must be signed in to change notification settings - Fork 310
/
Copy pathCMakeLists.txt
462 lines (394 loc) · 15.7 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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
#=============================================================================
# Copyright (c) 2018-2022, 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(../fetch_rapids.cmake)
include(rapids-cmake)
include(rapids-cpm)
include(rapids-cuda)
include(rapids-export)
include(rapids-find)
rapids_cuda_init_architectures(CUGRAPH)
project(CUGRAPH VERSION 22.08.00 LANGUAGES C CXX CUDA)
if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND
CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 11.0)
message(FATAL_ERROR "CUDA compiler version must be at least 11.0")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.3)
message(FATAL_ERROR "GCC compiler must be at least 9.3")
endif()
# Remove the following archs from CMAKE_CUDA_ARCHITECTURES that
# cuhornet currently doesn't support
#
# >= 90
set(supported_archs "60" "62" "70" "72" "75" "80" "86")
foreach( arch IN LISTS CMAKE_CUDA_ARCHITECTURES)
string(REPLACE "-real" "" arch ${arch})
if( arch IN_LIST supported_archs )
list(APPEND usable_arch_values ${arch})
endif()
endforeach()
# Make sure everything but the 'newest' arch
# is marked as `-real` so we only generate PTX for
# arch > 86
list(POP_BACK usable_arch_values latest_arch)
list(TRANSFORM usable_arch_values APPEND "-real")
if (usable_arch_values)
list(APPEND usable_arch_values ${latest_arch})
else()
list(APPEND usable_arch_values ${latest_arch}-real)
endif()
set(CMAKE_CUDA_ARCHITECTURES ${usable_arch_values})
# Write the version header
rapids_cmake_write_version_file(include/cugraph/version_config.hpp)
rapids_cmake_write_version_file(include/cugraph_c/version_config.hpp)
################################################################################
# - build type -----------------------------------------------------------------
# Set a default build type if none was specified
rapids_cmake_build_type(Release)
################################################################################
# - User Options --------------------------------------------------------------
option(BUILD_SHARED_LIBS "Build cuGraph shared libraries" ON)
option(BUILD_CUGRAPH_MG_TESTS "Build cuGraph multigpu algorithm tests" OFF)
option(CMAKE_CUDA_LINEINFO "Enable the -lineinfo option for nvcc (useful for cuda-memcheck / profiler" OFF)
option(BUILD_TESTS "Configure CMake to build tests" ON)
option(USE_CUGRAPH_OPS "Enable all functions that call cugraph-ops" ON)
################################################################################
# - compiler options -----------------------------------------------------------
rapids_find_package(CUDAToolkit REQUIRED
BUILD_EXPORT_SET cugraph-exports
INSTALL_EXPORT_SET cugraph-exports
)
set(CUGRAPH_CXX_FLAGS "")
set(CUGRAPH_CUDA_FLAGS "")
if(CMAKE_COMPILER_IS_GNUCXX)
list(APPEND CUGRAPH_CXX_FLAGS -Werror -Wno-error=deprecated-declarations)
endif(CMAKE_COMPILER_IS_GNUCXX)
message("-- Building for GPU_ARCHS = ${CMAKE_CUDA_ARCHITECTURES}")
list(APPEND CUGRAPH_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr)
list(APPEND CUGRAPH_CUDA_FLAGS -Werror=cross-execution-space-call -Wno-deprecated-declarations -Xptxas=--disable-warnings)
list(APPEND CUGRAPH_CUDA_FLAGS -Xcompiler=-Wall,-Wno-error=sign-compare,-Wno-error=unused-but-set-variable)
list(APPEND CUGRAPH_CUDA_FLAGS -Xfatbin=-compress-all)
# Option to enable line info in CUDA device compilation to allow introspection when profiling /
# memchecking
if (CMAKE_CUDA_LINEINFO)
list(APPEND CUGRAPH_CUDA_FLAGS -lineinfo)
endif()
# Debug options
if(CMAKE_BUILD_TYPE MATCHES Debug)
message(STATUS "Building with debugging flags")
list(APPEND CUGRAPH_CUDA_FLAGS -G -Xcompiler=-rdynamic)
endif()
if(NOT USE_CUGRAPH_OPS)
message(STATUS "Disabling functions that reference cugraph-ops")
list(APPEND CUGRAPH_CXX_FLAGS -DNO_CUGRAPH_OPS)
list(APPEND CUGRAPH_CUDA_FLAGS -DNO_CUGRAPH_OPS)
endif()
###################################################################################################
# - find CPM based dependencies ------------------------------------------------------------------
rapids_cpm_init()
###
# Linking to the `raft::raft` target implicitly links cugraph targets to the
# following public header-only raft dependencies:
# * RMM
# * Thrust
# * GTest/GMock
#
# The CMakeLists.txt for each of these projects are properly configured
# to generate a build and install export-set, so reimplementing finding or
# fetching those targets in cuGraph is redundant (at best), and potentially
# error-prone if something about those targets change and our implementation
# lags behind.
###
# Putting this before raft to override RAFT from pulling them in.
include(cmake/thirdparty/get_libcudacxx.cmake)
include(${rapids-cmake-dir}/cpm/cuco.cmake)
rapids_cpm_cuco(BUILD_EXPORT_SET cugraph-exports)
include(cmake/thirdparty/get_raft.cmake)
if(USE_CUGRAPH_OPS)
include(cmake/thirdparty/get_libcugraphops.cmake)
endif()
include(cmake/thirdparty/get_nccl.cmake)
include(cmake/thirdparty/get_cuhornet.cmake)
if(BUILD_TESTS)
include(cmake/thirdparty/get_gtest.cmake)
endif()
################################################################################
# - libcugraph library target --------------------------------------------------
set(CUGRAPH_SOURCES
src/detail/utility_wrappers.cu
src/detail/shuffle_wrappers.cu
src/utilities/cython.cu
src/utilities/path_retrieval.cu
src/utilities/graph_bcast.cu
src/structure/legacy/graph.cu
src/linear_assignment/hungarian.cu
src/traversal/legacy/bfs.cu
src/link_prediction/jaccard.cu
src/link_prediction/overlap.cu
src/layout/legacy/force_atlas2.cu
src/converters/legacy/COOtoCSR.cu
src/community/legacy/spectral_clustering.cu
src/community/louvain_sg.cu
src/community/louvain_mg.cu
src/community/legacy/louvain.cu
src/community/legacy/leiden.cu
src/community/legacy/ktruss.cu
src/community/legacy/ecg.cu
src/community/legacy/triangles_counting.cu
src/community/legacy/extract_subgraph_by_vertex.cu
src/community/legacy/egonet.cu
src/sampling/random_walks.cu
src/sampling/random_walks_sg.cu
src/sampling/random_walks_mg.cu
src/sampling/detail/sampling_utils_mg.cu
src/sampling/detail/sampling_utils_sg.cu
src/sampling/uniform_neighbor_sampling_mg.cpp
src/sampling/uniform_neighbor_sampling_sg.cpp
src/cores/legacy/core_number.cu
src/cores/core_number_sg.cu
src/cores/core_number_mg.cu
src/traversal/two_hop_neighbors.cu
src/components/legacy/connectivity.cu
src/centrality/betweenness_centrality.cu
src/generators/generate_rmat_edgelist.cu
src/generators/generator_tools.cu
src/generators/simple_generators.cu
src/generators/erdos_renyi_generator.cu
src/structure/graph_sg.cu
src/structure/graph_mg.cu
src/structure/graph_view_sg.cu
src/structure/graph_view_mg.cu
src/structure/coarsen_graph_sg.cu
src/structure/coarsen_graph_mg.cu
src/structure/renumber_edgelist_sg.cu
src/structure/renumber_edgelist_mg.cu
src/structure/renumber_utils_sg.cu
src/structure/renumber_utils_mg.cu
src/structure/relabel_sg.cu
src/structure/relabel_mg.cu
src/structure/induced_subgraph_sg.cu
src/structure/induced_subgraph_mg.cu
src/traversal/extract_bfs_paths_sg.cu
src/traversal/extract_bfs_paths_mg.cu
src/traversal/bfs_sg.cu
src/traversal/bfs_mg.cu
src/traversal/sssp_sg.cu
src/traversal/sssp_mg.cu
src/link_analysis/hits_sg.cu
src/link_analysis/hits_mg.cu
src/link_analysis/pagerank_sg.cu
src/link_analysis/pagerank_mg.cu
src/centrality/katz_centrality_sg.cu
src/centrality/katz_centrality_mg.cu
src/centrality/eigenvector_centrality_sg.cu
src/centrality/eigenvector_centrality_mg.cu
src/serialization/serializer.cu
src/tree/mst.cu
src/components/weakly_connected_components_sg.cu
src/components/weakly_connected_components_mg.cu
src/structure/create_graph_from_edgelist_sg.cu
src/structure/create_graph_from_edgelist_mg.cu
src/structure/symmetrize_edgelist_sg.cu
src/structure/symmetrize_edgelist_mg.cu
src/community/triangle_count_sg.cu
src/community/triangle_count_mg.cu
)
if(USE_CUGRAPH_OPS)
list(APPEND CUGRAPH_SOURCES
src/sampling/neighborhood.cu
)
endif()
add_library(cugraph ${CUGRAPH_SOURCES})
set_target_properties(cugraph
PROPERTIES BUILD_RPATH "\$ORIGIN"
INSTALL_RPATH "\$ORIGIN"
# set target compile options
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CUDA_STANDARD 17
CUDA_STANDARD_REQUIRED ON
POSITION_INDEPENDENT_CODE ON
INTERFACE_POSITION_INDEPENDENT_CODE ON
)
target_compile_options(cugraph
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${CUGRAPH_CXX_FLAGS}>"
"$<$<COMPILE_LANGUAGE:CUDA>:${CUGRAPH_CUDA_FLAGS}>"
)
# Per-thread default stream option see https://docs.nvidia.com/cuda/cuda-runtime-api/stream-sync-behavior.html
# The per-thread default stream does not synchronize with other streams
target_compile_definitions(cugraph PUBLIC CUDA_API_PER_THREAD_DEFAULT_STREAM)
file(WRITE "${CUGRAPH_BINARY_DIR}/fatbin.ld"
[=[
SECTIONS
{
.nvFatBinSegment : { *(.nvFatBinSegment) }
.nv_fatbin : { *(.nv_fatbin) }
}
]=])
target_link_options(cugraph PRIVATE "${CUGRAPH_BINARY_DIR}/fatbin.ld")
add_library(cugraph::cugraph ALIAS cugraph)
################################################################################
# - include paths --------------------------------------------------------------
target_include_directories(cugraph
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/../thirdparty"
"${CMAKE_CURRENT_SOURCE_DIR}/src"
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
################################################################################
# - link libraries -------------------------------------------------------------
if (USE_CUGRAPH_OPS)
target_link_libraries(cugraph
PUBLIC
cugraph-ops::cugraph-ops++
raft::raft
PRIVATE
cuco::cuco
cugraph::cuHornet
NCCL::NCCL
)
else()
target_link_libraries(cugraph
PUBLIC
raft::raft
PRIVATE
cuco::cuco
cugraph::cuHornet
NCCL::NCCL
)
endif()
################################################################################
# - C-API library --------------------------------------------------------------
add_library(cugraph_c
src/c_api/resource_handle.cpp
src/c_api/array.cpp
src/c_api/error.cpp
src/c_api/graph_sg.cpp
src/c_api/graph_mg.cpp
src/c_api/pagerank.cpp
src/c_api/katz.cpp
src/c_api/centrality_result.cpp
src/c_api/eigenvector_centrality.cpp
src/c_api/core_number.cpp
src/c_api/core_result.cpp
src/c_api/hits.cpp
src/c_api/bfs.cpp
src/c_api/sssp.cpp
src/c_api/extract_paths.cpp
src/c_api/random_walks.cpp
src/c_api/louvain.cpp
src/c_api/triangle_count.cpp
src/c_api/uniform_neighbor_sampling.cpp
src/c_api/labeling_result.cpp
src/c_api/weakly_connected_components.cpp
src/c_api/strongly_connected_components.cpp
)
add_library(cugraph::cugraph_c ALIAS cugraph_c)
# Currently presuming we aren't calling any CUDA kernels in cugraph_c
set_target_properties(cugraph_c
PROPERTIES BUILD_RPATH "\$ORIGIN"
INSTALL_RPATH "\$ORIGIN"
# set target compile options
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
INTERFACE_POSITION_INDEPENDENT_CODE ON
)
target_compile_options(cugraph_c
PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:${CUGRAPH_CXX_FLAGS}>"
)
################################################################################
# - C-API include paths --------------------------------------------------------
target_include_directories(cugraph_c
PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/src"
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
################################################################################
# - C-API link libraries -------------------------------------------------------
target_link_libraries(cugraph_c
PUBLIC
CUDA::cublas
CUDA::curand
CUDA::cusolver
CUDA::cusparse
raft::raft
PRIVATE
cuco::cuco
cugraph::cugraph
)
################################################################################
# - generate tests -------------------------------------------------------------
if(BUILD_TESTS)
include(CTest)
add_subdirectory(tests)
endif()
################################################################################
# - install targets ------------------------------------------------------------
rapids_cmake_install_lib_dir( lib_dir )
include(CPack)
install(TARGETS cugraph
DESTINATION ${lib_dir}
EXPORT cugraph-exports)
install(DIRECTORY include/cugraph/
DESTINATION include/cugraph)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/cugraph/version_config.hpp
DESTINATION include/cugraph)
install(TARGETS cugraph_c
DESTINATION ${lib_dir})
install(DIRECTORY include/cugraph_c/
DESTINATION include/cugraph_c)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/cugraph_c/version_config.hpp
DESTINATION include/cugraph_c)
################################################################################
# - install export -------------------------------------------------------------
set(doc_string
[=[
Provide targets for cuGraph.
cuGraph library is a collection of GPU accelerated graph algorithms that process data found in
[GPU DataFrames](https://github.com/rapidsai/cudf).
]=])
rapids_export(INSTALL cugraph
EXPORT_SET cugraph-exports
GLOBAL_TARGETS cugraph cugraph_c
NAMESPACE cugraph::
DOCUMENTATION doc_string
)
################################################################################
# - build export ---------------------------------------------------------------
rapids_export(BUILD cugraph
EXPORT_SET cugraph-exports
GLOBAL_TARGETS cugraph cugraph_c
NAMESPACE cugraph::
DOCUMENTATION doc_string
)
################################################################################
# - make documentation ---------------------------------------------------------
# requires doxygen and graphviz to be installed
# from build directory, run make docs_cugraph
# doc targets for cugraph
find_package(Doxygen 1.8.11)
if(Doxygen_FOUND)
add_custom_command(OUTPUT CUGRAPH_DOXYGEN
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doxygen
COMMAND doxygen Doxyfile
VERBATIM)
add_custom_target(docs_cugraph DEPENDS CUGRAPH_DOXYGEN)
endif()