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();
Strongly-typed non-owning wrapper for CUDA streams with default constructor.
Definition: cuda_stream_view.hpp:39
constexpr cudaStream_t value() const noexcept
Get the wrapped stream.
Definition: cuda_stream_view.hpp:73
constexpr cuda_stream_view & operator=(cuda_stream_view const &)=default
Default copy assignment operator.
constexpr cuda_stream_view & operator=(cuda_stream_view &&)=default
Default move assignment operator.
constexpr cuda_stream_view(cudaStream_t stream) noexcept
Constructor from a cudaStream_t.
Definition: cuda_stream_view.hpp:59
constexpr cuda_stream_view(cuda::stream_ref stream) noexcept
Implicit conversion from stream_ref.
Definition: cuda_stream_view.hpp:66
constexpr cuda_stream_view(cuda_stream_view &&)=default
Default move constructor.
void synchronize_no_throw() const noexcept
Synchronize the viewed CUDA stream. Does not throw if there is an error.
Definition: cuda_stream_view.hpp:113
constexpr cuda_stream_view(cuda_stream_view const &)=default
Default copy constructor.
bool operator==(cuda_stream_view lhs, cuda_stream_view rhs)
Equality comparison operator for streams.
Definition: cuda_stream_view.hpp:175
static constexpr cuda_stream_view cuda_stream_default
Static cuda_stream_view of the default stream (stream 0), for convenience.
Definition: cuda_stream_view.hpp:125
std::ostream & operator<<(std::ostream &os, cuda_stream_view stream)
Output stream operator for printing / logging streams.
Definition: cuda_stream_view.hpp:196
static const cuda_stream_view cuda_stream_per_thread
Static cuda_stream_view of cudaStreamPerThread, for convenience.
Definition: cuda_stream_view.hpp:138
bool operator!=(cuda_stream_view lhs, cuda_stream_view rhs)
Inequality comparison operator for streams.
Definition: cuda_stream_view.hpp:187
static const cuda_stream_view cuda_stream_legacy
Static cuda_stream_view of cudaStreamLegacy, for convenience.
Definition: cuda_stream_view.hpp:131