stream#

struct stream : public stream_ref#

An owning wrapper for cudaStream_t.

Public Types

using value_type = ::cudaStream_t#

Public Functions

inline explicit stream(
device_ref __dev,
int __priority = default_priority,
)#

Constructs a stream on a specified device and with specified priority.

Priority is defaulted to stream::default_priority

Throws:

cuda_error – if stream creation fails

inline explicit stream(no_init_t) noexcept#

Construct a new stream object into the moved-from state.

Post:

stream() returns an invalid stream handle

inline stream(stream &&__other) noexcept#

Move-construct a new stream object.

Parameters:

__other

Post:

__other is in moved-from state.

stream(const stream&) = delete#
inline ~stream()#

Destroy the stream object.

Note

If the stream fails to be destroyed, the error is silently ignored.

inline stream &operator=(stream &&__other) noexcept#

Move-assign a stream object.

Parameters:

__other

Post:

__other is in a moved-from state.

stream &operator=(const stream&) = delete#
inline ::cudaStream_t release()#

Retrieve the native cudaStream_t handle and give up ownership.

Returns:

cudaStream_t The native handle being held by the stream object.

Post:

The stream object is in a moved-from state.

inline constexpr value_type get() const noexcept#

Returns the wrapped cudaStream_t handle.

inline void sync() const#

Synchronizes the wrapped stream.

Throws:

cuda::cuda_error – if synchronization fails.

inline void wait() const#

Deprecated.

Use sync() instead.

Deprecated:

Use sync() instead.

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:

true if all operations have completed, or false if not.

inline bool ready() const#

Queries if all operations on the wrapped stream have completed.

Throws:

cuda::cuda_error – if the query fails.

Returns:

true if all operations have completed, or false if 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,
) const#

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,
) const#

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_context the device on which that green_context was created is returned

Throws:

cuda_error – if device check fails

inline constexpr stream_ref query(
const ::cuda::get_stream_t&,
) const noexcept#

Queries the stream_ref for itself.

This makes stream_ref usable in places where we expect an environment with a get_stream_t query

Public Static Functions

static inline stream from_native_handle(::cudaStream_t __handle)#

Construct an stream object from a native cudaStream_t handle.

Note

The constructed stream object takes ownership of the native handle.

Parameters:

__handle – The native handle

Returns:

stream The constructed stream object

static stream from_native_handle(int) = delete#
static stream from_native_handle(::cuda::std::nullptr_t) = delete#
static stream from_native_handle(invalid_stream_t) = delete#

Public Static Attributes

static constexpr int default_priority = 0#