Skip to content

Commit 63419a8

Browse files
committed
add cuvs to dependency list and third party library
1 parent 3bdc52d commit 63419a8

File tree

2 files changed

+99
-1
lines changed

2 files changed

+99
-1
lines changed

cpp/CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ option(BUILD_TESTS "Configure CMake to build tests" ON)
5757
option(USE_RAFT_STATIC "Build raft as a static library" OFF)
5858
option(CUGRAPH_COMPILE_RAFT_LIB "Compile the raft library instead of using it header-only" ON)
5959
option(CUDA_STATIC_RUNTIME "Statically link the CUDA toolkit runtime and libraries" OFF)
60+
#option(USE_CUVS_STATIC "Build and statically link the CUVS library" OFF)
61+
#option(CUGRAPH_COMPILE_CUVS_LIB "Compile the cuvs library instead of using it header-only" ON)
6062

6163
message(VERBOSE "CUGRAPH: CUDA_STATIC_RUNTIME=${CUDA_STATIC_RUNTIME}")
6264

@@ -121,14 +123,15 @@ rapids_cpm_init()
121123
# lags behind.
122124
###
123125

124-
# Need CCCL, then rmm, then cuCollections, then RAFT.
126+
# Need CCCL, then rmm, then cuCollections, then RAFT and CUVS.
125127
# This ensures that libraries can be overridden for testing.
126128
include(cmake/thirdparty/get_cccl.cmake)
127129
include(${rapids-cmake-dir}/cpm/rmm.cmake)
128130
rapids_cpm_rmm(BUILD_EXPORT_SET cugraph-exports)
129131
include(${rapids-cmake-dir}/cpm/cuco.cmake)
130132
rapids_cpm_cuco(BUILD_EXPORT_SET cugraph-exports INSTALL_EXPORT_SET cugraph-exports)
131133
include(cmake/thirdparty/get_raft.cmake)
134+
include(cmake/thirdparty/get_cuvs.cmake)
132135

133136
if (BUILD_CUGRAPH_MTMG_TESTS)
134137
if(NOT TARGET ucx::ucp)
@@ -487,15 +490,25 @@ if(CUGRAPH_COMPILE_RAFT_LIB)
487490
endif()
488491
endif()
489492

493+
#set(COMPILED_CUVS_LIB )
494+
#if(CUGRAPH_COMPILE_CUVS_LIB)
495+
#set(COMPILED_CUVS_LIB cuvs::compiled)
496+
#if(USE_CUVS_STATIC)
497+
#set(COMPILED_CUVS_LIB cuvs::cuvs_static)
498+
#endif()
499+
#endif()
500+
490501
################################################################################
491502
# - link libraries -------------------------------------------------------------
492503
target_link_libraries(cugraph
493504
PUBLIC
494505
rmm::rmm
495506
raft::raft
507+
cuvs::cuvs
496508
$<BUILD_LOCAL_INTERFACE:CUDA::toolkit>
497509
PRIVATE
498510
${COMPILED_RAFT_LIB}
511+
#${COMPILED_CUVS_LIB}
499512
cuco::cuco
500513
)
501514

cpp/cmake/thirdparty/get_cuvs.cmake

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#=============================================================================
2+
# Copyright (c) 2025, NVIDIA CORPORATION.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#=============================================================================
16+
17+
set(CUGRAPH_MIN_VERSION_cuvs "${CUGRAPH_VERSION_MAJOR}.${CUGRAPH_VERSION_MINOR}.00")
18+
set(CUGRAPH_BRANCH_VERSION_cuvs "${CUGRAPH_VERSION_MAJOR}.${CUGRAPH_VERSION_MINOR}")
19+
20+
function(find_and_configure_cuvs)
21+
set(oneValueArgs VERSION FORK PINNED_TAG EXCLUDE_FROM_ALL USE_CUVS_STATIC COMPILE_LIBRARY CLONE_ON_PIN)
22+
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}"
23+
"${multiValueArgs}" ${ARGN} )
24+
25+
if(PKG_CLONE_ON_PIN AND NOT PKG_PINNED_TAG STREQUAL "branch-${CUGRAPH_BRANCH_VERSION_cuvs}")
26+
message(STATUS "CUGRAPH: CUVS pinned tag found: ${PKG_PINNED_TAG}. Cloning cuvs locally.")
27+
set(CPM_DOWNLOAD_cuvs ON)
28+
elseif(PKG_USE_CUVS_STATIC AND (NOT CPM_cuvs_SOURCE))
29+
message(STATUS "CUGRAPH: Cloning cuvs locally to build static libraries.")
30+
set(CPM_DOWNLOAD_cuvs ON)
31+
else()
32+
message(STATUS "Not cloning cuvs locally")
33+
endif()
34+
35+
if(PKG_USE_CUVS_STATIC)
36+
set(CUVS_LIB cuvs::cuvs_static PARENT_SCOPE)
37+
else()
38+
set(CUVS_LIB cuvs::cuvs PARENT_SCOPE)
39+
endif()
40+
41+
set(CUVS_BUILD_MG_ALGOS ON)
42+
if(SINGLEGPU)
43+
set(CUVS_BUILD_MG_ALGOS OFF)
44+
endif()
45+
46+
rapids_cpm_find(cuvs ${PKG_VERSION}
47+
GLOBAL_TARGETS cuvs::cuvs
48+
BUILD_EXPORT_SET CUGRAPH-exports
49+
INSTALL_EXPORT_SET CUGRAPH-exports
50+
CPM_ARGS
51+
GIT_REPOSITORY https://github.com/${PKG_FORK}/cuvs.git
52+
GIT_TAG ${PKG_PINNED_TAG}
53+
SOURCE_SUBDIR cpp
54+
EXCLUDE_FROM_ALL ${PKG_EXCLUDE_FROM_ALL}
55+
OPTIONS
56+
"BUILD_TESTS OFF"
57+
"BUILD_CAGRA_HNSWLIB OFF"
58+
"BUILD_CUVS_BENCH OFF"
59+
"BUILD_MG_ALGOS ${CUVS_BUILD_MG_ALGOS}"
60+
61+
)
62+
63+
if(cuvs_ADDED)
64+
message(VERBOSE "CUGRAPH: Using CUVS located in ${cuvs_SOURCE_DIR}")
65+
else()
66+
message(VERBOSE "CUGRAPH: Using CUVS located in ${cuvs_DIR}")
67+
endif()
68+
69+
70+
endfunction()
71+
72+
# Change pinned tag here to test a commit in CI
73+
# To use a different CUVS locally, set the CMake variable
74+
# CPM_cuvs_SOURCE=/path/to/local/cuvs
75+
find_and_configure_cuvs(VERSION ${CUGRAPH_MIN_VERSION_cuvs}
76+
FORK rapidsai
77+
PINNED_TAG branch-${CUGRAPH_BRANCH_VERSION_cuvs}
78+
EXCLUDE_FROM_ALL ${CUGRAPH_EXCLUDE_CUVS_FROM_ALL}
79+
# When PINNED_TAG above doesn't match CUGRAPH,
80+
# force local cuvs clone in build directory
81+
# even if it's already installed.
82+
CLONE_ON_PIN ${CUGRAPH_CUVS_CLONE_ON_PIN}
83+
COMPILE_LIBRARY ${CUGRAPH_CUVS_COMPILED}
84+
USE_CUVS_STATIC ${CUGRAPH_USE_CUVS_STATIC}
85+
)

0 commit comments

Comments
 (0)