19 #include <rmm/detail/error.hpp>
20 #include <rmm/detail/export.hpp>
22 #include <cuda/stream_ref>
23 #include <cuda_runtime_api.h>
29 namespace RMM_NAMESPACE {
68 constexpr
cuda_stream_view(cuda::stream_ref stream) noexcept : stream_{stream.get()} {}
75 [[nodiscard]] constexpr cudaStream_t
value() const noexcept {
return stream_; }
82 constexpr
operator cudaStream_t() const noexcept {
return value(); }
89 constexpr
operator cuda::stream_ref() const noexcept {
return value(); }
94 [[nodiscard]]
inline bool is_per_thread_default() const noexcept;
99 [[nodiscard]] inline
bool is_default() const noexcept;
108 void synchronize()
const { RMM_CUDA_TRY(cudaStreamSynchronize(stream_)); }
117 RMM_ASSERT_CUDA_SUCCESS(cudaStreamSynchronize(stream_));
121 cudaStream_t stream_{};
147 [[nodiscard]]
inline bool cuda_stream_view::is_per_thread_default() const noexcept
149 #ifdef CUDA_API_PER_THREAD_DEFAULT_STREAM
156 [[nodiscard]]
inline bool cuda_stream_view::is_default() const noexcept
158 #ifdef CUDA_API_PER_THREAD_DEFAULT_STREAM
200 os << stream.
value();
Strongly-typed non-owning wrapper for CUDA streams with default constructor.
Definition: cuda_stream_view.hpp:41
constexpr cudaStream_t value() const noexcept
Get the wrapped stream.
Definition: cuda_stream_view.hpp:75
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:61
constexpr cuda_stream_view(cuda::stream_ref stream) noexcept
Implicit conversion from stream_ref.
Definition: cuda_stream_view.hpp:68
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:115
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:177
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:127
std::ostream & operator<<(std::ostream &os, cuda_stream_view stream)
Output stream operator for printing / logging streams.
Definition: cuda_stream_view.hpp:198
static const cuda_stream_view cuda_stream_per_thread
Static cuda_stream_view of cudaStreamPerThread, for convenience.
Definition: cuda_stream_view.hpp:140
bool operator!=(cuda_stream_view lhs, cuda_stream_view rhs)
Inequality comparison operator for streams.
Definition: cuda_stream_view.hpp:189
static const cuda_stream_view cuda_stream_legacy
Static cuda_stream_view of cudaStreamLegacy, for convenience.
Definition: cuda_stream_view.hpp:133