Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to use rapids-cmake for all deps #2096

Merged
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
19 changes: 9 additions & 10 deletions cpp/bench/ann/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 @@ -136,7 +136,7 @@ endif()
function(ConfigureAnnBench)

set(oneValueArgs NAME)
set(multiValueArgs PATH LINKS CXXFLAGS INCLUDES)
set(multiValueArgs PATH LINKS CXXFLAGS)

if(NOT BUILD_CPU_ONLY)
set(GPU_BUILD ON)
Expand Down Expand Up @@ -225,9 +225,11 @@ endfunction()

if(RAFT_ANN_BENCH_USE_HNSWLIB)
ConfigureAnnBench(
NAME HNSWLIB PATH bench/ann/src/hnswlib/hnswlib_benchmark.cpp INCLUDES
${CMAKE_CURRENT_BINARY_DIR}/_deps/hnswlib-src/hnswlib CXXFLAGS "${HNSW_CXX_FLAGS}"
NAME HNSWLIB PATH bench/ann/src/hnswlib/hnswlib_benchmark.cpp
LINKS
hnswlib::hnswlib
)

endif()

if(RAFT_ANN_BENCH_USE_RAFT_IVF_PQ)
Expand Down Expand Up @@ -278,12 +280,9 @@ if(RAFT_ANN_BENCH_USE_RAFT_CAGRA_HNSWLIB)
RAFT_CAGRA_HNSWLIB
PATH
bench/ann/src/raft/raft_cagra_hnswlib.cu
INCLUDES
${CMAKE_CURRENT_BINARY_DIR}/_deps/hnswlib-src/hnswlib
LINKS
raft::compiled
CXXFLAGS
"${HNSW_CXX_FLAGS}"
hnswlib::hnswlib
)
endif()

Expand Down Expand Up @@ -338,8 +337,8 @@ endif()
if(RAFT_ANN_BENCH_USE_GGNN)
include(cmake/thirdparty/get_glog.cmake)
ConfigureAnnBench(
NAME GGNN PATH bench/ann/src/ggnn/ggnn_benchmark.cu INCLUDES
${CMAKE_CURRENT_BINARY_DIR}/_deps/ggnn-src/include LINKS glog::glog
NAME GGNN PATH bench/ann/src/ggnn/ggnn_benchmark.cu
LINKS glog::glog ggnn::ggnn
)
endif()

Expand Down
4 changes: 2 additions & 2 deletions cpp/bench/ann/src/hnswlib/hnswlib_wrapper.h
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.
Expand Down Expand Up @@ -33,7 +33,7 @@

#include "../common/ann_types.hpp"
#include "../common/thread_pool.hpp"
#include <hnswlib.h>
#include <hnswlib/hnswlib.h>

