Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 54 additions & 3 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ option(DISABLE_OPENMP "Disable OpenMP" OFF)
option(CUVS_COMPILE_DYNAMIC_ONLY "Only build the shared library and skip the static library." OFF)
option(CUVS_NVTX "Enable nvtx markers" OFF)
option(CUVS_RAFT_CLONE_ON_PIN "Explicitly clone RAFT branch when pinned to non-feature branch" ON)
option(CUVS_ENABLE_FLOWANN_SEARCH "Enable experimental FlowANN tiered-graph search" OFF)
option(CUVS_FLOWANN_USE_GDRCOPY "Use GDRCopy for FlowANN GPU-to-CPU command queues" ON)

if(CUVS_ENABLE_FLOWANN_SEARCH AND BUILD_CPU_ONLY)
message(FATAL_ERROR "CUVS_ENABLE_FLOWANN_SEARCH requires a CUDA-enabled build")
endif()
if(BUILD_CPU_ONLY)
set(BUILD_SHARED_LIBS OFF)
set(BUILD_TESTS OFF)
Expand Down Expand Up @@ -113,7 +118,6 @@ elseif(NOT BUILD_SHARED_LIBS)
set(cuvs_compile_mode "static_only")
set(_cuvs_lib_targets cuvs_static)
endif()

# Needed because GoogleBenchmark changes the state of FindThreads.cmake, causing subsequent runs to
# have different values for the `Threads::Threads` target. Setting this flag ensures
# `Threads::Threads` is the same value across all builds so that cache hits occur
Expand All @@ -127,6 +131,8 @@ message(VERBOSE "cuVS: Build cuVS unit-tests: ${BUILD_TESTS}")
message(VERBOSE "cuVS: Build CPU only components: ${BUILD_CPU_ONLY}")
message(VERBOSE "cuVS: Build ANN benchmarks: ${BUILD_CUVS_BENCH}")
message(VERBOSE "cuVS: Build only the shared library: ${CUVS_COMPILE_DYNAMIC_ONLY}")
message(VERBOSE "cuVS: Enable FlowANN tiered-graph search: ${CUVS_ENABLE_FLOWANN_SEARCH}")
message(VERBOSE "cuVS: Use GDRCopy for FlowANN queues: ${CUVS_FLOWANN_USE_GDRCOPY}")
message(VERBOSE "cuVS: Enable detection of conda environment for dependencies: ${DETECT_CONDA_ENV}")
message(VERBOSE "cuVS: Disable deprecation warnings " ${DISABLE_DEPRECATION_WARNINGS})
message(VERBOSE "cuVS: Disable OpenMP: ${DISABLE_OPENMP}")
Expand Down Expand Up @@ -169,6 +175,22 @@ if(NOT BUILD_CPU_ONLY)
BUILD_EXPORT_SET cuvs-exports
INSTALL_EXPORT_SET cuvs-exports
)

if(CUVS_ENABLE_FLOWANN_SEARCH AND CUVS_FLOWANN_USE_GDRCOPY)
rapids_find_generate_module(
GDRCopy
HEADER_NAMES gdrapi.h
LIBRARY_NAMES gdrapi
BUILD_EXPORT_SET cuvs-exports
INSTALL_EXPORT_SET cuvs-exports
)
rapids_find_package(
GDRCopy REQUIRED
BUILD_EXPORT_SET cuvs-exports
INSTALL_EXPORT_SET cuvs-exports
)
set(CUVS_FLOWANN_GDRCOPY_DEPENDENCIES GDRCopy::GDRCopy CUDA::cuda_driver)
endif()
else()
add_compile_definitions(BUILD_CPU_ONLY)
endif()
Expand Down Expand Up @@ -233,6 +255,9 @@ if(NOT BUILD_CPU_ONLY)
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
target_compile_definitions(
cuvs_cpp_headers INTERFACE $<$<BOOL:${CUVS_ENABLE_FLOWANN_SEARCH}>:CUVS_ENABLE_FLOWANN_SEARCH>
)
target_link_libraries(cuvs_cpp_headers INTERFACE raft::raft rmm::rmm)

