From 4bbce1c99ff0ab442e4ef19dd2128fba360a343d Mon Sep 17 00:00:00 2001 From: MithunR Date: Thu, 19 Feb 2026 15:23:37 -0800 Subject: [PATCH 1/3] Fix compile error for thrust make_counting_iterator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes the compile error one sees because of the use of `thrust::make_counting_iterator`: ``` │ │ $SRC_DIR/cpp/tests/neighbors/all_neighbors/../../../src/neighbors/detail/knn_brute_force.cuh(230): error: namespace "thrust" has no member "make_counting_iterator" │ │ auto count = thrust::make_counting_iterator(0); │ │ ^ │ │ $SRC_DIR/cpp/tests/neighbors/all_neighbors/../../../src/neighbors/detail/knn_brute_force.cuh(230): error: type name is not allowed │ │ auto count = thrust::make_counting_iterator(0); ``` The RAPIDS projects seem to be moving away from using the thrust function, and switching to the cuda version of the same. This change moves cuVS in that direction. Signed-off-by: MithunR --- cpp/src/neighbors/detail/knn_brute_force.cuh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cpp/src/neighbors/detail/knn_brute_force.cuh b/cpp/src/neighbors/detail/knn_brute_force.cuh index da9a2e78d7..ada7fab978 100644 --- a/cpp/src/neighbors/detail/knn_brute_force.cuh +++ b/cpp/src/neighbors/detail/knn_brute_force.cuh @@ -37,10 +37,11 @@ #include #include +#include #include #include #include -#include +#include #include #include @@ -226,7 +227,7 @@ void tiled_brute_force_knn(const raft::resources& handle, } auto distances_ptr = temp_distances.data(); - auto count = thrust::make_counting_iterator(0); + auto count = cuda::make_counting_iterator(0); DistanceT masked_distance = select_min ? std::numeric_limits::infinity() : std::numeric_limits::lowest(); @@ -276,7 +277,7 @@ void tiled_brute_force_knn(const raft::resources& handle, DistanceT* out_distances = temp_out_distances.data(); IndexType* out_indices = temp_out_indices.data(); - auto count = thrust::make_counting_iterator(0); + auto count = cuda::make_counting_iterator(0); thrust::for_each(raft::resource::get_thrust_policy(handle), count, count + current_query_size * current_k, From bc2e98b2182eb85a945acc170393295ca982af1a Mon Sep 17 00:00:00 2001 From: MithunR Date: Fri, 20 Feb 2026 16:13:12 -0800 Subject: [PATCH 2/3] More comprehensive changes. Signed-off-by: MithunR --- cpp/src/cluster/detail/agglomerative.cuh | 4 ++-- .../sparse/coo_spmv_strategies/hash_strategy.cuh | 10 +++++----- cpp/src/distance/detail/sparse/l2_distance.cuh | 6 +++--- cpp/src/sparse/neighbors/detail/cross_component_nn.cuh | 6 +++--- cpp/tests/test_utils.cuh | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/cpp/src/cluster/detail/agglomerative.cuh b/cpp/src/cluster/detail/agglomerative.cuh index f7e39f899a..836d735c61 100644 --- a/cpp/src/cluster/detail/agglomerative.cuh +++ b/cpp/src/cluster/detail/agglomerative.cuh @@ -13,6 +13,7 @@ #include +#include #include #include #include @@ -20,7 +21,6 @@ #include #include #include -#include #include #include @@ -290,7 +290,7 @@ void extract_flattened_clusters(raft::resources const& handle, thrust::fill(thrust_policy, tmp_labels.data(), tmp_labels.data() + n_vertices, -1); // Write labels for cluster roots to "labels" - thrust::counting_iterator first(0); + auto first = cuda::make_counting_iterator(0); auto z_iter = thrust::make_zip_iterator( cuda::std::make_tuple(first, label_roots.data() + (label_roots.size() - n_clusters))); diff --git a/cpp/src/distance/detail/sparse/coo_spmv_strategies/hash_strategy.cuh b/cpp/src/distance/detail/sparse/coo_spmv_strategies/hash_strategy.cuh index a05fe35cc7..30872a4e46 100644 --- a/cpp/src/distance/detail/sparse/coo_spmv_strategies/hash_strategy.cuh +++ b/cpp/src/distance/detail/sparse/coo_spmv_strategies/hash_strategy.cuh @@ -12,8 +12,8 @@ #include #include +#include #include -#include #include #include @@ -68,16 +68,16 @@ class hash_strategy : public coo_spmv_strategy { auto policy = raft::resource::get_thrust_policy(this->config.handle); auto less = thrust::copy_if(policy, - thrust::make_counting_iterator(value_idx(0)), - thrust::make_counting_iterator(n_rows), + cuda::make_counting_iterator(value_idx(0)), + cuda::make_counting_iterator(n_rows), mask_indptr.data(), fits_in_hash_table(indptr, 0, capacity_threshold * map_size)); std::get<0>(n_rows_divided) = less - mask_indptr.data(); auto more = thrust::copy_if( policy, - thrust::make_counting_iterator(value_idx(0)), - thrust::make_counting_iterator(n_rows), + cuda::make_counting_iterator(value_idx(0)), + cuda::make_counting_iterator(n_rows), less, fits_in_hash_table( indptr, capacity_threshold * map_size, std::numeric_limits::max())); diff --git a/cpp/src/distance/detail/sparse/l2_distance.cuh b/cpp/src/distance/detail/sparse/l2_distance.cuh index 68ed46cc3c..627535472f 100644 --- a/cpp/src/distance/detail/sparse/l2_distance.cuh +++ b/cpp/src/distance/detail/sparse/l2_distance.cuh @@ -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 */ @@ -19,8 +19,8 @@ #include +#include #include -#include #include #include @@ -470,7 +470,7 @@ class russelrao_expanded_distances_t : public distances_t { raft::resource::get_cuda_stream(config_->handle)); auto exec_policy = rmm::exec_policy(raft::resource::get_cuda_stream(config_->handle)); - auto diags = thrust::counting_iterator(0); + auto diags = cuda::make_counting_iterator(0); value_idx b_nrows = config_->b_nrows; thrust::for_each(exec_policy, diags, diags + config_->a_nrows, [=] __device__(value_idx input) { out_dists[input * b_nrows + input] = 0.0; diff --git a/cpp/src/sparse/neighbors/detail/cross_component_nn.cuh b/cpp/src/sparse/neighbors/detail/cross_component_nn.cuh index 8ab0f659b1..f90915fd1a 100644 --- a/cpp/src/sparse/neighbors/detail/cross_component_nn.cuh +++ b/cpp/src/sparse/neighbors/detail/cross_component_nn.cuh @@ -26,11 +26,11 @@ #include +#include #include #include #include #include -#include #include #include #include @@ -432,8 +432,8 @@ void sort_by_color(raft::resources const& handle, value_idx* src_indices, size_t n_rows) { - auto exec_policy = raft::resource::get_thrust_policy(handle); - thrust::counting_iterator arg_sort_iter(0); + auto exec_policy = raft::resource::get_thrust_policy(handle); + auto arg_sort_iter = cuda::make_counting_iterator(0); thrust::copy(exec_policy, arg_sort_iter, arg_sort_iter + n_rows, src_indices); auto keys = thrust::make_zip_iterator( diff --git a/cpp/tests/test_utils.cuh b/cpp/tests/test_utils.cuh index 7fc0b023bd..7554596eee 100644 --- a/cpp/tests/test_utils.cuh +++ b/cpp/tests/test_utils.cuh @@ -7,6 +7,7 @@ #include "test_utils.h" +#include #include #include #include @@ -15,7 +16,6 @@ #include #include #include -#include #include #include @@ -260,7 +260,7 @@ void gen_uniform(const raft::resources& handle, const T1* d_keys = keys.data(); const T2* d_values = values.data(); - auto counting = thrust::make_counting_iterator(0); + auto counting = cuda::make_counting_iterator(0); thrust::for_each(rmm::exec_policy(stream), counting, counting + len, From 4b252cc1f99c7a8927b213b6a5a0289e1b0b2209 Mon Sep 17 00:00:00 2001 From: MithunR Date: Fri, 20 Feb 2026 16:22:17 -0800 Subject: [PATCH 3/3] Also fixed common.cuh. Signed-off-by: MithunR --- examples/cpp/src/common.cuh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/cpp/src/common.cuh b/examples/cpp/src/common.cuh index 902ae74c7a..6348884ea8 100644 --- a/examples/cpp/src/common.cuh +++ b/examples/cpp/src/common.cuh @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION. + * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. * SPDX-License-Identifier: Apache-2.0 */ @@ -17,7 +17,6 @@ #include #include -#include #include