diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 86b555dd62..d8ba929321 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -1072,6 +1072,7 @@ if(NOT BUILD_CPU_ONLY) CUDA_STANDARD_REQUIRED ON POSITION_INDEPENDENT_CODE ON CXX_VISIBILITY_PRESET hidden + CUDA_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON ) target_compile_options( diff --git a/cpp/include/cuvs/core/cuda_fp16.hpp b/cpp/include/cuvs/core/cuda_fp16.hpp new file mode 100644 index 0000000000..3cdbe76d10 --- /dev/null +++ b/cpp/include/cuvs/core/cuda_fp16.hpp @@ -0,0 +1,18 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION. + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +// Wrapper for cuda_fp16.h that ensures __half gets default symbol visibility. +// +// GCC's "type visibility" rule causes template instantiations over __half to +// inherit hidden visibility when -fvisibility=hidden is in effect, because +// __half is a user-defined type first seen under hidden visibility. By +// including cuda_fp16.h under #pragma GCC visibility push(default), the __half +// type acquires default visibility, and downstream template instantiations +// (e.g., index<__half, ...>) will be properly exported from shared libraries. +#pragma GCC visibility push(default) +#include // NOLINT +#pragma GCC visibility pop diff --git a/cpp/include/cuvs/distance/distance.hpp b/cpp/include/cuvs/distance/distance.hpp index 3dd273696e..255e548203 100644 --- a/cpp/include/cuvs/distance/distance.hpp +++ b/cpp/include/cuvs/distance/distance.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include +#include #include #include #include diff --git a/cpp/include/cuvs/neighbors/brute_force.hpp b/cpp/include/cuvs/neighbors/brute_force.hpp index 9d690f8f89..635447d0ed 100644 --- a/cpp/include/cuvs/neighbors/brute_force.hpp +++ b/cpp/include/cuvs/neighbors/brute_force.hpp @@ -12,7 +12,7 @@ #include #include -#include +#include #include namespace CUVS_EXPORT cuvs { @@ -35,7 +35,7 @@ struct search_params : cuvs::neighbors::search_params {}; * @tparam T data element type */ template -struct index : cuvs::neighbors::index { +struct CUVS_EXPORT index : cuvs::neighbors::index { using index_params_type = brute_force::index_params; using search_params_type = brute_force::search_params; using index_type = int64_t; @@ -166,6 +166,7 @@ struct index : cuvs::neighbors::index { raft::device_matrix_view dataset_view_; DistT metric_arg_; }; + /** * @} */ diff --git a/cpp/include/cuvs/neighbors/cagra.hpp b/cpp/include/cuvs/neighbors/cagra.hpp index 6a5d15bc59..8edbcab8fa 100644 --- a/cpp/include/cuvs/neighbors/cagra.hpp +++ b/cpp/include/cuvs/neighbors/cagra.hpp @@ -391,7 +391,7 @@ static_assert(std::is_aggregate_v); * */ template -struct index : cuvs::neighbors::index { +struct CUVS_EXPORT index : cuvs::neighbors::index { using index_params_type = cagra::index_params; using search_params_type = cagra::search_params; using index_type = IdxT; @@ -883,6 +883,7 @@ struct index : cuvs::neighbors::index { size_t dim_ = 0; size_t graph_degree_ = 0; }; + /** * @} */ diff --git a/cpp/include/cuvs/neighbors/common.hpp b/cpp/include/cuvs/neighbors/common.hpp index 7569ee2508..887593c23b 100644 --- a/cpp/include/cuvs/neighbors/common.hpp +++ b/cpp/include/cuvs/neighbors/common.hpp @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -27,7 +28,6 @@ #ifdef __cpp_lib_bitops #include -#include #endif namespace CUVS_EXPORT cuvs { @@ -811,11 +811,11 @@ using enable_if_valid_list_t = typename enable_if_valid_list::type; * `cuvs::neighbors::ivf_pq::helpers::resize_list` which handle type casting internally. */ template -void resize_list(raft::resources const& res, - std::shared_ptr& orig_list, // NOLINT - const typename ListT::spec_type& spec, - typename ListT::size_type new_used_size, - typename ListT::size_type old_used_size); +CUVS_EXPORT void resize_list(raft::resources const& res, + std::shared_ptr& orig_list, // NOLINT + const typename ListT::spec_type& spec, + typename ListT::size_type new_used_size, + typename ListT::size_type old_used_size); /** * Serialize a list to an output stream. diff --git a/cpp/include/cuvs/neighbors/composite/index.hpp b/cpp/include/cuvs/neighbors/composite/index.hpp index e7b7f9a872..d7970a5cd6 100644 --- a/cpp/include/cuvs/neighbors/composite/index.hpp +++ b/cpp/include/cuvs/neighbors/composite/index.hpp @@ -41,7 +41,7 @@ namespace composite { * @endcode */ template -class composite_index { +class CUVS_EXPORT composite_index { public: using value_type = T; using index_type = IdxT; diff --git a/cpp/include/cuvs/neighbors/ivf_flat.hpp b/cpp/include/cuvs/neighbors/ivf_flat.hpp index a8fb4f49be..6ab31faf82 100644 --- a/cpp/include/cuvs/neighbors/ivf_flat.hpp +++ b/cpp/include/cuvs/neighbors/ivf_flat.hpp @@ -3576,4 +3576,5 @@ __device__ __forceinline__ void compute_dist_udf_impl(AccT& acc, AccT x, AccT y) } // namespace ivf_flat } // namespace neighbors + } // namespace CUVS_EXPORT cuvs diff --git a/cpp/include/cuvs/neighbors/ivf_pq.hpp b/cpp/include/cuvs/neighbors/ivf_pq.hpp index d83412038a..43fec40bf1 100644 --- a/cpp/include/cuvs/neighbors/ivf_pq.hpp +++ b/cpp/include/cuvs/neighbors/ivf_pq.hpp @@ -5,7 +5,7 @@ #pragma once -#include +#include #include diff --git a/cpp/include/cuvs/neighbors/nn_descent.hpp b/cpp/include/cuvs/neighbors/nn_descent.hpp index 7698038c8c..1586505039 100644 --- a/cpp/include/cuvs/neighbors/nn_descent.hpp +++ b/cpp/include/cuvs/neighbors/nn_descent.hpp @@ -16,7 +16,7 @@ #include -#include +#include #include namespace CUVS_EXPORT cuvs { diff --git a/cpp/include/cuvs/preprocessing/quantize/binary.hpp b/cpp/include/cuvs/preprocessing/quantize/binary.hpp index 29861f8ab9..108c222365 100644 --- a/cpp/include/cuvs/preprocessing/quantize/binary.hpp +++ b/cpp/include/cuvs/preprocessing/quantize/binary.hpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include namespace CUVS_EXPORT cuvs { diff --git a/cpp/include/cuvs/preprocessing/quantize/scalar.hpp b/cpp/include/cuvs/preprocessing/quantize/scalar.hpp index 016ebd5dc5..9cb0afb537 100644 --- a/cpp/include/cuvs/preprocessing/quantize/scalar.hpp +++ b/cpp/include/cuvs/preprocessing/quantize/scalar.hpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include namespace CUVS_EXPORT cuvs { diff --git a/cpp/include/cuvs/selection/select_k.hpp b/cpp/include/cuvs/selection/select_k.hpp index 415a3d7099..c9c6332997 100644 --- a/cpp/include/cuvs/selection/select_k.hpp +++ b/cpp/include/cuvs/selection/select_k.hpp @@ -5,7 +5,7 @@ #pragma once -#include +#include #include #include diff --git a/cpp/src/neighbors/brute_force.cu b/cpp/src/neighbors/brute_force.cu index 9966c692a8..2f9000acf7 100644 --- a/cpp/src/neighbors/brute_force.cu +++ b/cpp/src/neighbors/brute_force.cu @@ -1,15 +1,19 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ +#include + #include "./detail/knn_brute_force.cuh" #include #include -namespace cuvs::neighbors::brute_force { +namespace CUVS_EXPORT cuvs { +namespace neighbors { +namespace brute_force { template index::index(raft::resources const& res) @@ -227,13 +231,16 @@ void index::update_dataset( { \ detail::search( \ res, idx, queries, neighbors, distances, sample_filter); \ - } \ - \ - template struct cuvs::neighbors::brute_force::index; + } CUVS_INST_BFKNN(float, float); CUVS_INST_BFKNN(half, float); +template class cuvs::neighbors::brute_force::index; +template class cuvs::neighbors::brute_force::index; + #undef CUVS_INST_BFKNN -} // namespace cuvs::neighbors::brute_force +} // namespace brute_force +} // namespace neighbors +} // namespace CUVS_EXPORT cuvs diff --git a/cpp/src/neighbors/cagra_build_inst.cu.in b/cpp/src/neighbors/cagra_build_inst.cu.in index 86ee6a0d2d..00e0fab327 100644 --- a/cpp/src/neighbors/cagra_build_inst.cu.in +++ b/cpp/src/neighbors/cagra_build_inst.cu.in @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include + #include #include @@ -39,4 +41,6 @@ auto build(raft::resources const& handle, return cuvs::neighbors::cagra::build(handle, params, dataset); } +template struct index; + } // namespace cuvs::neighbors::cagra diff --git a/cpp/src/neighbors/cagra_extend_inst.cu.in b/cpp/src/neighbors/cagra_extend_inst.cu.in index 265c2761df..d544789713 100644 --- a/cpp/src/neighbors/cagra_extend_inst.cu.in +++ b/cpp/src/neighbors/cagra_extend_inst.cu.in @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include + #include #include diff --git a/cpp/src/neighbors/cagra_merge_inst.cu.in b/cpp/src/neighbors/cagra_merge_inst.cu.in index c2a1dbcce5..2fafb37ae4 100644 --- a/cpp/src/neighbors/cagra_merge_inst.cu.in +++ b/cpp/src/neighbors/cagra_merge_inst.cu.in @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include + #include #include diff --git a/cpp/src/neighbors/cagra_serialize_inst.cu.in b/cpp/src/neighbors/cagra_serialize_inst.cu.in index 4a9f48241d..4b14ee72f4 100644 --- a/cpp/src/neighbors/cagra_serialize_inst.cu.in +++ b/cpp/src/neighbors/cagra_serialize_inst.cu.in @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include + #include namespace { diff --git a/cpp/src/neighbors/composite/index.cu b/cpp/src/neighbors/composite/index.cu index 7c02d0e43e..4b9150ba01 100644 --- a/cpp/src/neighbors/composite/index.cu +++ b/cpp/src/neighbors/composite/index.cu @@ -111,13 +111,13 @@ void composite_index::search( cuvs::selection::SelectAlgo::kAuto); } -template class composite_index; -template class composite_index; -template class composite_index; -template class composite_index; -template class composite_index; -template class composite_index; -template class composite_index; -template class composite_index; +template class CUVS_EXPORT composite_index; +template class CUVS_EXPORT composite_index; +template class CUVS_EXPORT composite_index; +template class CUVS_EXPORT composite_index; +template class CUVS_EXPORT composite_index; +template class CUVS_EXPORT composite_index; +template class CUVS_EXPORT composite_index; +template class CUVS_EXPORT composite_index; } // namespace cuvs::neighbors::composite diff --git a/cpp/src/neighbors/detail/nn_descent_gnnd.hpp b/cpp/src/neighbors/detail/nn_descent_gnnd.hpp index a2639e4f43..39e3075e7e 100644 --- a/cpp/src/neighbors/detail/nn_descent_gnnd.hpp +++ b/cpp/src/neighbors/detail/nn_descent_gnnd.hpp @@ -151,7 +151,7 @@ class BloomFilter { }; template -struct GnndGraph { +struct CUVS_EXPORT GnndGraph { raft::resources const& res; static constexpr int segment_size = 32; InternalID_t* h_graph; @@ -192,7 +192,7 @@ struct GnndGraph { }; template -class GNND { +class CUVS_EXPORT GNND { public: GNND(raft::resources const& res, const BuildConfig& build_config); GNND(const GNND&) = delete; diff --git a/cpp/src/neighbors/dynamic_batching.cu b/cpp/src/neighbors/dynamic_batching.cu index d8a705652a..cfbef44409 100644 --- a/cpp/src/neighbors/dynamic_batching.cu +++ b/cpp/src/neighbors/dynamic_batching.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -21,7 +21,7 @@ namespace cuvs::neighbors::dynamic_batching { #define CUVS_INST_DYNAMIC_BATCHING_INDEX(T, IdxT, Namespace, ...) \ template <> \ template <> \ - index::index( \ + CUVS_EXPORT index::index( \ const raft::resources& res, \ const cuvs::neighbors::dynamic_batching::index_params& params, \ const Namespace ::__VA_ARGS__& upstream_index, \ diff --git a/cpp/src/neighbors/ivf_flat/ivf_flat_build_extend_inst.cu.in b/cpp/src/neighbors/ivf_flat/ivf_flat_build_extend_inst.cu.in index c3bf80bde7..eb8143925c 100644 --- a/cpp/src/neighbors/ivf_flat/ivf_flat_build_extend_inst.cu.in +++ b/cpp/src/neighbors/ivf_flat/ivf_flat_build_extend_inst.cu.in @@ -3,6 +3,8 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include + #include #include @@ -84,3 +86,14 @@ void extend(raft::resources const& handle, } } // namespace cuvs::neighbors::ivf_flat + +namespace cuvs::neighbors::ivf { + +template void resize_list>( + raft::resources const&, + std::shared_ptr>&, + const list::spec_type&, + list::size_type, + list::size_type); + +} // namespace cuvs::neighbors::ivf diff --git a/cpp/src/neighbors/ivf_flat/ivf_flat_helpers.cu b/cpp/src/neighbors/ivf_flat/ivf_flat_helpers.cu index c5f8db6e9d..405eee21bd 100644 --- a/cpp/src/neighbors/ivf_flat/ivf_flat_helpers.cu +++ b/cpp/src/neighbors/ivf_flat/ivf_flat_helpers.cu @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ #include #include "../ivf_common.cuh" +#include "../ivf_list.cuh" #include "ivf_flat_helpers.cuh" #include @@ -206,3 +207,15 @@ void recompute_internal_state(const raft::resources& res, index>( + raft::resources const&, + std::shared_ptr>&, + const list::spec_type&, + list::size_type, + list::size_type); + +} // namespace cuvs::neighbors::ivf diff --git a/cpp/src/neighbors/ivf_list.cuh b/cpp/src/neighbors/ivf_list.cuh index d8704c7b89..24691463ff 100644 --- a/cpp/src/neighbors/ivf_list.cuh +++ b/cpp/src/neighbors/ivf_list.cuh @@ -62,11 +62,11 @@ list::list(raft::resources const& res, } template -void resize_list(raft::resources const& res, - std::shared_ptr& orig_list, // NOLINT - const typename ListT::spec_type& spec, - typename ListT::size_type new_used_size, - typename ListT::size_type old_used_size) +CUVS_EXPORT void resize_list(raft::resources const& res, + std::shared_ptr& orig_list, // NOLINT + const typename ListT::spec_type& spec, + typename ListT::size_type new_used_size, + typename ListT::size_type old_used_size) { bool skip_resize = false; if (orig_list) { diff --git a/cpp/src/neighbors/mg/mg_cagra_inst.cu.in b/cpp/src/neighbors/mg/mg_cagra_inst.cu.in index aee9496e1b..6e57c3f598 100644 --- a/cpp/src/neighbors/mg/mg_cagra_inst.cu.in +++ b/cpp/src/neighbors/mg/mg_cagra_inst.cu.in @@ -5,87 +5,87 @@ #include -#define CUVS_INST_MG_CAGRA(T, IdxT) \ - namespace cuvs::neighbors::cagra { \ - using namespace cuvs::neighbors; \ - \ - cuvs::neighbors::mg_index, T, IdxT> build( \ - const raft::resources& res, \ - const mg_index_params& index_params, \ - raft::host_matrix_view index_dataset) \ - { \ - cuvs::neighbors::mg_index, T, IdxT> index(res, index_params.mode); \ - cuvs::neighbors::snmg::detail::build( \ - res, \ - index, \ - static_cast(&index_params), \ - index_dataset); \ - return index; \ - } \ - \ - void extend(const raft::resources& res, \ - cuvs::neighbors::mg_index, T, IdxT>& index, \ - raft::host_matrix_view new_vectors, \ - std::optional> new_indices) \ - { \ - cuvs::neighbors::snmg::detail::extend(res, index, new_vectors, new_indices); \ - } \ - \ - void search(const raft::resources& res, \ - const cuvs::neighbors::mg_index, T, IdxT>& index, \ - const mg_search_params& search_params, \ - raft::host_matrix_view queries, \ - raft::host_matrix_view neighbors, \ - raft::host_matrix_view distances) \ - { \ - cuvs::neighbors::snmg::detail::search( \ - res, \ - index, \ - static_cast(&search_params), \ - queries, \ - neighbors, \ - distances); \ - } \ - \ - void search(const raft::resources& res, \ - const cuvs::neighbors::mg_index, T, IdxT>& index, \ - const mg_search_params& search_params, \ - raft::host_matrix_view queries, \ - raft::host_matrix_view neighbors, \ - raft::host_matrix_view distances) \ - { \ - cuvs::neighbors::snmg::detail::search( \ - res, \ - index, \ - static_cast(&search_params), \ - queries, \ - neighbors, \ - distances); \ - } \ - \ - void serialize(const raft::resources& res, \ - const cuvs::neighbors::mg_index, T, IdxT>& index, \ - const std::string& filename) \ - { \ - cuvs::neighbors::snmg::detail::serialize(res, index, filename); \ - } \ - \ - template <> \ - cuvs::neighbors::mg_index, T, IdxT> deserialize( \ - const raft::resources& res, const std::string& filename) \ - { \ - auto idx = cuvs::neighbors::mg_index, T, IdxT>(res, filename); \ - return idx; \ - } \ - \ - template <> \ - cuvs::neighbors::mg_index, T, IdxT> distribute( \ - const raft::resources& res, const std::string& filename) \ - { \ - auto idx = cuvs::neighbors::mg_index, T, IdxT>(res, REPLICATED); \ - cuvs::neighbors::snmg::detail::deserialize_and_distribute(res, idx, filename); \ - return idx; \ - } \ +#define CUVS_INST_MG_CAGRA(T, IdxT) \ + namespace cuvs::neighbors::cagra { \ + using namespace cuvs::neighbors; \ + \ + cuvs::neighbors::mg_index, T, IdxT> build( \ + const raft::resources& res, \ + const mg_index_params& index_params, \ + raft::host_matrix_view index_dataset) \ + { \ + cuvs::neighbors::mg_index, T, IdxT> index(res, index_params.mode); \ + cuvs::neighbors::snmg::detail::build( \ + res, \ + index, \ + static_cast(&index_params), \ + index_dataset); \ + return index; \ + } \ + \ + void extend(const raft::resources& res, \ + cuvs::neighbors::mg_index, T, IdxT>& index, \ + raft::host_matrix_view new_vectors, \ + std::optional> new_indices) \ + { \ + cuvs::neighbors::snmg::detail::extend(res, index, new_vectors, new_indices); \ + } \ + \ + void search(const raft::resources& res, \ + const cuvs::neighbors::mg_index, T, IdxT>& index, \ + const mg_search_params& search_params, \ + raft::host_matrix_view queries, \ + raft::host_matrix_view neighbors, \ + raft::host_matrix_view distances) \ + { \ + cuvs::neighbors::snmg::detail::search( \ + res, \ + index, \ + static_cast(&search_params), \ + queries, \ + neighbors, \ + distances); \ + } \ + \ + void search(const raft::resources& res, \ + const cuvs::neighbors::mg_index, T, IdxT>& index, \ + const mg_search_params& search_params, \ + raft::host_matrix_view queries, \ + raft::host_matrix_view neighbors, \ + raft::host_matrix_view distances) \ + { \ + cuvs::neighbors::snmg::detail::search( \ + res, \ + index, \ + static_cast(&search_params), \ + queries, \ + neighbors, \ + distances); \ + } \ + \ + void serialize(const raft::resources& res, \ + const cuvs::neighbors::mg_index, T, IdxT>& index, \ + const std::string& filename) \ + { \ + cuvs::neighbors::snmg::detail::serialize(res, index, filename); \ + } \ + \ + template <> \ + CUVS_EXPORT cuvs::neighbors::mg_index, T, IdxT> deserialize( \ + const raft::resources& res, const std::string& filename) \ + { \ + auto idx = cuvs::neighbors::mg_index, T, IdxT>(res, filename); \ + return idx; \ + } \ + \ + template <> \ + CUVS_EXPORT cuvs::neighbors::mg_index, T, IdxT> distribute( \ + const raft::resources& res, const std::string& filename) \ + { \ + auto idx = cuvs::neighbors::mg_index, T, IdxT>(res, REPLICATED); \ + cuvs::neighbors::snmg::detail::deserialize_and_distribute(res, idx, filename); \ + return idx; \ + } \ } // namespace cuvs::neighbors::cagra CUVS_INST_MG_CAGRA(@data_type@, uint32_t); diff --git a/cpp/src/neighbors/mg/mg_flat_inst.cu.in b/cpp/src/neighbors/mg/mg_flat_inst.cu.in index f5a2f63c0e..86f71f57c4 100644 --- a/cpp/src/neighbors/mg/mg_flat_inst.cu.in +++ b/cpp/src/neighbors/mg/mg_flat_inst.cu.in @@ -5,71 +5,71 @@ #include -#define CUVS_INST_MG_FLAT(T, IdxT) \ - namespace cuvs::neighbors::ivf_flat { \ - using namespace cuvs::neighbors; \ - \ - cuvs::neighbors::mg_index, T, IdxT> build( \ - const raft::resources& res, \ - const mg_index_params& index_params, \ - raft::host_matrix_view index_dataset) \ - { \ - cuvs::neighbors::mg_index, T, IdxT> index(res, index_params.mode); \ - cuvs::neighbors::snmg::detail::build( \ - res, \ - index, \ - static_cast(&index_params), \ - index_dataset); \ - return index; \ - } \ - \ - void extend(const raft::resources& res, \ - cuvs::neighbors::mg_index, T, IdxT>& index, \ - raft::host_matrix_view new_vectors, \ - std::optional> new_indices) \ - { \ - cuvs::neighbors::snmg::detail::extend(res, index, new_vectors, new_indices); \ - } \ - \ - void search(const raft::resources& res, \ - const cuvs::neighbors::mg_index, T, IdxT>& index, \ - const mg_search_params& search_params, \ - raft::host_matrix_view queries, \ - raft::host_matrix_view neighbors, \ - raft::host_matrix_view distances) \ - { \ - cuvs::neighbors::snmg::detail::search( \ - res, \ - index, \ - static_cast(&search_params), \ - queries, \ - neighbors, \ - distances); \ - } \ - \ - void serialize(const raft::resources& res, \ - const cuvs::neighbors::mg_index, T, IdxT>& index, \ - const std::string& filename) \ - { \ - cuvs::neighbors::snmg::detail::serialize(res, index, filename); \ - } \ - \ - template <> \ - cuvs::neighbors::mg_index, T, IdxT> deserialize( \ - const raft::resources& res, const std::string& filename) \ - { \ - auto idx = cuvs::neighbors::mg_index, T, IdxT>(res, filename); \ - return idx; \ - } \ - \ - template <> \ - cuvs::neighbors::mg_index, T, IdxT> distribute( \ - const raft::resources& res, const std::string& filename) \ - { \ - auto idx = cuvs::neighbors::mg_index, T, IdxT>(res, REPLICATED); \ - cuvs::neighbors::snmg::detail::deserialize_and_distribute(res, idx, filename); \ - return idx; \ - } \ +#define CUVS_INST_MG_FLAT(T, IdxT) \ + namespace cuvs::neighbors::ivf_flat { \ + using namespace cuvs::neighbors; \ + \ + cuvs::neighbors::mg_index, T, IdxT> build( \ + const raft::resources& res, \ + const mg_index_params& index_params, \ + raft::host_matrix_view index_dataset) \ + { \ + cuvs::neighbors::mg_index, T, IdxT> index(res, index_params.mode); \ + cuvs::neighbors::snmg::detail::build( \ + res, \ + index, \ + static_cast(&index_params), \ + index_dataset); \ + return index; \ + } \ + \ + void extend(const raft::resources& res, \ + cuvs::neighbors::mg_index, T, IdxT>& index, \ + raft::host_matrix_view new_vectors, \ + std::optional> new_indices) \ + { \ + cuvs::neighbors::snmg::detail::extend(res, index, new_vectors, new_indices); \ + } \ + \ + void search(const raft::resources& res, \ + const cuvs::neighbors::mg_index, T, IdxT>& index, \ + const mg_search_params& search_params, \ + raft::host_matrix_view queries, \ + raft::host_matrix_view neighbors, \ + raft::host_matrix_view distances) \ + { \ + cuvs::neighbors::snmg::detail::search( \ + res, \ + index, \ + static_cast(&search_params), \ + queries, \ + neighbors, \ + distances); \ + } \ + \ + void serialize(const raft::resources& res, \ + const cuvs::neighbors::mg_index, T, IdxT>& index, \ + const std::string& filename) \ + { \ + cuvs::neighbors::snmg::detail::serialize(res, index, filename); \ + } \ + \ + template <> \ + CUVS_EXPORT cuvs::neighbors::mg_index, T, IdxT> deserialize( \ + const raft::resources& res, const std::string& filename) \ + { \ + auto idx = cuvs::neighbors::mg_index, T, IdxT>(res, filename); \ + return idx; \ + } \ + \ + template <> \ + CUVS_EXPORT cuvs::neighbors::mg_index, T, IdxT> distribute( \ + const raft::resources& res, const std::string& filename) \ + { \ + auto idx = cuvs::neighbors::mg_index, T, IdxT>(res, REPLICATED); \ + cuvs::neighbors::snmg::detail::deserialize_and_distribute(res, idx, filename); \ + return idx; \ + } \ } // namespace cuvs::neighbors::ivf_flat CUVS_INST_MG_FLAT(@data_type@, int64_t); diff --git a/cpp/src/neighbors/mg/mg_pq_inst.cu.in b/cpp/src/neighbors/mg/mg_pq_inst.cu.in index ed938f19b3..2d4e040006 100644 --- a/cpp/src/neighbors/mg/mg_pq_inst.cu.in +++ b/cpp/src/neighbors/mg/mg_pq_inst.cu.in @@ -5,71 +5,71 @@ #include -#define CUVS_INST_MG_PQ(T, IdxT) \ - namespace cuvs::neighbors::ivf_pq { \ - using namespace cuvs::neighbors; \ - \ - cuvs::neighbors::mg_index, T, IdxT> build( \ - const raft::resources& res, \ - const mg_index_params& index_params, \ - raft::host_matrix_view index_dataset) \ - { \ - cuvs::neighbors::mg_index, T, IdxT> index(res, index_params.mode); \ - cuvs::neighbors::snmg::detail::build( \ - res, \ - index, \ - static_cast(&index_params), \ - index_dataset); \ - return index; \ - } \ - \ - void extend(const raft::resources& res, \ - cuvs::neighbors::mg_index, T, IdxT>& index, \ - raft::host_matrix_view new_vectors, \ - std::optional> new_indices) \ - { \ - cuvs::neighbors::snmg::detail::extend(res, index, new_vectors, new_indices); \ - } \ - \ - void search(const raft::resources& res, \ - const cuvs::neighbors::mg_index, T, IdxT>& index, \ - const mg_search_params& search_params, \ - raft::host_matrix_view queries, \ - raft::host_matrix_view neighbors, \ - raft::host_matrix_view distances) \ - { \ - cuvs::neighbors::snmg::detail::search( \ - res, \ - index, \ - static_cast(&search_params), \ - queries, \ - neighbors, \ - distances); \ - } \ - \ - void serialize(const raft::resources& res, \ - const cuvs::neighbors::mg_index, T, IdxT>& index, \ - const std::string& filename) \ - { \ - cuvs::neighbors::snmg::detail::serialize(res, index, filename); \ - } \ - \ - template <> \ - cuvs::neighbors::mg_index, T, IdxT> deserialize( \ - const raft::resources& res, const std::string& filename) \ - { \ - auto idx = cuvs::neighbors::mg_index, T, IdxT>(res, filename); \ - return idx; \ - } \ - \ - template <> \ - cuvs::neighbors::mg_index, T, IdxT> distribute( \ - const raft::resources& res, const std::string& filename) \ - { \ - auto idx = cuvs::neighbors::mg_index, T, IdxT>(res, REPLICATED); \ - cuvs::neighbors::snmg::detail::deserialize_and_distribute(res, idx, filename); \ - return idx; \ - } \ +#define CUVS_INST_MG_PQ(T, IdxT) \ + namespace cuvs::neighbors::ivf_pq { \ + using namespace cuvs::neighbors; \ + \ + cuvs::neighbors::mg_index, T, IdxT> build( \ + const raft::resources& res, \ + const mg_index_params& index_params, \ + raft::host_matrix_view index_dataset) \ + { \ + cuvs::neighbors::mg_index, T, IdxT> index(res, index_params.mode); \ + cuvs::neighbors::snmg::detail::build( \ + res, \ + index, \ + static_cast(&index_params), \ + index_dataset); \ + return index; \ + } \ + \ + void extend(const raft::resources& res, \ + cuvs::neighbors::mg_index, T, IdxT>& index, \ + raft::host_matrix_view new_vectors, \ + std::optional> new_indices) \ + { \ + cuvs::neighbors::snmg::detail::extend(res, index, new_vectors, new_indices); \ + } \ + \ + void search(const raft::resources& res, \ + const cuvs::neighbors::mg_index, T, IdxT>& index, \ + const mg_search_params& search_params, \ + raft::host_matrix_view queries, \ + raft::host_matrix_view neighbors, \ + raft::host_matrix_view distances) \ + { \ + cuvs::neighbors::snmg::detail::search( \ + res, \ + index, \ + static_cast(&search_params), \ + queries, \ + neighbors, \ + distances); \ + } \ + \ + void serialize(const raft::resources& res, \ + const cuvs::neighbors::mg_index, T, IdxT>& index, \ + const std::string& filename) \ + { \ + cuvs::neighbors::snmg::detail::serialize(res, index, filename); \ + } \ + \ + template <> \ + CUVS_EXPORT cuvs::neighbors::mg_index, T, IdxT> deserialize( \ + const raft::resources& res, const std::string& filename) \ + { \ + auto idx = cuvs::neighbors::mg_index, T, IdxT>(res, filename); \ + return idx; \ + } \ + \ + template <> \ + CUVS_EXPORT cuvs::neighbors::mg_index, T, IdxT> distribute( \ + const raft::resources& res, const std::string& filename) \ + { \ + auto idx = cuvs::neighbors::mg_index, T, IdxT>(res, REPLICATED); \ + cuvs::neighbors::snmg::detail::deserialize_and_distribute(res, idx, filename); \ + return idx; \ + } \ } // namespace cuvs::neighbors::ivf_pq CUVS_INST_MG_PQ(@data_type@, int64_t); diff --git a/cpp/src/neighbors/nn_descent_gnnd_inst.cu b/cpp/src/neighbors/nn_descent_gnnd_inst.cu index dc819f744a..0e4bb3a534 100644 --- a/cpp/src/neighbors/nn_descent_gnnd_inst.cu +++ b/cpp/src/neighbors/nn_descent_gnnd_inst.cu @@ -17,7 +17,7 @@ using index_t = uint32_t; namespace cuvs::neighbors::nn_descent { -template class detail::GNND; +template class CUVS_EXPORT detail::GNND; template void detail::GNND::build< cuvs::neighbors::detail::reachability::ReachabilityPostProcess>(