stream_ref#
-
class stream_ref#
A non-owning wrapper for a
cudaStream_t.Subclassed by stream
Public Types
-
using value_type = ::cudaStream_t#
Public Functions
-
stream_ref() = default#
Constructs a
stream_refof the “default” CUDA stream.For behavior of the default stream,
-
inline constexpr stream_ref(value_type __stream_) noexcept#
Constructs a
stream_reffrom acudaStream_thandle.This constructor provides implicit conversion from
cudaStream_t.Note
: It is the callers responsibility to ensure the
stream_refdoes not outlive the stream identified by thecudaStream_thandle.
-
inline explicit stream_ref(invalid_stream_t) noexcept#
Constructs a
stream_reffrom thecuda::invalid_stream_t.Note
Any CUDA APIs called on the created object will result in an CUDA error.
-
stream_ref(int) = delete#
Disallow construction from an
int, e.g.,0.
-
stream_ref(::cuda::std::nullptr_t) = delete#
Disallow construction from
nullptr.
-
inline constexpr value_type get() const noexcept#
Returns the wrapped
cudaStream_thandle.
-
inline void sync() const#
Synchronizes the wrapped stream.
- Throws:
cuda::cuda_error – if synchronization fails.
-
inline void wait(event_ref __ev) const#
Make all future work submitted into this stream depend on completion of the specified event.
- Parameters:
__ev – Event that this stream should wait for
- Throws:
cuda_error – if inserting the dependency fails
-
inline void wait(stream_ref __other) const#
Make all future work submitted into this stream depend on completion of all work from the specified stream.
- Parameters:
__other – Stream that this stream should wait for
- Throws:
cuda_error – if inserting the dependency fails
-
inline bool is_done() const#
Queries if all operations on the stream have completed.
- Throws:
cuda::cuda_error – if the query fails.
- Returns:
trueif all operations have completed, orfalseif not.
-
inline bool ready() const#
Queries if all operations on the wrapped stream have completed.
- Throws:
cuda::cuda_error – if the query fails.
- Returns:
trueif all operations have completed, orfalseif not.
-
inline int priority() const#
Queries the priority of the wrapped stream.
- Throws:
cuda::cuda_error – if the query fails.
- Returns:
value representing the priority of the wrapped stream.
-
inline stream_id id() const#
Get the unique ID of the stream.
Stream handles are sometimes reused, but ID is guaranteed to be unique.
- Throws:
cuda_error – if the ID query fails
- Returns:
The unique ID of the stream
- inline event record_event(
- event_flags __flags = event_flags::none,
Create a new event and record it into this stream.
- Throws:
cuda_error – if event creation or record failed
- Returns:
A new event that was recorded into this stream
- inline timed_event record_timed_event(
- event_flags __flags = event_flags::none,
Create a new timed event and record it into this stream.
- Throws:
cuda_error – if event creation or record failed
- Returns:
A new timed event that was recorded into this stream
-
inline device_ref device() const#
Get device under which this stream was created.
Note: In case of a stream created under a
green_contextthe device on which thatgreen_contextwas created is returned- Throws:
cuda_error – if device check fails
- inline constexpr stream_ref query(
- const ::cuda::get_stream_t&,
Queries the
stream_reffor itself.This makes
stream_refusable in places where we expect an environment with aget_stream_tquery
Friends
- inline friend constexpr bool operator==(
- const stream_ref &__lhs,
- const stream_ref &__rhs,
Compares two
stream_refs for equality.Note
Allows comparison with
cudaStream_tdue to implicit conversion tostream_ref.- Parameters:
__lhs – The first
stream_refto compare__rhs – The second
stream_refto compare
- Returns:
true if equal, false if unequal
- inline friend bool operator==(
- const stream_ref &__lhs,
- const invalid_stream_t&,
Compares
stream_refwithinvalid_stream_tfor equality.Note
Allows comparison with
cudaStream_tdue to implicit conversion tostream_ref.- Parameters:
__lhs – The
stream_refto compare__rhs – The
invalid_stream_tto compare
- Returns:
true if equal, false if unequal
- inline friend bool operator==(
- const invalid_stream_t&,
- const stream_ref &__rhs,
Compares
invalid_stream_twithstream_reffor equality.Note
Allows comparison with
cudaStream_tdue to implicit conversion tostream_ref.- Parameters:
__lhs – The
invalid_stream_tto compare__rhs – The
stream_refto compare
- Returns:
true if equal, false if unequal
- inline friend constexpr bool operator!=(
- const stream_ref &__lhs,
- const stream_ref &__rhs,
Compares two
stream_refs for inequality.Note
Allows comparison with
cudaStream_tdue to implicit conversion tostream_ref.- Parameters:
__lhs – The first
stream_refto compare__rhs – The second
stream_refto compare
- Returns:
true if unequal, false if equal
- inline friend bool operator!=(
- const stream_ref &__lhs,
- const invalid_stream_t&,
Compares
stream_refwithinvalid_stream_tfor inequality.Note
Allows comparison with
cudaStream_tdue to implicit conversion tostream_ref.- Parameters:
__lhs – The
stream_refto compare__rhs – The
invalid_stream_tto compare
- Returns:
false if equal, true if unequal
- inline friend bool operator!=(
- const invalid_stream_t&,
- const stream_ref &__rhs,
Compares
invalid_stream_twithstream_reffor inequality.Note
Allows comparison with
cudaStream_tdue to implicit conversion tostream_ref.- Parameters:
__lhs – The
invalid_stream_tto compare__rhs – The
stream_refto compare
- Returns:
false if equal, true if unequal
-
using value_type = ::cudaStream_t#