cuda_stream_pool.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2020-2025, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #pragma once
7 
8 #include <rmm/cuda_stream.hpp>
10 #include <rmm/detail/export.hpp>
11 
12 #include <atomic>
13 #include <cstddef>
14 #include <vector>
15 
16 namespace RMM_EXPORT rmm {
32  public:
33  static constexpr std::size_t default_size{16};
34 
42  explicit cuda_stream_pool(std::size_t pool_size = default_size,
43  cuda_stream::flags flags = cuda_stream::flags::sync_default);
44  ~cuda_stream_pool() = default;
45 
47  cuda_stream_pool(cuda_stream_pool const&) = delete;
48  cuda_stream_pool& operator=(cuda_stream_pool&&) = delete;
49  cuda_stream_pool& operator=(cuda_stream_pool const&) = delete;
50 
59 
70  rmm::cuda_stream_view get_stream(std::size_t stream_id) const;
71 
79  std::size_t get_pool_size() const noexcept;
80 
81  private:
82  std::vector<rmm::cuda_stream> streams_;
83  mutable std::atomic_size_t next_stream{};
84 };
85  // end of group
87 } // namespace RMM_EXPORT rmm
A pool of CUDA streams.
Definition: cuda_stream_pool.hpp:31
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.
rmm::cuda_stream_view get_stream() const noexcept
Get a cuda_stream_view of a stream in the pool.
Strongly-typed non-owning wrapper for CUDA streams with default constructor.
Definition: cuda_stream_view.hpp:28
Owning wrapper for a CUDA stream.
Definition: cuda_stream.hpp:28
flags
stream creation flags.
Definition: cuda_stream.hpp:33