Skip to content

Commit

Permalink
Fix cmake export and template project
Browse files Browse the repository at this point in the history
  • Loading branch information
lowener committed Jan 24, 2024
1 parent 5b59a52 commit 2bfe42d
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 182 deletions.
4 changes: 2 additions & 2 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ SECTIONS

if(CUVS_NVTX)
# This enables NVTX within the project with no option to disable it downstream.
target_link_libraries(cuvs PUBLIC CUDA::nvToolsExt)
target_link_libraries(cuvs PUBLIC CUDA::nvtx3)
target_compile_definitions(cuvs PUBLIC NVTX_ENABLED)
else()
# Allow enable NVTX downstream if not set here. This creates a new option at build/install time,
Expand All @@ -263,7 +263,7 @@ else()
"\" OFF)"
[=[

target_link_libraries(cuvs::cuvs INTERFACE $<$<BOOL:${CUVS_NVTX}>:CUDA::nvToolsExt>)
target_link_libraries(cuvs::cuvs INTERFACE $<$<BOOL:${CUVS_NVTX}>:CUDA::nvtx3>)
target_compile_definitions(cuvs::cuvs INTERFACE $<$<BOOL:${CUVS_NVTX}>:NVTX_ENABLED>)

]=]
Expand Down
4 changes: 2 additions & 2 deletions cpp/cmake/thirdparty/get_raft.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ function(find_and_configure_raft)
#-----------------------------------------------------
rapids_cpm_find(raft ${PKG_VERSION}
GLOBAL_TARGETS raft::raft
BUILD_EXPORT_SET cuvs-template-exports
INSTALL_EXPORT_SET cuvs-template-exports
BUILD_EXPORT_SET cuvs-exports
INSTALL_EXPORT_SET cuvs-exports
COMPONENTS ${RAFT_COMPONENTS}
CPM_ARGS
GIT_REPOSITORY https://github.com/${PKG_FORK}/raft.git
Expand Down
7 changes: 2 additions & 5 deletions cpp/template/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =============================================================================
# Copyright (c) 2023, NVIDIA CORPORATION.
# Copyright (c) 2023-2024, 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
Expand Down Expand Up @@ -35,7 +35,4 @@ include(cmake/thirdparty/get_cuvs.cmake)

# -------------- compile tasks ----------------- #
add_executable(CAGRA_EXAMPLE src/cagra_example.cu)
target_link_libraries(CAGRA_EXAMPLE PRIVATE cuvs::cuvs cuvs::compiled)

add_executable(IVF_FLAT_EXAMPLE src/ivf_flat_example.cu)
target_link_libraries(IVF_FLAT_EXAMPLE PRIVATE cuvs::cuvs cuvs::compiled)
target_link_libraries(CAGRA_EXAMPLE PRIVATE cuvs::cuvs)
4 changes: 2 additions & 2 deletions cpp/template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ This directory (`CUVS_SOURCE/cpp/template`) can be copied directly in order to b

CUVS can be integrated into an existing CMake project by copying the contents in the `configure rapids-cmake` and `configure cuvs` sections of the provided `CMakeLists.txt` into your project, along with `cmake/thirdparty/get_cuvs.cmake`.

Make sure to link against the appropriate Cmake targets. Use `cuvs::cuvs`to add make the headers available and `cuvs::compiled` when utilizing the shared library.
Make sure to link against the appropriate Cmake targets. Use `cuvs::cuvs` to utilize the shared library.

```cmake
target_link_libraries(your_app_target PRIVATE cuvs::cuvs cuvs::compiled)
target_link_libraries(your_app_target PRIVATE cuvs::cuvs)
```

11 changes: 3 additions & 8 deletions cpp/template/cmake/thirdparty/get_cuvs.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =============================================================================
# Copyright (c) 2023, NVIDIA CORPORATION.
# Copyright (c) 2023-2024, 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
Expand All @@ -17,7 +17,7 @@ set(CUVS_FORK "rapidsai")
set(CUVS_PINNED_TAG "branch-${RAPIDS_VERSION}")

function(find_and_configure_cuvs)
set(oneValueArgs VERSION FORK PINNED_TAG COMPILE_LIBRARY ENABLE_NVTX ENABLE_MNMG_DEPENDENCIES)
set(oneValueArgs VERSION FORK PINNED_TAG COMPILE_LIBRARY ENABLE_NVTX)
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )

Expand All @@ -26,10 +26,6 @@ function(find_and_configure_cuvs)
string(APPEND CUVS_COMPONENTS " compiled")
endif()

if(PKG_ENABLE_MNMG_DEPENDENCIES)
string(APPEND CUVS_COMPONENTS " distributed")
endif()

#-----------------------------------------------------
# Invoke CPM find_package()
#-----------------------------------------------------
Expand All @@ -46,7 +42,7 @@ function(find_and_configure_cuvs)
"BUILD_TESTS OFF"
"BUILD_PRIMS_BENCH OFF"
"BUILD_ANN_BENCH OFF"
"CUVS_NVTX ${ENABLE_NVTX}"
"CUVS_NVTX ${PKG_ENABLE_NVTX}"
"CUVS_COMPILE_LIBRARY ${PKG_COMPILE_LIBRARY}"
)
endfunction()
Expand All @@ -58,6 +54,5 @@ find_and_configure_cuvs(VERSION ${CUVS_VERSION}.00
FORK ${CUVS_FORK}
PINNED_TAG ${CUVS_PINNED_TAG}
COMPILE_LIBRARY ON
ENABLE_MNMG_DEPENDENCIES OFF
ENABLE_NVTX OFF
)
5 changes: 2 additions & 3 deletions cpp/template/src/cagra_example.cu
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void cagra_build_search_simple(raft::device_resources const& dev_resources,
cagra::index_params index_params;

std::cout << "Building CAGRA index (search graph)" << std::endl;
auto index = cagra::build<float, uint32_t>(dev_resources, index_params, dataset);
auto index = cagra::build(dev_resources, index_params, dataset);

std::cout << "CAGRA index has " << index.size() << " vectors" << std::endl;
std::cout << "CAGRA graph has degree " << index.graph_degree() << ", graph size ["
Expand All @@ -52,8 +52,7 @@ void cagra_build_search_simple(raft::device_resources const& dev_resources,
// use default search parameters
cagra::search_params search_params;
// search K nearest neighbors
cagra::search<float, uint32_t>(
dev_resources, search_params, index, queries, neighbors.view(), distances.view());
cagra::search(dev_resources, search_params, index, queries, neighbors.view(), distances.view());

// The call to ivf_flat::search is asynchronous. Before accessing the data, sync by calling
// raft::resource::sync_stream(dev_resources);
Expand Down
160 changes: 0 additions & 160 deletions cpp/template/src/ivf_flat_example.cu

This file was deleted.

0 comments on commit 2bfe42d

Please sign in to comment.