generate_inst_matrix(
Expand Down Expand Up @@ -1486,6 +1511,8 @@ if(NOT BUILD_CPU_ONLY)
src/neighbors/brute_force.cu
src/neighbors/brute_force_serialize.cu
src/neighbors/cagra.cpp
$<$<BOOL:${CUVS_ENABLE_FLOWANN_SEARCH}>:src/neighbors/flowann.cu>
$<$<BOOL:${CUVS_ENABLE_FLOWANN_SEARCH}>:src/neighbors/flowann_queue.cpp>
${cagra_build_inst_files}
${cagra_extend_inst_files}
src/neighbors/cagra_optimize.cu
Expand Down Expand Up @@ -1592,6 +1619,12 @@ if(NOT BUILD_CPU_ONLY)
"$<$<AND:$<COMPILE_LANGUAGE:CUDA>,$<CONFIG:Debug>>:${CUVS_DEBUG_CUDA_FLAGS}>"
)

target_compile_definitions(
cuvs_objs
PRIVATE
$<$<AND:$<BOOL:${CUVS_ENABLE_FLOWANN_SEARCH}>,$<BOOL:${CUVS_FLOWANN_USE_GDRCOPY}>>:CUVS_FLOWANN_USE_GDRCOPY>
)

target_compile_definitions(
cuvs_objs
PRIVATE CUVS_CUTILE_ENABLED=${CUVS_CUTILE_ENABLED}
Expand All @@ -1608,6 +1641,7 @@ if(NOT BUILD_CPU_ONLY)
nvidia::cutlass::cutlass
rtcx::rtcx
${CUVS_CTK_MATH_DEPENDENCIES}
${CUVS_FLOWANN_GDRCOPY_DEPENDENCIES}
$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>
$<TARGET_NAME_IF_EXISTS:hnswlib::hnswlib>
kvikio::kvikio
Expand Down Expand Up @@ -1687,10 +1721,26 @@ if(NOT BUILD_CPU_ONLY)
$<BUILD_LOCAL_INTERFACE:$<TARGET_NAME_IF_EXISTS:NCCL::NCCL>>
$<BUILD_LOCAL_INTERFACE:$<TARGET_NAME_IF_EXISTS:hnswlib::hnswlib>>
$<$<BOOL:${CUVS_NVTX}>:CUDA::nvtx3>
PRIVATE $<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX> $<COMPILE_ONLY:nvidia::cutlass::cutlass>
$<COMPILE_ONLY:cuco::cuco> CUDA::nvJitLink CUDA::nvrtc rtcx::rtcx kvikio::kvikio
PRIVATE $<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>
$<COMPILE_ONLY:nvidia::cutlass::cutlass>
$<COMPILE_ONLY:cuco::cuco>
CUDA::nvJitLink
CUDA::nvrtc
rtcx::rtcx
kvikio::kvikio
${CUVS_FLOWANN_GDRCOPY_DEPENDENCIES}
INTERFACE $<LINK_ONLY:kvikio::kvikio>
)
if(CUVS_ENABLE_FLOWANN_SEARCH)
target_link_libraries(cuvs INTERFACE $<LINK_ONLY:$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>>)
endif()
if(CUVS_ENABLE_FLOWANN_SEARCH AND CUVS_FLOWANN_USE_GDRCOPY)
# Consumers must resolve this runtime dependency even when it is installed outside the
# linker's default search paths. Its headers remain private to the queue implementation.
target_link_libraries(
cuvs INTERFACE $<LINK_ONLY:GDRCopy::GDRCopy> $<LINK_ONLY:CUDA::cuda_driver>
)
endif()

endif()

Expand Down Expand Up @@ -1735,6 +1785,7 @@ if(NOT BUILD_CPU_ONLY)
CUDA::nvJitLink
CUDA::nvrtc
rtcx::rtcx
${CUVS_FLOWANN_GDRCOPY_DEPENDENCIES}
$<$<BOOL:${CUVS_NVTX}>:CUDA::nvtx3>
$<COMPILE_ONLY:nvidia::cutlass::cutlass>
$<COMPILE_ONLY:cuco::cuco>
Expand Down
Loading
Loading