diff --git a/cpp/bench/ann/src/raft/raft_ann_bench_utils.h b/cpp/bench/ann/src/raft/raft_ann_bench_utils.h index 72a2c0bb05..6cadb26736 100644 --- a/cpp/bench/ann/src/raft/raft_ann_bench_utils.h +++ b/cpp/bench/ann/src/raft/raft_ann_bench_utils.h @@ -122,7 +122,9 @@ class configured_raft_resources { * It's used by the copy constructor. */ explicit configured_raft_resources(const std::shared_ptr& shared_res) - : shared_res_{shared_res}, res_{rmm::cuda_stream_view(get_stream_from_global_pool())} + : shared_res_{shared_res}, + res_{std::make_unique( + rmm::cuda_stream_view(get_stream_from_global_pool()))} { } @@ -131,9 +133,9 @@ class configured_raft_resources { { } - configured_raft_resources(configured_raft_resources&&) = delete; - configured_raft_resources& operator=(configured_raft_resources&&) = delete; - ~configured_raft_resources() = default; + configured_raft_resources(configured_raft_resources&&); + configured_raft_resources& operator=(configured_raft_resources&&); + ~configured_raft_resources() = default; configured_raft_resources(const configured_raft_resources& res) : configured_raft_resources{res.shared_res_} { @@ -144,11 +146,11 @@ class configured_raft_resources { return *this; } - operator raft::resources&() noexcept { return res_; } - operator const raft::resources&() const noexcept { return res_; } + operator raft::resources&() noexcept { return *res_; } + operator const raft::resources&() const noexcept { return *res_; } /** Get the main stream */ - [[nodiscard]] auto get_sync_stream() const noexcept { return resource::get_cuda_stream(res_); } + [[nodiscard]] auto get_sync_stream() const noexcept { return resource::get_cuda_stream(*res_); } private: /** The resources shared among multiple raft handles / threads. */ @@ -157,7 +159,11 @@ class configured_raft_resources { * Until we make the use of copies of raft::resources thread-safe, each benchmark wrapper must * have its own copy of it. */ - raft::device_resources res_; + std::unique_ptr res_ = std::make_unique(); }; +inline configured_raft_resources::configured_raft_resources(configured_raft_resources&&) = default; +inline configured_raft_resources& configured_raft_resources::operator=( + configured_raft_resources&&) = default; + } // namespace raft::bench::ann