Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions c/src/core/c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <raft/core/resources.hpp>
#include <raft/util/cudart_utils.hpp>
#include <rapids_logger/logger.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <cuda/stream>
#include <rmm/mr/cuda_async_memory_resource.hpp>
#include <rmm/mr/cuda_memory_resource.hpp>
#include <rmm/mr/managed_memory_resource.hpp>
Expand Down Expand Up @@ -136,15 +136,15 @@ extern "C" cuvsError_t cuvsStreamSet(cuvsResources_t res, cudaStream_t stream)
{
return cuvs::core::translate_exceptions([=] {
auto res_ptr = reinterpret_cast<raft::resources*>(res);
raft::resource::set_cuda_stream(*res_ptr, static_cast<rmm::cuda_stream_view>(stream));
raft::resource::set_cuda_stream(*res_ptr, static_cast<cuda::stream_ref>(stream));
});
}

extern "C" cuvsError_t cuvsStreamGet(cuvsResources_t res, cudaStream_t* stream)
{
return cuvs::core::translate_exceptions([=] {
auto res_ptr = reinterpret_cast<raft::resources*>(res);
*stream = raft::resource::get_cuda_stream(*res_ptr);
*stream = raft::resource::get_cuda_stream(*res_ptr).get();
});
}

Expand Down
2 changes: 1 addition & 1 deletion c/src/neighbors/nn_descent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void _get_distances(cuvsResources_t res, cuvsNNDescentIndex_t index, DLManagedTe
src->data_handle(),
dst.extent(0) * dst.extent(1) * sizeof(float),
cudaMemcpyDefault,
raft::resource::get_cuda_stream(*res_ptr));
raft::resource::get_cuda_stream(*res_ptr).get());

} else {
RAFT_FAIL("Unsupported nn-descent index dtype: %d and bits: %d", dtype.code, dtype.bits);
Expand Down
2 changes: 1 addition & 1 deletion c/tests/neighbors/ann_ivf_sq_c.cu
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ TEST(IvfSqC, BuildSearch)

cuvsResources_t res;
cuvsResourcesCreate(&res);
cuvsStreamSet(res, stream);
cuvsStreamSet(res, stream.get());

run_ivf_sq(res,
n_rows,
Expand Down
15 changes: 8 additions & 7 deletions c/tests/neighbors/ann_mg_c.cu
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2025-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

#include <cuda.h>
#include <gtest/gtest.h>
#include <cuda/stream>
#include <raft/core/device_mdarray.hpp>
#include <raft/core/handle.hpp>
#include <raft/random/rng.cuh>
Expand Down Expand Up @@ -158,12 +159,12 @@ class MgCTest : public ::testing::TestWithParam<mg_test_params> {

protected:
mg_test_params params;
rmm::device_uvector<float> index_data{0, rmm::cuda_stream_default};
rmm::device_uvector<float> query_data{0, rmm::cuda_stream_default};
rmm::device_uvector<int64_t> neighbors_data{0, rmm::cuda_stream_default};
rmm::device_uvector<float> distances_data{0, rmm::cuda_stream_default};
rmm::device_uvector<int64_t> ref_neighbors_data{0, rmm::cuda_stream_default};
rmm::device_uvector<float> ref_distances_data{0, rmm::cuda_stream_default};
rmm::device_uvector<float> index_data{0, cuda::stream_ref{cudaStream_t{cudaStreamDefault}}};
rmm::device_uvector<float> query_data{0, cuda::stream_ref{cudaStream_t{cudaStreamDefault}}};
rmm::device_uvector<int64_t> neighbors_data{0, cuda::stream_ref{cudaStream_t{cudaStreamDefault}}};
rmm::device_uvector<float> distances_data{0, cuda::stream_ref{cudaStream_t{cudaStreamDefault}}};
rmm::device_uvector<int64_t> ref_neighbors_data{0, cuda::stream_ref{cudaStream_t{cudaStreamDefault}}};
rmm::device_uvector<float> ref_distances_data{0, cuda::stream_ref{cudaStream_t{cudaStreamDefault}}};

// Host memory for multi-GPU tests
std::vector<float> index_data_host;
Expand Down
3 changes: 2 additions & 1 deletion cpp/bench/ann/src/common/cuda_huge_page_resource.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once

#include <cuda/stream>
#include <raft/core/error.hpp>
#include <raft/core/logger_macros.hpp>

Expand Down
8 changes: 4 additions & 4 deletions cpp/bench/ann/src/cuvs/cuvs_ann_bench_utils.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
Expand All @@ -18,7 +18,7 @@
#include <raft/core/resource/device_memory_resource.hpp>
#include <raft/util/cudart_utils.hpp>

#include <rmm/cuda_stream_view.hpp>
#include <cuda/stream>
#include <rmm/device_uvector.hpp>
#include <rmm/mr/failure_callback_resource_adaptor.hpp>
#include <rmm/mr/managed_memory_resource.hpp>
Expand Down Expand Up @@ -122,8 +122,8 @@ class configured_raft_resources {
*/
explicit configured_raft_resources(const std::shared_ptr<shared_raft_resources>& shared_res)
: shared_res_{shared_res},
res_{std::make_unique<raft::device_resources>(
rmm::cuda_stream_view(get_stream_from_global_pool()))}
res_{
std::make_unique<raft::device_resources>(cuda::stream_ref(get_stream_from_global_pool()))}
{
raft::resource::set_large_workspace_resource(
*res_, raft::mr::device_resource{shared_res_->get_large_memory_resource()});
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/cuvs/neighbors/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ auto make_device_dense_row_major_dataset_from_src(raft::resources const& res,
RAFT_CUDA_TRY(cudaMemsetAsync(out_array.data_handle(),
0,
out_array.size() * sizeof(ValueT),
raft::resource::get_cuda_stream(res)));
raft::resource::get_cuda_stream(res).get()));
raft::copy_matrix(out_array.data_handle(),
target_stride,
src.data_handle(),
Expand Down
3 changes: 1 addition & 2 deletions cpp/include/cuvs/neighbors/scann.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2024-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

Expand All @@ -17,7 +17,6 @@
#include <raft/core/resource/stream_view.hpp>
#include <raft/core/resources.hpp>
#include <raft/util/integer_utils.hpp>
#include <rmm/cuda_stream_view.hpp>

#include <cmath>
#include <cuvs/core/export.hpp>
Expand Down
1 change: 0 additions & 1 deletion cpp/include/cuvs/neighbors/vamana.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <raft/core/resource/stream_view.hpp>
#include <raft/core/resources.hpp>
#include <raft/util/integer_utils.hpp>
#include <rmm/cuda_stream_view.hpp>

#include <cuvs/core/export.hpp>
#include <optional>
Expand Down
3 changes: 1 addition & 2 deletions cpp/internal/cuvs_internal/neighbors/naive_knn.cuh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

Expand All @@ -11,7 +11,6 @@
#include <raft/util/cuda_utils.cuh>

#include <raft/core/resource/cuda_stream.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
#include <rmm/mr/per_device_resource.hpp>
#include <rmm/resource_ref.hpp>
Expand Down
6 changes: 3 additions & 3 deletions cpp/internal/cuvs_internal/neighbors/refine_helper.cuh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
Expand All @@ -15,7 +15,7 @@
#include <raft/core/resources.hpp>
#include <raft/random/rng.cuh>

#include <rmm/cuda_stream_view.hpp>
#include <cuda/stream>
#include <rmm/device_uvector.hpp>

namespace cuvs::neighbors {
Expand Down Expand Up @@ -127,7 +127,7 @@ class RefineHelper {
public:
RefineInputs<IdxT> p;
const raft::resources& handle_;
rmm::cuda_stream_view stream_;
cuda::stream_ref stream_;

raft::device_matrix<DataT, IdxT, row_major> dataset;
raft::device_matrix<DataT, IdxT, row_major> queries;
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/cluster/detail/agglomerative.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ void extract_flattened_clusters(raft::resources const& handle,
rmm::device_uvector<value_idx> levels(n_vertices, stream);

value_idx n_blocks = raft::ceildiv(n_vertices, (value_idx)tpb);
write_levels_kernel<<<n_blocks, tpb, 0, stream>>>(children, levels.data(), n_vertices);
write_levels_kernel<<<n_blocks, tpb, 0, stream.get()>>>(children, levels.data(), n_vertices);
/**
* Step 1: Find label roots:
*
Expand Down Expand Up @@ -323,7 +323,7 @@ void extract_flattened_clusters(raft::resources const& handle,
*/
value_idx cut_level = (n_edges / 2) - (n_clusters - 1);

inherit_labels<<<n_blocks, tpb, 0, stream>>>(
inherit_labels<<<n_blocks, tpb, 0, stream.get()>>>(
children, levels.data(), n_leaves, tmp_labels.data(), cut_level, n_vertices);

// copy tmp labels to actual labels
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/cluster/detail/connectivities.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct distance_graph_impl<Linkage::KNN_GRAPH, value_idx, value_t> {
auto thrust_policy = raft::resource::get_thrust_policy(handle);

// Need to symmetrize knn into undirected graph
raft::sparse::COO<value_t, value_idx> knn_graph_coo(stream);
raft::sparse::COO<value_t, value_idx> knn_graph_coo(stream.get());

auto X_view = raft::make_device_matrix_view<const value_t, value_idx, raft::row_major>(X, m, n);
cuvs::neighbors::detail::knn_graph<value_idx, value_t, size_t>(
Expand Down Expand Up @@ -92,7 +92,7 @@ struct distance_graph_impl<Linkage::KNN_GRAPH, value_idx, value_t> {
raft::make_const_mdspan(vals_in_view));

raft::sparse::convert::sorted_coo_to_csr(
knn_graph_coo.rows(), knn_graph_coo.nnz, indptr.data(), m + 1, stream);
knn_graph_coo.rows(), knn_graph_coo.nnz, indptr.data(), m + 1, stream.get());

// TODO: Wouldn't need to copy here if we could compute knn
// graph directly on the device uvectors
Expand Down Expand Up @@ -140,7 +140,7 @@ void pairwise_distances(const raft::resources& handle,
value_idx nnz = m * m;

value_idx blocks = raft::ceildiv(nnz, (value_idx)256);
fill_indices2<value_idx><<<blocks, 256, 0, stream>>>(indices, m, nnz);
fill_indices2<value_idx><<<blocks, 256, 0, stream.get()>>>(indices, m, nnz);

raft::linalg::map_offset(handle,
raft::make_device_vector_view<value_idx, value_idx>(indptr, m),
Expand Down
10 changes: 5 additions & 5 deletions cpp/src/cluster/detail/kmeans.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void kmeansPlusPlus(raft::resources const& handle,
rmm::device_uvector<char>& workspace)
{
raft::common::nvtx::range<cuvs::common::nvtx::domain::cuvs> fun_scope("kmeansPlusPlus");
cudaStream_t stream = raft::resource::get_cuda_stream(handle);
cudaStream_t stream = raft::resource::get_cuda_stream(handle).get();
auto n_samples = X.extent(0);
auto n_features = X.extent(1);
auto n_clusters = params.n_clusters;
Expand Down Expand Up @@ -309,7 +309,7 @@ void initScalableKMeansPlusPlus(raft::resources const& handle,
{
raft::common::nvtx::range<cuvs::common::nvtx::domain::cuvs> fun_scope(
"initScalableKMeansPlusPlus");
cudaStream_t stream = raft::resource::get_cuda_stream(handle);
cudaStream_t stream = raft::resource::get_cuda_stream(handle).get();
auto n_samples = X.extent(0);
auto n_features = X.extent(1);
auto n_clusters = params.n_clusters;
Expand Down Expand Up @@ -573,7 +573,7 @@ void kmeans_fit(
auto n_features = X.extent(1);
auto n_clusters = pams.n_clusters;
auto metric = pams.metric;
cudaStream_t stream = raft::resource::get_cuda_stream(handle);
cudaStream_t stream = raft::resource::get_cuda_stream(handle).get();

if (sample_weight.has_value())
RAFT_EXPECTS(sample_weight.value().extent(0) == n_samples,
Expand Down Expand Up @@ -1035,7 +1035,7 @@ void kmeans_predict(raft::resources const& handle,
raft::common::nvtx::range<cuvs::common::nvtx::domain::cuvs> fun_scope("kmeans_predict");
auto n_samples = X.extent(0);
auto n_features = X.extent(1);
cudaStream_t stream = raft::resource::get_cuda_stream(handle);
cudaStream_t stream = raft::resource::get_cuda_stream(handle).get();
// Check that parameters are valid
if (sample_weight.has_value())
RAFT_EXPECTS(sample_weight.value().extent(0) == n_samples,
Expand Down Expand Up @@ -1186,7 +1186,7 @@ void kmeans_transform(raft::resources const& handle,
"kmeans only supports L2Expanded or L2SqrtExpanded distance metrics.");
raft::common::nvtx::range<cuvs::common::nvtx::domain::cuvs> fun_scope("kmeans_transform");
raft::default_logger().set_level(pams.verbosity);
cudaStream_t stream = raft::resource::get_cuda_stream(handle);
cudaStream_t stream = raft::resource::get_cuda_stream(handle).get();
auto n_samples = X.extent(0);
auto n_features = X.extent(1);
auto n_clusters = pams.n_clusters;
Expand Down
Loading
Loading