From 7f3c596dfdf29ba00131b606f9ae961a598efe85 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Sat, 16 May 2026 13:05:28 -0700 Subject: [PATCH 1/7] fix(visibility): add CUDA_VISIBILITY_PRESET hidden to cuvs_objs Matches raft's visibility config (CXX_VISIBILITY_PRESET hidden + CUDA_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON) so that CUDA symbols compiled into cuvs_objs also get hidden visibility by default, preventing symbol interposition with libcuml.so. --- cpp/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) 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( From 7118e803dda5692f957db9a4a39ba40019bd8594 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Sat, 16 May 2026 17:16:28 -0700 Subject: [PATCH 2/7] fix(visibility): add CUVS_EXPORT to symbols hidden by CUDA_VISIBILITY_PRESET hidden Add CUVS_EXPORT to explicit template instantiations and out-of-line definitions that are now hidden after enabling CUDA_VISIBILITY_PRESET hidden on cuvs_objs. Affected symbols (all reported as undefined in devcontainer CI): - brute_force::index (constructor) - composite::composite_index (all methods) - cagra::index::compute_dataset_norms_ (out-of-line member fn) - dynamic_batching::index::index<...> (template constructor) - ivf::resize_list (template function definition) - nn_descent::detail::GNND and GnndGraph (constructors/destructor) - mg_index cagra/ivf_flat/ivf_pq deserialize/distribute (template specializations) --- cpp/src/neighbors/brute_force.cu | 4 +- cpp/src/neighbors/cagra.cuh | 2 +- cpp/src/neighbors/composite/index.cu | 16 +-- cpp/src/neighbors/dynamic_batching.cu | 4 +- cpp/src/neighbors/ivf_list.cuh | 10 +- cpp/src/neighbors/mg/mg_cagra_inst.cu.in | 162 +++++++++++----------- cpp/src/neighbors/mg/mg_flat_inst.cu.in | 130 ++++++++--------- cpp/src/neighbors/mg/mg_pq_inst.cu.in | 130 ++++++++--------- cpp/src/neighbors/nn_descent_gnnd_inst.cu | 3 +- 9 files changed, 231 insertions(+), 230 deletions(-) diff --git a/cpp/src/neighbors/brute_force.cu b/cpp/src/neighbors/brute_force.cu index 9966c692a8..71e8415f41 100644 --- a/cpp/src/neighbors/brute_force.cu +++ b/cpp/src/neighbors/brute_force.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 */ @@ -229,7 +229,7 @@ void index::update_dataset( res, idx, queries, neighbors, distances, sample_filter); \ } \ \ - template struct cuvs::neighbors::brute_force::index; + template struct CUVS_EXPORT cuvs::neighbors::brute_force::index; CUVS_INST_BFKNN(float, float); CUVS_INST_BFKNN(half, float); diff --git a/cpp/src/neighbors/cagra.cuh b/cpp/src/neighbors/cagra.cuh index 73c3794d39..72bd557aa5 100644 --- a/cpp/src/neighbors/cagra.cuh +++ b/cpp/src/neighbors/cagra.cuh @@ -30,7 +30,7 @@ namespace cuvs::neighbors::cagra { // Member function implementations for cagra::index template -void index::compute_dataset_norms_(raft::resources const& res) +CUVS_EXPORT void index::compute_dataset_norms_(raft::resources const& res) { // Get the dataset view auto dataset_view = this->dataset(); 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/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_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..66210937e6 100644 --- a/cpp/src/neighbors/nn_descent_gnnd_inst.cu +++ b/cpp/src/neighbors/nn_descent_gnnd_inst.cu @@ -17,7 +17,8 @@ using index_t = uint32_t; namespace cuvs::neighbors::nn_descent { -template class detail::GNND; +template class CUVS_EXPORT detail::GNND; +template struct CUVS_EXPORT detail::GnndGraph; template void detail::GNND::build< cuvs::neighbors::detail::reachability::ReachabilityPostProcess>( From 9a6cde77407c4b15256201937a1bd608e64ba536 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Sun, 17 May 2026 10:27:28 -0700 Subject: [PATCH 3/7] fix(visibility): fix CUVS_EXPORT placement to be NVCC-compatible NVCC rejects __attribute__((visibility)) on template struct/class explicit instantiations (error #1091-D) and on template function redeclarations (error #2189-D). Fix by moving CUVS_EXPORT to the class/struct declaration and function declaration instead: - brute_force::index: CUVS_EXPORT on struct declaration in brute_force.hpp - composite_index: CUVS_EXPORT on class declaration in composite/index.hpp - GnndGraph: CUVS_EXPORT on struct declaration in nn_descent_gnnd.hpp - ivf::resize_list: CUVS_EXPORT on declaration in common.hpp (not definition) Revert CUVS_EXPORT from explicit instantiations in brute_force.cu, composite/index.cu, nn_descent_gnnd_inst.cu (NVCC rejects template struct), and revert from definition in ivf_list.cuh (NVCC rejects redeclaration attr). --- cpp/include/cuvs/neighbors/brute_force.hpp | 2 +- cpp/include/cuvs/neighbors/common.hpp | 10 +++++----- cpp/include/cuvs/neighbors/composite/index.hpp | 2 +- cpp/src/neighbors/brute_force.cu | 4 ++-- cpp/src/neighbors/composite/index.cu | 16 ++++++++-------- cpp/src/neighbors/detail/nn_descent_gnnd.hpp | 2 +- cpp/src/neighbors/ivf_list.cuh | 10 +++++----- cpp/src/neighbors/nn_descent_gnnd_inst.cu | 1 - 8 files changed, 23 insertions(+), 24 deletions(-) diff --git a/cpp/include/cuvs/neighbors/brute_force.hpp b/cpp/include/cuvs/neighbors/brute_force.hpp index 9d690f8f89..c6b77799f0 100644 --- a/cpp/include/cuvs/neighbors/brute_force.hpp +++ b/cpp/include/cuvs/neighbors/brute_force.hpp @@ -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; diff --git a/cpp/include/cuvs/neighbors/common.hpp b/cpp/include/cuvs/neighbors/common.hpp index 7569ee2508..20eb394f1b 100644 --- a/cpp/include/cuvs/neighbors/common.hpp +++ b/cpp/include/cuvs/neighbors/common.hpp @@ -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/src/neighbors/brute_force.cu b/cpp/src/neighbors/brute_force.cu index 71e8415f41..9966c692a8 100644 --- a/cpp/src/neighbors/brute_force.cu +++ b/cpp/src/neighbors/brute_force.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -229,7 +229,7 @@ void index::update_dataset( res, idx, queries, neighbors, distances, sample_filter); \ } \ \ - template struct CUVS_EXPORT cuvs::neighbors::brute_force::index; + template struct cuvs::neighbors::brute_force::index; CUVS_INST_BFKNN(float, float); CUVS_INST_BFKNN(half, float); diff --git a/cpp/src/neighbors/composite/index.cu b/cpp/src/neighbors/composite/index.cu index 4b9150ba01..7c02d0e43e 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 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; +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; } // 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..49c29ccb55 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; diff --git a/cpp/src/neighbors/ivf_list.cuh b/cpp/src/neighbors/ivf_list.cuh index 24691463ff..d8704c7b89 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 -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) +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/nn_descent_gnnd_inst.cu b/cpp/src/neighbors/nn_descent_gnnd_inst.cu index 66210937e6..0e4bb3a534 100644 --- a/cpp/src/neighbors/nn_descent_gnnd_inst.cu +++ b/cpp/src/neighbors/nn_descent_gnnd_inst.cu @@ -18,7 +18,6 @@ using index_t = uint32_t; namespace cuvs::neighbors::nn_descent { template class CUVS_EXPORT detail::GNND; -template struct CUVS_EXPORT detail::GnndGraph; template void detail::GNND::build< cuvs::neighbors::detail::reachability::ReachabilityPostProcess>( From ae178ef5af575f18ec4030e99b5bc55dd1d70519 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Sun, 17 May 2026 11:33:19 -0700 Subject: [PATCH 4/7] fix(visibility): fix remaining 4 hidden symbol linker errors - Add CUVS_EXPORT to class GNND definition (nn_descent_gnnd.hpp) - Add CUVS_EXPORT to compute_dataset_norms_ declaration (cagra.hpp); remove it from definition in cagra.cuh (NVCC #2189-D rule) - Add CUVS_EXPORT to all composite_index explicit instantiations - Add explicit resize_list instantiation for ivf_flat::list_spec/half/int64_t in ivf_flat_helpers.cu to export it from the shared library --- cpp/include/cuvs/neighbors/cagra.hpp | 2 +- cpp/src/neighbors/cagra.cuh | 2 +- cpp/src/neighbors/composite/index.cu | 16 ++++++++-------- cpp/src/neighbors/detail/nn_descent_gnnd.hpp | 2 +- cpp/src/neighbors/ivf_flat/ivf_flat_helpers.cu | 14 +++++++++++++- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/cpp/include/cuvs/neighbors/cagra.hpp b/cpp/include/cuvs/neighbors/cagra.hpp index 6a5d15bc59..82d4f4c97e 100644 --- a/cpp/include/cuvs/neighbors/cagra.hpp +++ b/cpp/include/cuvs/neighbors/cagra.hpp @@ -878,7 +878,7 @@ struct index : cuvs::neighbors::index { std::optional graph_fd_; std::optional mapping_fd_; - void compute_dataset_norms_(raft::resources const& res); + CUVS_EXPORT void compute_dataset_norms_(raft::resources const& res); size_t n_rows_ = 0; size_t dim_ = 0; size_t graph_degree_ = 0; diff --git a/cpp/src/neighbors/cagra.cuh b/cpp/src/neighbors/cagra.cuh index 72bd557aa5..73c3794d39 100644 --- a/cpp/src/neighbors/cagra.cuh +++ b/cpp/src/neighbors/cagra.cuh @@ -30,7 +30,7 @@ namespace cuvs::neighbors::cagra { // Member function implementations for cagra::index template -CUVS_EXPORT void index::compute_dataset_norms_(raft::resources const& res) +void index::compute_dataset_norms_(raft::resources const& res) { // Get the dataset view auto dataset_view = this->dataset(); 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 49c29ccb55..39e3075e7e 100644 --- a/cpp/src/neighbors/detail/nn_descent_gnnd.hpp +++ b/cpp/src/neighbors/detail/nn_descent_gnnd.hpp @@ -192,7 +192,7 @@ struct CUVS_EXPORT 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/ivf_flat/ivf_flat_helpers.cu b/cpp/src/neighbors/ivf_flat/ivf_flat_helpers.cu index c5f8db6e9d..e85fede471 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,14 @@ void recompute_internal_state(const raft::resources& res, index>( + raft::resources const&, + std::shared_ptr>&, + const ivf::list::spec_type&, + ivf::list::size_type, + ivf::list::size_type); + +} // namespace cuvs::neighbors::ivf From c956741c015acc0179be14c766216afa52193764 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Sun, 17 May 2026 15:16:25 -0700 Subject: [PATCH 5/7] fix(visibility): fix brute_force, cagra, resize_list symbol export - brute_force.cu: change 'template struct' to 'template class CUVS_EXPORT' (NVCC rejects 'template struct CUVS_EXPORT' but accepts 'template class CUVS_EXPORT') - cagra_build_inst.cu.in: add 'template class CUVS_EXPORT index' to force compute_dataset_norms_ and all other members to be exported - ivf_flat_helpers.cu: fix namespace in resize_list explicit instantiation (inside namespace cuvs::neighbors::ivf, use 'list<>' not 'ivf::list<>') --- cpp/src/neighbors/brute_force.cu | 4 ++-- cpp/src/neighbors/cagra_build_inst.cu.in | 2 ++ cpp/src/neighbors/ivf_flat/ivf_flat_helpers.cu | 11 ++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cpp/src/neighbors/brute_force.cu b/cpp/src/neighbors/brute_force.cu index 9966c692a8..18c0d53bb0 100644 --- a/cpp/src/neighbors/brute_force.cu +++ b/cpp/src/neighbors/brute_force.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 */ @@ -229,7 +229,7 @@ void index::update_dataset( res, idx, queries, neighbors, distances, sample_filter); \ } \ \ - template struct cuvs::neighbors::brute_force::index; + template class CUVS_EXPORT cuvs::neighbors::brute_force::index; CUVS_INST_BFKNN(float, float); CUVS_INST_BFKNN(half, float); diff --git a/cpp/src/neighbors/cagra_build_inst.cu.in b/cpp/src/neighbors/cagra_build_inst.cu.in index 86ee6a0d2d..569da3900b 100644 --- a/cpp/src/neighbors/cagra_build_inst.cu.in +++ b/cpp/src/neighbors/cagra_build_inst.cu.in @@ -39,4 +39,6 @@ auto build(raft::resources const& handle, return cuvs::neighbors::cagra::build(handle, params, dataset); } +template class CUVS_EXPORT index; + } // namespace cuvs::neighbors::cagra diff --git a/cpp/src/neighbors/ivf_flat/ivf_flat_helpers.cu b/cpp/src/neighbors/ivf_flat/ivf_flat_helpers.cu index e85fede471..405eee21bd 100644 --- a/cpp/src/neighbors/ivf_flat/ivf_flat_helpers.cu +++ b/cpp/src/neighbors/ivf_flat/ivf_flat_helpers.cu @@ -210,11 +210,12 @@ void recompute_internal_state(const raft::resources& res, index>( +template CUVS_EXPORT void +resize_list>( raft::resources const&, - std::shared_ptr>&, - const ivf::list::spec_type&, - ivf::list::size_type, - ivf::list::size_type); + std::shared_ptr>&, + const list::spec_type&, + list::size_type, + list::size_type); } // namespace cuvs::neighbors::ivf From 61b1049af22990f693943e8bf75d56d4a8fc21c7 Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Sun, 17 May 2026 15:33:17 -0700 Subject: [PATCH 6/7] fix(visibility): use struct CUVS_EXPORT on definitions instead of instantiations NVCC error #1091-D fires when CUVS_EXPORT is placed on explicit instantiations of struct types (even with 'template class' keyword). The correct approach is to annotate the struct/class definition in the header: - cagra.hpp: struct CUVS_EXPORT index (was struct index) - brute_force.cu: revert to 'template struct' without CUVS_EXPORT - cagra_build_inst.cu.in: revert to 'template struct' without CUVS_EXPORT The class/struct definition-level CUVS_EXPORT causes all member symbols to be exported when the type is explicitly instantiated, without needing annotation at the instantiation site. --- cpp/include/cuvs/neighbors/cagra.hpp | 2 +- cpp/src/neighbors/brute_force.cu | 4 ++-- cpp/src/neighbors/cagra_build_inst.cu.in | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cpp/include/cuvs/neighbors/cagra.hpp b/cpp/include/cuvs/neighbors/cagra.hpp index 82d4f4c97e..b3eda66e63 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; diff --git a/cpp/src/neighbors/brute_force.cu b/cpp/src/neighbors/brute_force.cu index 18c0d53bb0..9966c692a8 100644 --- a/cpp/src/neighbors/brute_force.cu +++ b/cpp/src/neighbors/brute_force.cu @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -229,7 +229,7 @@ void index::update_dataset( res, idx, queries, neighbors, distances, sample_filter); \ } \ \ - template class CUVS_EXPORT cuvs::neighbors::brute_force::index; + template struct cuvs::neighbors::brute_force::index; CUVS_INST_BFKNN(float, float); CUVS_INST_BFKNN(half, float); diff --git a/cpp/src/neighbors/cagra_build_inst.cu.in b/cpp/src/neighbors/cagra_build_inst.cu.in index 569da3900b..7145c86196 100644 --- a/cpp/src/neighbors/cagra_build_inst.cu.in +++ b/cpp/src/neighbors/cagra_build_inst.cu.in @@ -39,6 +39,6 @@ auto build(raft::resources const& handle, return cuvs::neighbors::cagra::build(handle, params, dataset); } -template class CUVS_EXPORT index; +template struct index; } // namespace cuvs::neighbors::cagra From 528edafdb896cca80db76dcd025744a819c1dcba Mon Sep 17 00:00:00 2001 From: Vyas Ramasubramani Date: Tue, 19 May 2026 09:18:11 -0700 Subject: [PATCH 7/7] fix(visibility): add cuda_fp16.hpp wrapper to fix __half type visibility GCC's type visibility rule causes template instantiations over __half to inherit hidden visibility when -fvisibility=hidden is in effect. This happens because __half is a user-defined type from cuda_fp16.h that gets compiled with hidden visibility, and GCC propagates the minimum visibility of all template argument types to the instantiation. Fix by creating a wrapper header (cuvs/core/cuda_fp16.hpp) that includes cuda_fp16.h under #pragma GCC visibility push(default). This ensures __half gets default type visibility so downstream template instantiations (e.g., index<__half, ...>) are properly exported from libcuvs.so. Changes: - New: cpp/include/cuvs/core/cuda_fp16.hpp wrapper header - Replace #include with wrapper in all public headers - Add wrapper as first include in .cu.in instantiation templates - Add explicit resize_list instantiation in ivf_flat_build_extend_inst - Add CUVS_EXPORT on resize_list definition in ivf_list.cuh Fixes linker errors for: - cagra::index<__half>::compute_dataset_norms_ - brute_force::index<__half, float>::index() - ivf::resize_list<..., __half, ...> --- cpp/include/cuvs/core/cuda_fp16.hpp | 18 ++++++++++++++++++ cpp/include/cuvs/distance/distance.hpp | 2 +- cpp/include/cuvs/neighbors/brute_force.hpp | 3 ++- cpp/include/cuvs/neighbors/cagra.hpp | 3 ++- cpp/include/cuvs/neighbors/common.hpp | 2 +- cpp/include/cuvs/neighbors/ivf_flat.hpp | 1 + cpp/include/cuvs/neighbors/ivf_pq.hpp | 2 +- cpp/include/cuvs/neighbors/nn_descent.hpp | 2 +- .../cuvs/preprocessing/quantize/binary.hpp | 2 +- .../cuvs/preprocessing/quantize/scalar.hpp | 2 +- cpp/include/cuvs/selection/select_k.hpp | 2 +- cpp/src/neighbors/brute_force.cu | 19 +++++++++++++------ cpp/src/neighbors/cagra_build_inst.cu.in | 2 ++ cpp/src/neighbors/cagra_extend_inst.cu.in | 2 ++ cpp/src/neighbors/cagra_merge_inst.cu.in | 2 ++ cpp/src/neighbors/cagra_serialize_inst.cu.in | 2 ++ .../ivf_flat/ivf_flat_build_extend_inst.cu.in | 13 +++++++++++++ cpp/src/neighbors/ivf_list.cuh | 10 +++++----- 18 files changed, 69 insertions(+), 20 deletions(-) create mode 100644 cpp/include/cuvs/core/cuda_fp16.hpp 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 c6b77799f0..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 { @@ -166,6 +166,7 @@ struct CUVS_EXPORT 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 b3eda66e63..8edbcab8fa 100644 --- a/cpp/include/cuvs/neighbors/cagra.hpp +++ b/cpp/include/cuvs/neighbors/cagra.hpp @@ -878,11 +878,12 @@ struct CUVS_EXPORT index : cuvs::neighbors::index { std::optional graph_fd_; std::optional mapping_fd_; - CUVS_EXPORT void compute_dataset_norms_(raft::resources const& res); + void compute_dataset_norms_(raft::resources const& res); size_t n_rows_ = 0; 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 20eb394f1b..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 { 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 7145c86196..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 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/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_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) {