19 #include <rmm/detail/error.hpp>
20 #include <rmm/detail/export.hpp>
22 #include <cuda/stream_ref>
23 #include <cuda_runtime_api.h>
27 namespace RMM_NAMESPACE {
66 constexpr
cuda_stream_view(cuda::stream_ref stream) noexcept : stream_{stream.get()} {}
73 [[nodiscard]] constexpr cudaStream_t
value() const noexcept {
return stream_; }
80 constexpr
operator cudaStream_t() const noexcept {
return value(); }
87 constexpr
operator cuda::stream_ref() const noexcept {
return value(); }
92 [[nodiscard]]
inline bool is_per_thread_default() const noexcept;
97 [[nodiscard]] inline
bool is_default() const noexcept;
106 void synchronize()
const { RMM_CUDA_TRY(cudaStreamSynchronize(stream_)); }
115 RMM_ASSERT_CUDA_SUCCESS(cudaStreamSynchronize(stream_));
119 cudaStream_t stream_{};
145 [[nodiscard]]
inline bool cuda_stream_view::is_per_thread_default() const noexcept
147 #ifdef CUDA_API_PER_THREAD_DEFAULT_STREAM
154 [[nodiscard]]
inline bool cuda_stream_view::is_default() const noexcept
156 #ifdef CUDA_API_PER_THREAD_DEFAULT_STREAM
198 os << stream.
value();
用于 CUDA 流的强类型非拥有包装器,具有默认构造函数。
定义: cuda_stream_view.hpp:39
constexpr cudaStream_t value() const noexcept
获取包装的流。
定义: cuda_stream_view.hpp:73
constexpr cuda_stream_view & operator=(cuda_stream_view const &)=default
默认拷贝赋值运算符。
constexpr cuda_stream_view & operator=(cuda_stream_view &&)=default
默认移动赋值运算符。
constexpr cuda_stream_view(cudaStream_t stream) noexcept
从 cudaStream_t 构造。
定义: cuda_stream_view.hpp:59
constexpr cuda_stream_view(cuda::stream_ref stream) noexcept
从 stream_ref 进行隐式转换。
定义: cuda_stream_view.hpp:66
constexpr cuda_stream_view(cuda_stream_view &&)=default
默认移动构造函数。
void synchronize_no_throw() const noexcept
同步被查看的 CUDA 流。如果发生错误,不会抛出异常。
定义: cuda_stream_view.hpp:113
constexpr cuda_stream_view(cuda_stream_view const &)=default
默认拷贝构造函数。
bool operator==(cuda_stream_view lhs, cuda_stream_view rhs)
流的相等比较运算符。
定义: cuda_stream_view.hpp:175
static constexpr cuda_stream_view cuda_stream_default
默认流(流 0)的静态 cuda_stream_view,方便使用。
定义: cuda_stream_view.hpp:125
std::ostream & operator<<(std::ostream &os, cuda_stream_view stream)
用于打印/日志记录流的输出流运算符。
定义: cuda_stream_view.hpp:196
static const cuda_stream_view cuda_stream_per_thread
cudaStreamPerThread 的静态 cuda_stream_view,方便使用。
定义: cuda_stream_view.hpp:138
bool operator!=(cuda_stream_view lhs, cuda_stream_view rhs)
流的不等比较运算符。
定义: cuda_stream_view.hpp:187
static const cuda_stream_view cuda_stream_legacy
cudaStreamLegacy 的静态 cuda_stream_view,方便使用。
定义: cuda_stream_view.hpp:131