Loading...
Searching...
No Matches
cuda_stream_pool.hpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6#pragma once
7
8#include <rmm/cuda_stream.hpp>
9#include <rmm/detail/export.hpp>
10
11#include <cuda/stream>
12
13#include <atomic>
14#include <cstddef>
15#include <vector>
16
17RMM_NAMESPACE_BEGIN
23
33 public:
34 static constexpr std::size_t default_size{16};
35
43 explicit cuda_stream_pool(std::size_t pool_size = default_size,
45 ~cuda_stream_pool() = default;
46
48 cuda_stream_pool(cuda_stream_pool const&) = delete;
49 cuda_stream_pool& operator=(cuda_stream_pool&&) = delete;
50 cuda_stream_pool& operator=(cuda_stream_pool const&) = delete;
51
59 cuda::stream_ref get_stream() const noexcept;
60
74 cuda::stream_ref get_stream(std::size_t stream_id) const;
75
83 std::size_t get_pool_size() const noexcept;
84
85 private:
86 std::vector<rmm::cuda_stream> streams_;
87 mutable std::atomic_size_t next_stream{};
88};
89 // end of group
91RMM_NAMESPACE_END
static constexpr std::size_t default_size
Default stream pool size.
Definition cuda_stream_pool.hpp:34
std::size_t get_pool_size() const noexcept
Get the number of streams in the pool.
cuda_stream_pool(std::size_t pool_size=default_size, cuda_stream::flags flags=cuda_stream::flags::sync_default)
Construct a new CUDA stream pool object of the given non-zero size.
cuda::stream_ref get_stream() const noexcept
Get a cuda::stream_ref of a stream in the pool.
Owning wrapper for a CUDA stream.
Definition cuda_stream.hpp:28
flags
stream creation flags.
Definition cuda_stream.hpp:33
@ sync_default
Created stream synchronizes with the default stream.
Definition cuda_stream.hpp:34
The top-level namespace containing all RMM functionality.