Skip to content

Commit

Permalink
Update to use rapids-cmake for all deps
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmaynard committed Jan 16, 2024
1 parent 0c75bb1 commit 0bae5db
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 108 deletions.
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
3 changes: 3 additions & 0 deletions cpp/cmake/patches/ggnn.patch
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,6 @@ index 49d76a1..eef69e6 100644
#include <cub/cub.cuh>

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

3 changes: 3 additions & 0 deletions cpp/cmake/patches/hnswlib.patch
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,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.

57 changes: 35 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,43 @@
#=============================================================================

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 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/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)
set(patch_script "${CMAKE_BINARY_DIR}/rapids-cmake/patches/${package_name}/patch.cmake")
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 "${patch_command}"
)
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}
)
65 changes: 33 additions & 32 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,41 @@
#=============================================================================

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)
set(patch_script "${CMAKE_BINARY_DIR}/rapids-cmake/patches/${package_name}/patch.cmake")
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 )

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 ()
rapids_cpm_find(
hnswlib ${PKG_VERSION}
GLOBAL_TARGETS hnswlib::hnswlib
CPM_ARGS
GIT_REPOSITORY ${PKG_REPOSITORY}
GIT_TAG ${PKG_PINNED_TAG}
GIT_SHALLOW TRUE
EXCLUDE_FROM_ALL ${PKG_EXCLUDE_FROM_ALL}
PATCH_COMMAND "${patch_command}"
)
if(NOT TARGET hnswlib::hnswlib)
add_library(hnswlib::hnswlib ALIAS hnswlib)
endif()
endfunction()

include(cmake/modules/FindAVX.cmake)

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}")
endif()
endfunction()
if(NOT RAFT_HNSWLIB_GIT_TAG)
set(RAFT_HNSWLIB_GIT_TAG v0.6.2)
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_hnswlib(VERSION 0.6.2
FORK nmslib
PINNED_TAG v0.6.2
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 YES)

0 comments on commit 0bae5db

Please sign in to comment.