namespace raft::bench::ann {

Expand Down
4 changes: 2 additions & 2 deletions cpp/bench/ann/src/raft/raft_benchmark.cu
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.
Expand Down Expand Up @@ -44,7 +44,7 @@ std::unique_ptr<raft::bench::ann::ANN<T>> create_algo(const std::string& algo,
// stop compiler warning; not all algorithms support multi-GPU so it may not be used
(void)dev_list;

raft::bench::ann::Metric metric = parse_metric(distance);
[[maybe_unused]] raft::bench::ann::Metric metric = parse_metric(distance);
std::unique_ptr<raft::bench::ann::ANN<T>> ann;

if constexpr (std::is_same_v<T, float>) {
Expand Down
4 changes: 2 additions & 2 deletions cpp/bench/ann/src/raft/raft_cagra_hnswlib.cu
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.
Expand Down Expand Up @@ -43,7 +43,7 @@ std::unique_ptr<raft::bench::ann::ANN<T>> create_algo(const std::string& algo,
// stop compiler warning; not all algorithms support multi-GPU so it may not be used
(void)dev_list;

raft::bench::ann::Metric metric = parse_metric(distance);
[[maybe_unused]] raft::bench::ann::Metric metric = parse_metric(distance);
std::unique_ptr<raft::bench::ann::ANN<T>> ann;

if constexpr (std::is_same_v<T, float> or std::is_same_v<T, std::uint8_t>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
diff --git a/include/ggnn/cache/cuda_simple_knn_sym_cache.cuh b/include/ggnn/cache/cuda_simple_knn_sym_cache.cuh
index 890420e..d792903 100644
--- a/include/ggnn/cache/cuda_simple_knn_sym_cache.cuh
+++ b/include/ggnn/cache/cuda_simple_knn_sym_cache.cuh
@@ -62,7 +62,7 @@ struct SimpleKNNSymCache {
Expand Down Expand Up @@ -227,3 +225,6 @@ index 49d76a1..eef69e6 100644
#include <cub/cub.cuh>

#include "ggnn/utils/cuda_knn_constants.cuh"
--
2.43.0

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
diff --git a/hnswlib/hnswalg.h b/hnswlib/hnswalg.h
index e95e0b5..f0fe50a 100644
--- a/hnswlib/hnswalg.h
+++ b/hnswlib/hnswalg.h
@@ -3,6 +3,7 @@
Expand Down Expand Up @@ -128,3 +126,6 @@ index 5e1a4a5..4195ebd 100644
numelements = numelements1;
mass = new vl_type[numelements];
}
--
2.43.0

38 changes: 0 additions & 38 deletions cpp/cmake/patches/nlohmann_json.patch

This file was deleted.

58 changes: 36 additions & 22 deletions cpp/cmake/thirdparty/get_ggnn.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.
Expand All @@ -15,30 +15,44 @@
#=============================================================================

function(find_and_configure_ggnn)
set(oneValueArgs VERSION FORK PINNED_TAG EXCLUDE_FROM_ALL)
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )
set(oneValueArgs VERSION REPOSITORY PINNED_TAG)
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )

set ( EXTERNAL_INCLUDES_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ )
if (NOT EXISTS ${EXTERNAL_INCLUDES_DIRECTORY}/_deps/ggnn-src/)

execute_process (
COMMAND git clone "https://github.com/${PKG_FORK}/ggnn" --branch ${PKG_PINNED_TAG} ggnn-src
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/_deps/ )
set(patch_files_to_run "${CMAKE_CURRENT_SOURCE_DIR}/cmake/patches/ggnn.diff")
set(patch_issues_to_ref "fix compile issues")
set(patch_script "${CMAKE_BINARY_DIR}/rapids-cmake/patches/ggnn/patch.cmake")
set(log_file "${CMAKE_BINARY_DIR}/rapids-cmake/patches/ggnn/log")
string(TIMESTAMP current_year "%Y" UTC)
configure_file(${rapids-cmake-dir}/cpm/patches/command_template.cmake.in "${patch_script}"
@ONLY)

message("SOURCE ${CMAKE_CURRENT_SOURCE_DIR}")
execute_process (
COMMAND git apply ${CMAKE_CURRENT_SOURCE_DIR}/cmake/patches/ggnn.patch
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/_deps/ggnn-src
)
endif()
rapids_cpm_find(
ggnn ${PKG_VERSION}
GLOBAL_TARGETS ggnn::ggnn
CPM_ARGS
GIT_REPOSITORY ${PKG_REPOSITORY}
GIT_TAG ${PKG_PINNED_TAG}
GIT_SHALLOW TRUE
DOWNLOAD_ONLY ON
PATCH_COMMAND ${CMAKE_COMMAND} -P ${patch_script}
)
if(NOT TARGET ggnn::ggnn)
add_library(ggnn INTERFACE)
target_include_directories(ggnn INTERFACE "$<BUILD_INTERFACE:${ggnn_SOURCE_DIR}/include>")
add_library(ggnn::ggnn ALIAS ggnn)
endif()

endfunction()
if(NOT RAFT_GGNN_GIT_TAG)
set(RAFT_GGNN_GIT_TAG release_0.5)
endif()

# Change pinned tag here to test a commit in CI
# To use a different RAFT locally, set the CMake variable
# CPM_raft_SOURCE=/path/to/local/raft
find_and_configure_ggnn(VERSION 0.5
FORK cgtuebingen
PINNED_TAG release_0.5
EXCLUDE_FROM_ALL YES)
if(NOT RAFT_GGNN_GIT_REPOSITORY)
set(RAFT_GGNN_GIT_REPOSITORY https://github.com/cgtuebingen/ggnn.git)
endif()
find_and_configure_ggnn(VERSION 0.5
REPOSITORY ${RAFT_GGNN_GIT_REPOSITORY}
PINNED_TAG ${RAFT_GGNN_GIT_TAG}
)
86 changes: 55 additions & 31 deletions cpp/cmake/thirdparty/get_hnswlib.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.
Expand All @@ -15,40 +15,64 @@
#=============================================================================

function(find_and_configure_hnswlib)
set(oneValueArgs VERSION FORK PINNED_TAG EXCLUDE_FROM_ALL)
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )
set(oneValueArgs VERSION REPOSITORY PINNED_TAG EXCLUDE_FROM_ALL)
cmake_parse_arguments(PKG "${options}" "${oneValueArgs}"
"${multiValueArgs}" ${ARGN} )

set ( EXTERNAL_INCLUDES_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
if( NOT EXISTS ${EXTERNAL_INCLUDES_DIRECTORY}/_deps/hnswlib-src )
set(patch_files_to_run "${CMAKE_CURRENT_SOURCE_DIR}/cmake/patches/hnswlib.diff")
set(patch_issues_to_ref "fix compile issues")
set(patch_script "${CMAKE_BINARY_DIR}/rapids-cmake/patches/hnswlib/patch.cmake")
set(log_file "${CMAKE_BINARY_DIR}/rapids-cmake/patches/hnswlib/log")
string(TIMESTAMP current_year "%Y" UTC)
configure_file(${rapids-cmake-dir}/cpm/patches/command_template.cmake.in "${patch_script}"
@ONLY)

execute_process (
COMMAND git clone --branch=v0.6.2 https://github.com/nmslib/hnswlib.git hnswlib-src
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/_deps )
rapids_cpm_find(
hnswlib ${PKG_VERSION}
GLOBAL_TARGETS hnswlib::hnswlib
CPM_ARGS
GIT_REPOSITORY ${PKG_REPOSITORY}
GIT_TAG ${PKG_PINNED_TAG}
GIT_SHALLOW TRUE
DOWNLOAD_ONLY ON
PATCH_COMMAND ${CMAKE_COMMAND} -P ${patch_script}
)
if(NOT TARGET hnswlib::hnswlib)
add_library(hnswlib INTERFACE )
add_library(hnswlib::hnswlib ALIAS hnswlib)
target_include_directories(hnswlib INTERFACE
"$<BUILD_INTERFACE:${hnswlib_SOURCE_DIR}>"
"$<INSTALL_INTERFACE:include>")

message("SOURCE ${CMAKE_CURRENT_SOURCE_DIR}")
execute_process (
COMMAND git apply ${CMAKE_CURRENT_SOURCE_DIR}/cmake/patches/hnswlib.patch
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/_deps/hnswlib-src
)
endif ()

include(cmake/modules/FindAVX.cmake)
if(NOT PKG_EXCLUDE_FROM_ALL)
install(TARGETS hnswlib EXPORT hnswlib-exports)
install(DIRECTORY "${hnswlib_SOURCE_DIR}/hnswlib/" DESTINATION include/hnswlib)

set(HNSW_CXX_FLAGS "")
if(CXX_AVX_FOUND)
set(HNSW_CXX_FLAGS "${HNSW_CXX_FLAGS} ${CXX_AVX_FLAGS}")
elseif(CXX_AVX2_FOUND)
set(HNSW_CXX_FLAGS "${HNSW_CXX_FLAGS} ${CXX_AVX2_FLAGS}")
elseif(CXX_AVX512_FOUND)
set(HNSW_CXX_FLAGS "${HNSW_CXX_FLAGS} ${CXX_AVX512_FLAGS}")
# write export rules
rapids_export(
BUILD hnswlib
EXPORT_SET hnswlib-exports
GLOBAL_TARGETS hnswlib
NAMESPACE hnswlib::)
rapids_export(
INSTALL hnswlib
EXPORT_SET hnswlib-exports
GLOBAL_TARGETS hnswlib
NAMESPACE hnswlib::)
endif()
endif()
endfunction()

# Change pinned tag here to test a commit in CI
# To use a different RAFT locally, set the CMake variable
# CPM_raft_SOURCE=/path/to/local/raft
find_and_configure_hnswlib(VERSION 0.6.2
FORK nmslib
PINNED_TAG v0.6.2
EXCLUDE_FROM_ALL YES)

if(NOT RAFT_HNSWLIB_GIT_TAG)
set(RAFT_HNSWLIB_GIT_TAG v0.6.2)
endif()

if(NOT RAFT_HNSWLIB_GIT_REPOSITORY)
set(RAFT_HNSWLIB_GIT_REPOSITORY https://github.com/nmslib/hnswlib.git)
endif()
find_and_configure_hnswlib(VERSION 0.6.2
REPOSITORY ${RAFT_HNSWLIB_GIT_REPOSITORY}
PINNED_TAG ${RAFT_HNSWLIB_GIT_TAG}
EXCLUDE_FROM_ALL ON
)