Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
10 changes: 7 additions & 3 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 @@ -15,13 +15,15 @@
#include <raft/core/host_mdspan.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/operators.hpp>
#include <raft/core/resource/cuda_stream_pool.hpp>
#include <raft/core/resource/device_memory_resource.hpp>
#include <raft/util/cudart_utils.hpp>

#include <rmm/cuda_stream_pool.hpp>
#include <rmm/cuda_stream_view.hpp>
#include <rmm/device_uvector.hpp>
#include <rmm/mr/cuda_async_managed_memory_resource.hpp>
#include <rmm/mr/failure_callback_resource_adaptor.hpp>
#include <rmm/mr/managed_memory_resource.hpp>
#include <rmm/mr/per_device_resource.hpp>
#include <rmm/mr/pool_memory_resource.hpp>
#include <rmm/resource_ref.hpp>
Expand Down Expand Up @@ -67,7 +69,7 @@ inline auto rmm_oom_callback(std::size_t bytes, void*) -> bool
*/
class shared_raft_resources {
public:
using large_mr_type = rmm::mr::managed_memory_resource;
using large_mr_type = rmm::mr::cuda_async_managed_memory_resource;

shared_raft_resources()
try : large_mr_() {
Expand Down Expand Up @@ -132,6 +134,8 @@ class configured_raft_resources {
/** Default constructor creates all resources anew. */
configured_raft_resources() : configured_raft_resources{std::make_shared<shared_raft_resources>()}
{
raft::resource::set_cuda_stream_pool(
*res_, std::make_shared<rmm::cuda_stream_pool>(1, rmm::cuda_stream::flags::non_blocking));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a prefetch stream in the default constructor.

}

configured_raft_resources(configured_raft_resources&&);
Expand Down
3 changes: 2 additions & 1 deletion cpp/bench/ann/src/cuvs/cuvs_cagra_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,8 @@ void cuvs_cagra<T, IdxT>::search_base(
raft::resources composite_handle(handle_);
size_t n_streams = cagra_indices.size();
raft::resource::set_cuda_stream_pool(composite_handle,
std::make_shared<rmm::cuda_stream_pool>(n_streams));
std::make_shared<rmm::cuda_stream_pool>(
n_streams, rmm::cuda_stream::flags::non_blocking));

cuvs::neighbors::composite::composite_index<T, IdxT, algo_base::index_type> composite(
cagra_indices);
Expand Down
5 changes: 1 addition & 4 deletions cpp/bench/ann/src/cuvs/cuvs_ivf_flat_wrapper.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
Expand Down Expand Up @@ -88,9 +88,6 @@ class cuvs_ivf_flat : public algo<T>, public algo_gpu {
template <typename T, typename IdxT>
void cuvs_ivf_flat<T, IdxT>::build(const T* dataset, size_t nrow)
{
// Create a CUDA stream pool with 1 stream (besides main stream) for kernel/copy overlapping.
size_t n_streams = 1;
raft::resource::set_cuda_stream_pool(handle_, std::make_shared<rmm::cuda_stream_pool>(n_streams));
index_ = std::make_shared<cuvs::neighbors::ivf_flat::index<T, IdxT>>(
std::move(cuvs::neighbors::ivf_flat::build(
handle_,
Expand Down
5 changes: 1 addition & 4 deletions cpp/bench/ann/src/cuvs/cuvs_ivf_pq_wrapper.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
Expand Down Expand Up @@ -118,9 +118,6 @@ void cuvs_ivf_pq<T, IdxT>::load(const std::string& file)
template <typename T, typename IdxT>
void cuvs_ivf_pq<T, IdxT>::build(const T* dataset, size_t nrow)
{
// Create a CUDA stream pool with 1 stream (besides main stream) for kernel/copy overlapping.
size_t n_streams = 1;
raft::resource::set_cuda_stream_pool(handle_, std::make_shared<rmm::cuda_stream_pool>(n_streams));
auto dataset_v = raft::make_device_matrix_view<const T, IdxT>(dataset, IdxT(nrow), dim_);
std::make_shared<cuvs::neighbors::ivf_pq::index<IdxT>>(
std::move(cuvs::neighbors::ivf_pq::build(handle_, index_params_, dataset_v)))
Expand Down
5 changes: 1 addition & 4 deletions cpp/bench/ann/src/cuvs/cuvs_ivf_rabitq_wrapper.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* 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
*/
#pragma once
Expand Down Expand Up @@ -98,9 +98,6 @@ void cuvs_ivf_rabitq<T, IdxT>::load(const std::string& file)
template <typename T, typename IdxT>
void cuvs_ivf_rabitq<T, IdxT>::build(const T* dataset, size_t nrow)
{
// Create a CUDA stream pool with 1 stream (besides main stream) for kernel/copy overlapping.
size_t n_streams = 1;
raft::resource::set_cuda_stream_pool(handle_, std::make_shared<rmm::cuda_stream_pool>(n_streams));
auto dataset_v = raft::make_device_matrix_view<const T, IdxT>(dataset, IdxT(nrow), dim_);
std::make_shared<cuvs::neighbors::ivf_rabitq::index<IdxT>>(
std::move(cuvs::neighbors::ivf_rabitq::build(handle_, index_params_, dataset_v)))
Expand Down
4 changes: 1 addition & 3 deletions cpp/bench/ann/src/cuvs/cuvs_ivf_sq_wrapper.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION.
* SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
Expand Down Expand Up @@ -83,8 +83,6 @@ class cuvs_ivf_sq : public algo<T>, public algo_gpu {
template <typename T>
void cuvs_ivf_sq<T>::build(const T* dataset, size_t nrow)
{
size_t n_streams = 1;
raft::resource::set_cuda_stream_pool(handle_, std::make_shared<rmm::cuda_stream_pool>(n_streams));
index_ = std::make_shared<cuvs::neighbors::ivf_sq::index<uint8_t>>(
std::move(cuvs::neighbors::ivf_sq::build(
handle_,
Expand Down
Loading