pub struct Stream { /* private fields */ }Expand description
A shared CUDA stream retaining its actual context.
Clones share native ownership and capture cleanup. Owned handles are synchronized and destroyed when their last wrapper drops. Externally owned handles instead retain an ownership token and are not destroyed by this wrapper.
Implementations§
Source§impl Stream
impl Stream
Sourcepub fn completion(&self) -> Result<CheckedStreamFuture>
pub fn completion(&self) -> Result<CheckedStreamFuture>
Returns a future that resolves with CUDA’s status once the work queued so far on this stream completes.
An event wait observes CUDA status independently of notification callbacks. Registration is rejected while stream capture is active.
§Errors
Returns an error if capture is active or invalidated, CUDA cannot query capture state, create or record the completion event, or bind the context, or the completion worker cannot be started or accept work. The returned future reports asynchronous CUDA completion errors.
Source§impl Stream
impl Stream
Sourcepub fn capture_owned<O: Recordable>(
&self,
operation: O,
) -> Result<OwnedGraph<O::Output>>
pub fn capture_owned<O: Recordable>( &self, operation: O, ) -> Result<OwnedGraph<O::Output>>
Captures already prepared owned work; no producer executes during recording.
§Errors
Propagates capture setup, operation recording, and capture finalization errors. Resources registered before failure remain retained until capture ends; if cleanup cannot establish that capture ended, the recording preserves those resources.
Source§impl Stream
impl Stream
Sourcepub unsafe fn from_cudarc(owner: Arc<CudaStream>) -> Result<Self>
pub unsafe fn from_cudarc(owner: Arc<CudaStream>) -> Result<Self>
Sourcepub unsafe fn to_cudarc(
&self,
context: &Arc<CudaContext>,
) -> Result<Arc<CudaStream>>
pub unsafe fn to_cudarc( &self, context: &Arc<CudaContext>, ) -> Result<Arc<CudaStream>>
Exposes this stream to cudarc without transferring destruction responsibility.
§Safety
Retain this Singe stream while any returned cudarc clone or allocation uses it. Cudarc submissions must participate in explicit ordering and exclude conflicting Singe accesses.
§Errors
Returns an error if context is not this stream’s context.
Source§impl Stream
impl Stream
Sourcepub fn add_callback<F>(&self, callback: F) -> Result<()>
pub fn add_callback<F>(&self, callback: F) -> Result<()>
This callback API is slated for eventual deprecation and removal.
If you do not require the callback to execute after a device error, consider using sys::cudaLaunchHostFunc.
Additionally, this callback mechanism is not supported with Stream::begin_capture and Stream::end_capture, unlike sys::cudaLaunchHostFunc.
Adds a callback to be called on the host after all currently enqueued items in the stream have completed.
For each Stream::add_callback call, a callback is executed exactly once.
A panic in the callback is caught and reported on standard error.
The callback blocks later work in the stream until it is finished.
The callback may be passed a successful status or an error code.
In the event of a device error, all subsequently executed callbacks receive an appropriate Status.
Callbacks must not call CUDA functions.
Attempting to do so may result in crate::error::Status::NotPermitted.
Callbacks must not perform any synchronization that may depend on outstanding device work or other callbacks that are not mandated to run earlier.
Callbacks without a mandated order (in independent streams) execute in undefined order and may be serialized.
For the purposes of Unified Memory, callback execution makes a number of guarantees:
- The callback stream is considered idle for the duration of the callback. Thus, for example, a callback may always use memory attached to the callback stream.
- The start of execution of a callback has the same effect as synchronizing an event recorded in the same stream immediately before the callback. It thus synchronizes streams which have been “joined” before the callback.
- Adding device work to any stream does not have the effect of making the stream active until all preceding callbacks have executed. Thus, for example, a callback might use global attached memory even if work has been added to another stream, if it has been properly ordered with an event.
- Completion of a callback does not cause a stream to become active except as described above. The callback stream will remain idle if no device work follows the callback, and will remain idle across consecutive callbacks without device work in between. Thus, for example, stream synchronization can be done by signaling from a callback at the end of the stream.
§Errors
Returns an error if the context cannot be bound, CUDA rejects the callback registration, a previous asynchronous launch reports an error, or CUDA reports runtime initialization diagnostics such as crate::error::Status::NotInitialized, crate::error::Status::CallRequiresNewerDriver, or crate::error::Status::NoDevice.
Sourcepub fn launch_host_func<F>(&self, function: F) -> Result<()>
pub fn launch_host_func<F>(&self, function: F) -> Result<()>
Enqueues a host function to run after all currently enqueued work in this stream completes.
Unlike Stream::add_callback, CUDA does not call this function if the CUDA context is already in an error state, and then drops neither it nor its captures.
The host function must not call CUDA APIs or perform synchronization that depends on outstanding device work.
A panic in the host function is caught and reported on standard error.
§Errors
Returns an error if the stream is capturing, since a graph would run the FnOnce function on every replay.
Also returns an error if the context cannot be bound, CUDA rejects the host function registration, a previous asynchronous launch reports an error, or CUDA reports runtime initialization diagnostics.
Source§impl Stream
impl Stream
Sourcepub fn begin_capture(&self, mode: StreamCaptureMode) -> Result<()>
pub fn begin_capture(&self, mode: StreamCaptureMode) -> Result<()>
Begin graph capture on stream.
When a stream is in capture mode, operations pushed into the stream are captured into a graph instead of executed.
Stream::end_capture returns the graph.
Capture may not be initiated on the legacy default stream.
Capture must be ended on the same stream in which it was initiated, and it may only be initiated if the stream is not already in capture mode.
The capture mode may be queried via Stream::capture_status.
A unique id representing the capture sequence may be queried via Stream::capture_info.
If mode is not StreamCaptureMode::Relaxed, Stream::end_capture must be called on this stream from the same thread.
Kernels captured using this API must not use texture and surface references. Reading or writing through any texture or surface reference is undefined behavior. This restriction does not apply to texture and surface objects.
§Errors
Returns an error if the context cannot be bound, capture cannot begin on this stream, the capture mode is invalid for the current thread state, or a previous asynchronous launch reports an error.
Sourcepub unsafe fn begin_capture_to_graph(
&self,
graph: &Graph,
dependencies: &[GraphDependency],
mode: StreamCaptureMode,
) -> Result<()>
pub unsafe fn begin_capture_to_graph( &self, graph: &Graph, dependencies: &[GraphDependency], mode: StreamCaptureMode, ) -> Result<()>
Begin graph capture on stream.
When a stream is in capture mode, operations pushed into the stream are captured into a graph instead of executed.
Stream::end_capture returns the graph.
Capture may not be initiated on the legacy default stream.
Capture must be ended on the same stream in which it was initiated, and it may only be initiated if the stream is not already in capture mode.
The capture mode may be queried via Stream::capture_status.
A unique id representing the capture sequence may be queried via Stream::capture_info.
If mode is not StreamCaptureMode::Relaxed, Stream::end_capture must be called on this stream from the same thread.
Kernels captured using this API must not use texture and surface references. Reading or writing through any texture or surface reference is undefined behavior. This restriction does not apply to texture and surface objects.
§Safety
This captures into graph’s existing CUDA handle.
Calling Stream::end_capture after this may return that same raw handle; the caller must not wrap it as a second owned Graph.
§Errors
Returns an error if the context cannot be bound, capture cannot begin on this stream, the graph dependencies are invalid, the capture mode is invalid for the current thread state, or a previous asynchronous launch reports an error.
Sourcepub fn end_capture(&self) -> Result<Graph>
pub fn end_capture(&self) -> Result<Graph>
Ends capture on this stream, returning the captured graph.
Capture must have been initiated on stream via a call to Stream::begin_capture.
If capture was invalidated due to a violation of the rules of stream capture, an error is returned.
If the mode argument to Stream::begin_capture was not StreamCaptureMode::Relaxed, this call must be from the same thread as Stream::begin_capture.
§Errors
Returns an error if the context cannot be bound, capture is not active on this stream, the capture has been invalidated, or a previous asynchronous launch reports an error.
Sourcepub fn capture<F>(&self, mode: StreamCaptureMode, f: F) -> Result<Graph>
pub fn capture<F>(&self, mode: StreamCaptureMode, f: F) -> Result<Graph>
Captures stream work recorded by f into a CUDA graph.
This is the scoped form of Stream::begin_capture and Stream::end_capture.
This method attempts to end capture before it returns or resumes a panic.
If f returns an error, this method attempts to end capture to restore stream usability, destroys any graph returned by CUDA, and returns the closure error.
The scope is !Send, so it cannot move to another thread while capture is active.
It retains recorded kernel-code owners in the returned graph.
§Errors
Returns an error if capture cannot begin, if f returns an error, or if capture cannot be ended successfully.
Sourcepub fn capture_executable<F>(
&self,
mode: StreamCaptureMode,
flags: GraphInstantiateFlags,
f: F,
) -> Result<ExecutableGraph>
pub fn capture_executable<F>( &self, mode: StreamCaptureMode, flags: GraphInstantiateFlags, f: F, ) -> Result<ExecutableGraph>
Captures work recorded by f and instantiates the resulting graph with flags.
Recorded kernel-code owners are retained by the executable.
§Errors
Propagates capture setup, closure, capture finalization, and graph-instantiation errors, including unsupported flags or invalid captured nodes.
Sourcepub fn capture_status(&self) -> Result<StreamCaptureStatus>
pub fn capture_status(&self) -> Result<StreamCaptureStatus>
Returns the capture status of this stream. After a successful call, the status is one of the following:
StreamCaptureStatus::None: The stream is not capturing.StreamCaptureStatus::Active: The stream is capturing.StreamCaptureStatus::Invalidated: The stream was capturing but an error has invalidated the capture sequence. The capture sequence must be terminated withStream::end_captureon the stream where it was initiated to continue using the stream.
If this is called on the legacy default stream while a blocking stream on the same device is capturing, it returns crate::error::Status::StreamCaptureImplicit.
The blocking stream capture is not invalidated.
When a blocking stream is capturing, the legacy stream is in an unusable state until the blocking stream capture is terminated. The legacy stream is not supported for stream capture, but attempted use would have an implicit dependency on the capturing stream(s).
§Errors
Returns an error if the context cannot be bound, CUDA cannot query the capture status, or a previous asynchronous launch reports an error.
Sourcepub fn capture_info(&self) -> Result<StreamCaptureInfo>
pub fn capture_info(&self) -> Result<StreamCaptureInfo>
Query stream state related to stream capture.
If called on the legacy default stream while a stream not created with StreamFlags::NON_BLOCKING is capturing, returns crate::error::Status::StreamCaptureImplicit.
Valid data (other than capture status) is returned only if both of the following are true:
- the call succeeds
- the returned capture status is
StreamCaptureStatus::Active
If there is non-zero edge data for one or more current stream dependencies and the query cannot return that data, the call returns crate::error::Status::LossyQuery.
§Errors
Returns an error if the context cannot be bound, CUDA cannot query the capture info, the query would lose non-zero edge data, or a previous asynchronous launch reports an error.
Sourcepub fn update_capture_dependencies(
&self,
dependencies: &[GraphDependency],
mode: StreamCaptureDependencyUpdate,
) -> Result<()>
pub fn update_capture_dependencies( &self, dependencies: &[GraphDependency], mode: StreamCaptureDependencyUpdate, ) -> Result<()>
Modifies the dependency set of a capturing stream. The dependency set is the set of nodes that the next captured node in the stream will depend on.
mode is StreamCaptureDependencyUpdate::Add to add the supplied set to the existing set, or StreamCaptureDependencyUpdate::Set to replace it.
Nodes that are removed from the dependency set by this call do not result in crate::error::Status::StreamCaptureUnjoined if they are unreachable from the stream at Stream::end_capture.
Returns crate::error::Status::IllegalState if the stream is not capturing.
§Errors
Returns an error if the context cannot be bound, the stream is not capturing, the supplied dependencies are invalid, or a previous asynchronous launch reports an error.
Source§impl Stream
impl Stream
Sourcepub fn ensure_not_capturing(&self) -> Result<()>
pub fn ensure_not_capturing(&self) -> Result<()>
Rejects active or invalidated capture before an operation that cannot be recorded.
Call this before synchronous work or ordinary allocation so a rejected operation does not first change the capturing stream’s state.
§Errors
Returns the native stream-capture-unsupported status for active capture or the stream-capture-invalidated status for invalidated capture. Also propagates capture-state query and context binding errors.
Source§impl Stream
impl Stream
Sourcepub unsafe fn from_raw(raw: RawStream) -> Result<Self>
pub unsafe fn from_raw(raw: RawStream) -> Result<Self>
Adopts a raw stream with the release responsibility recorded in raw.ownership.
An owned handle is synchronized and destroyed when the last clone drops; a borrowed handle keeps its owner token instead.
Use Stream::shutdown to surface synchronization or destruction errors explicitly.
§Safety
raw.handle must be a valid CUDA stream of raw.context.
An owned handle must not be destroyed elsewhere; a borrowed handle must stay valid while its owner token lives.
§Errors
Returns Error::NullHandle if raw.handle is null.
Sourcepub unsafe fn borrow_with_owner(
handle: cudaStream_t,
context: Arc<Context>,
owner: Arc<dyn Any + Send + Sync>,
) -> Result<Self>
pub unsafe fn borrow_with_owner( handle: cudaStream_t, context: Arc<Context>, owner: Arc<dyn Any + Send + Sync>, ) -> Result<Self>
Borrows a stream while retaining the library object that owns its native handle. Default legacy streams are accepted; per-thread default streams cannot be shared across threads.
§Safety
The handle must belong to context and remain valid while owner is retained.
External work must obey this wrapper’s access ordering and capture lifecycle.
§Errors
Returns Error::ThreadLocalStreamUnsupported for the per-thread default-stream sentinel.
Also propagates context binding errors.
Other handle validity and external ownership requirements remain the caller’s responsibility.
Source§impl Stream
impl Stream
Sourcepub fn into_raw(self) -> StdResult<RawStream, Self>
pub fn into_raw(self) -> StdResult<RawStream, Self>
Transfers the native handle, context and destruction responsibility to the caller. Destroy owned handles explicitly; retain borrowed ownership tokens through every use. Returns the unchanged stream if another clone or pending capture cleanup still retains it.
§Errors
Returns Err(self) if another stream clone retains the wrapper or shared capture cleanup still holds deferred owners, frees, or foreign tokens.
The returned wrapper remains usable and retains its release responsibility.
Source§impl Stream
impl Stream
Sourcepub fn sync_scope<'env, F, R>(&self, f: F) -> Result<R>
pub fn sync_scope<'env, F, R>(&self, f: F) -> Result<R>
Runs f with a stream scope and synchronizes this stream before returning.
Use this for scoped asynchronous operations that borrow host or device memory until stream completion.
For CUDA graph capture, use Stream::capture or Stream::capture_executable.
The completion wait also runs when f unwinds.
If CUDA completion cannot be established, the process aborts before returning borrowed storage to the caller.
§Errors
Propagates capture-state query errors, rejects active or invalidated capture, and returns errors from f or stream synchronization.
If both f and synchronization fail and cleanup can drain the stream, the closure error takes precedence.
Sourcepub fn complete<R, E>(
&self,
f: impl FnOnce() -> StdResult<R, E>,
) -> StdResult<R, E>
pub fn complete<R, E>( &self, f: impl FnOnce() -> StdResult<R, E>, ) -> StdResult<R, E>
Runs f, then waits for this stream even when f fails or unwinds, so borrowed operands outlive the work f enqueues.
Capture is rejected before f runs.
This is StreamBinding::sync_scope on a borrowed binding of this stream.
§Errors
Converts capture-query, context binding, capture rejection, and stream synchronization errors into E.
Errors returned by f take precedence over a synchronization error.
Source§impl Stream
impl Stream
Sourcepub unsafe fn memory_operations(
&self,
operations: &[MemoryOperation],
) -> Result<()>
pub unsafe fn memory_operations( &self, operations: &[MemoryOperation], ) -> Result<()>
Enqueues an ordered batch of at most 255 memory operations.
§Safety
Addresses must be live, naturally aligned, non-managed memory accessible in this context. Keep storage live and exclude conflicting accesses until completion or every captured replay. Waits must be satisfiable without circular dependencies, with event ordering visible to CUDA.
§Errors
Returns Error::OutOfRange for 256 or more operations, Error::NullPointer for a null wait or write address, or Error::Misaligned for a misaligned one.
Also propagates context binding and native batch errors, including unsupported operations or device capabilities.
An empty batch succeeds without binding the context or calling CUDA.
Source§impl Stream
impl Stream
Sourcepub unsafe fn wait_value32(
&self,
address: DevicePtr,
value: u32,
condition: WaitCondition,
flags: WaitFlags,
) -> Result<()>
pub unsafe fn wait_value32( &self, address: DevicePtr, value: u32, condition: WaitCondition, flags: WaitFlags, ) -> Result<()>
Waits for a naturally aligned device word to satisfy the condition.
§Safety
Follow Stream::memory_operations’s storage, ordering and progress requirements.
§Errors
Returns Error::NullPointer for a null address, or Error::Misaligned for one not aligned to the native word size.
Also propagates context binding and native wait errors for unsupported conditions, flags, or device capabilities.
Sourcepub unsafe fn write_value32(&self, address: DevicePtr, value: u32) -> Result<()>
pub unsafe fn write_value32(&self, address: DevicePtr, value: u32) -> Result<()>
Writes a naturally aligned device word with the native stream memory fence.
§Safety
Follow Stream::memory_operations’s storage and ordering requirements.
§Errors
Returns Error::NullPointer for a null address, or Error::Misaligned for one not aligned to the native word size.
Also propagates context binding and native write errors, including unsupported memory operations on the device.
Source§impl Stream
impl Stream
Sourcepub unsafe fn wait_value64(
&self,
address: DevicePtr,
value: u64,
condition: WaitCondition,
flags: WaitFlags,
) -> Result<()>
pub unsafe fn wait_value64( &self, address: DevicePtr, value: u64, condition: WaitCondition, flags: WaitFlags, ) -> Result<()>
Waits for a naturally aligned device word to satisfy the condition.
§Safety
Follow Stream::memory_operations’s storage, ordering and progress requirements.
§Errors
Returns Error::NullPointer for a null address, or Error::Misaligned for one not aligned to the native word size.
Also propagates context binding and native wait errors for unsupported conditions, flags, or device capabilities.
Sourcepub unsafe fn write_value64(&self, address: DevicePtr, value: u64) -> Result<()>
pub unsafe fn write_value64(&self, address: DevicePtr, value: u64) -> Result<()>
Writes a naturally aligned device word with the native stream memory fence.
§Safety
Follow Stream::memory_operations’s storage and ordering requirements.
§Errors
Returns Error::NullPointer for a null address, or Error::Misaligned for one not aligned to the native word size.
Also propagates context binding and native write errors, including unsupported memory operations on the device.
Source§impl Stream
impl Stream
Sourcepub fn defer_drop_until_capture_end<T>(&self, owner: Arc<T>) -> Result<()>
pub fn defer_drop_until_capture_end<T>(&self, owner: Arc<T>) -> Result<()>
Defers destruction of an unused resource until capture ends, if active. This permits eager APIs to reject capture without calling a capture-incompatible destructor while releasing their arguments. It does not retain resources for graph replay. End capture through this stream wrapper to release these owners. Avoid owners that retain this stream, which would create a reference cycle.
§Errors
Propagates capture-state query and context binding errors.
If capture is inactive, owner is dropped before this call returns.
Sourcepub fn to_borrowed(&self) -> BorrowedStream
pub fn to_borrowed(&self) -> BorrowedStream
Returns a borrowed stream wrapper retaining a clone of this stream’s owner.
Sourcepub unsafe fn to_unretained(&self) -> BorrowedStream
pub unsafe fn to_unretained(&self) -> BorrowedStream
Returns a borrowed stream wrapper that does not retain this stream’s owner.
A native owner passed to Self::defer_drop_until_capture_end holds one, since retaining the stream would form a reference cycle.
§Safety
The returned wrapper must not be used after the last owner of this stream is dropped.
Sourcepub fn synchronize(&self) -> Result<()>
pub fn synchronize(&self) -> Result<()>
Blocks until stream has completed all operations.
If ContextFlags::SCHEDULE_BLOCKING_SYNC was set for this device, the host thread will block until the stream is finished with all of its tasks.
Uses standard default stream semantics.
§Errors
Returns an error if stream synchronization fails or if a previous asynchronous launch reported an error.
CUDA may also return initialization-related errors such as crate::error::Status::NotInitialized, crate::error::Status::CallRequiresNewerDriver, or crate::error::Status::NoDevice if this call initializes internal runtime state.
Callbacks must not call CUDA functions; see Stream::add_callback.
Sourcepub fn synchronize_or_abort(&self)
pub fn synchronize_or_abort(&self)
Waits for queued work on this stream, or prints the error and aborts the process if the wait fails.
Cleanup code calls this before releasing borrowed storage that queued work may still access.
Sourcepub fn shutdown(self) -> Result<()>
pub fn shutdown(self) -> Result<()>
Synchronizes this stream and releases its native ownership.
Owned handles are destroyed. Borrowed handles release their external owner token after synchronization instead of destroying the handle. This may block while waiting for stream work and callbacks. For owned handles, destruction is attempted even if synchronization fails, and the synchronization error takes precedence over a destruction error.
§Errors
Returns Error::OwnershipShared if another stream clone or borrowed owner still retains the handle.
Also propagates capture-state rejection, deferred-free enqueue, context binding, synchronization, or owned-handle destruction errors.
Synchronization errors take precedence over destruction errors.
Sourcepub fn query(&self) -> Result<bool>
pub fn query(&self) -> Result<bool>
Returns true if all operations in stream have completed, or false if not.
For the purposes of Unified Memory, a return value of true is equivalent to having called Stream::synchronize.
Uses standard default stream semantics.
§Errors
Returns an error if querying the stream fails or if a previous asynchronous launch reported an error.
CUDA may also return initialization-related errors such as crate::error::Status::NotInitialized, crate::error::Status::CallRequiresNewerDriver, or crate::error::Status::NoDevice if this call initializes internal runtime state.
Callbacks must not call CUDA functions; see Stream::add_callback.
Sourcepub fn wait_event(&self, event: &Event, flags: EventWaitFlags) -> Result<()>
pub fn wait_event(&self, event: &Event, flags: EventWaitFlags) -> Result<()>
Makes all future work submitted to stream wait for all work captured in event.
See sys::cudaEventRecord for details on what is captured by an event.
flags controls how strictly the wait is enforced during capture.
Synchronization is performed efficiently on the device when applicable.
event may be from a different device than stream.
§Errors
Returns an error if the stream cannot wait on the event or if a previous asynchronous launch reported an error.
Sourcepub fn fork(&self) -> Result<Self>
pub fn fork(&self) -> Result<Self>
Creates a nonblocking stream ordered after this stream’s current work.
The new stream uses this stream’s context and priority.
Later submissions to either stream can execute independently.
Call Stream::join to order subsequent work after a branch completes.
During capture, keep the branch alive until capture ends and join it back into the capturing stream before ending capture.
§Errors
Returns an error if CUDA cannot create the stream or establish its event dependency.
Sourcepub fn join(&self, other: &Self) -> Result<()>
pub fn join(&self, other: &Self) -> Result<()>
Orders subsequent work on this stream after the other stream’s current work.
Records an event on other and enqueues a wait on this stream without blocking the host.
The other stream may belong to a different CUDA context or device.
Work submitted to other after this call is independent of the dependency.
§Errors
Returns an error if CUDA cannot record the event or enqueue the wait.
Sourcepub fn join_regions(&self, regions: &[DeviceRegion<'_>]) -> Result<()>
pub fn join_regions(&self, regions: &[DeviceRegion<'_>]) -> Result<()>
Orders subsequent work after the readiness streams of these device regions.
All regions must belong to this stream’s context. Each distinct producer stream contributes one event dependency. This does not establish initialization or retain allocations for later work. Borrowed consumers must keep their resources in a draining scope; raw queued consumers must uphold their resource and access contracts.
§Errors
Returns Error::MemoryContextMismatch before submitting dependencies if any region belongs to another context, or a CUDA error if an event cannot be recorded or waited on.
Sourcepub fn flags(&self) -> Result<StreamFlags>
pub fn flags(&self) -> Result<StreamFlags>
Query the flags of a stream.
Returns the stream flags.
See StreamFlags for the valid flags.
Uses standard default stream semantics.
§Errors
Returns an error if CUDA cannot query the flags or if a previous asynchronous launch reported an error.
CUDA may also return initialization-related errors such as crate::error::Status::NotInitialized, crate::error::Status::CallRequiresNewerDriver, or crate::error::Status::NoDevice if this call initializes internal runtime state.
Callbacks must not call CUDA functions; see Stream::add_callback.
Sourcepub fn priority(&self) -> Result<i32>
pub fn priority(&self) -> Result<i32>
Query the priority of a stream.
Returns the stream priority.
If the stream was created with a priority outside the meaningful numerical range returned by Device::stream_priority_range, this returns the clamped priority.
See StreamOptions::priority for details about priority clamping.
§Errors
Returns an error if the context cannot be bound, CUDA cannot query the priority, a previous asynchronous launch reports an error, or CUDA reports runtime initialization diagnostics.
Sourcepub fn id(&self) -> Result<u64>
pub fn id(&self) -> Result<u64>
Returns a stream identifier that remains unique for the life of the program.
The stream handle may refer to any of the following:
- a stream created via any of the CUDA runtime APIs such as
sys::cudaStreamCreate,Context::create_stream, or their driver API equivalents such assys::cuStreamCreateorsys::cuStreamCreateWithPriority. Passing an invalid handle results in undefined behavior. - the special legacy default stream and per-thread default stream. The driver API equivalents of these are also accepted.
§Errors
Returns an error if the context cannot be bound, CUDA cannot query the stream identifier, a previous asynchronous launch reports an error, or CUDA reports runtime initialization diagnostics.
Sourcepub fn device(&self) -> Result<Device>
pub fn device(&self) -> Result<Device>
Returns the device of the stream.
§Errors
Returns an error if the context cannot be bound, CUDA cannot query the stream device, a previous asynchronous launch reports an error, or CUDA reports runtime initialization diagnostics.
Sourcepub fn as_raw(&self) -> cudaStream_t
pub fn as_raw(&self) -> cudaStream_t
Returns the borrowed native stream handle without transferring ownership.
Source§impl Stream
impl Stream
Sourcepub fn submit<O: Operation>(
&self,
operation: O,
) -> Result<Submission<O::Output, O::Pending>>
pub fn submit<O: Operation>( &self, operation: O, ) -> Result<Submission<O::Output, O::Pending>>
Submits owned work with independent resource retention and checked completion.
§Errors
Propagates errors from the operation’s Operation::submit_on implementation, including execution setup, enqueue, and completion registration failures.
An error can occur after some native work has been queued; the execution ledger retains its resources through cleanup.
Source§impl Stream
impl Stream
Sourcepub unsafe fn enqueue_async<T, F>(
&self,
resources: Resources,
enqueue: F,
) -> Result<Submission<T>>
pub unsafe fn enqueue_async<T, F>( &self, resources: Resources, enqueue: F, ) -> Result<Submission<T>>
Submits arbitrary raw work with an explicitly supplied ownership ledger.
§Safety
The resources must retain every native owner and declare all accesses before enqueue runs.
Follow crate::submission::Execution::enqueue’s native execution contract.
§Errors
Propagates capture-state, context, access-tracking, dependency-ordering, and completion-event errors, errors returned by enqueue, and failures to start or submit to the completion worker.
The callback may already have enqueued work when a later step fails.
Trait Implementations§
Source§impl AsStream for Stream
impl AsStream for Stream
Source§fn as_raw(&self) -> cudaStream_t
fn as_raw(&self) -> cudaStream_t
Source§fn synchronize(&self) -> Result<()>
fn synchronize(&self) -> Result<()>
Source§fn synchronize_or_abort(&self)
fn synchronize_or_abort(&self)
Source§fn capture_status(&self) -> Result<StreamCaptureStatus>
fn capture_status(&self) -> Result<StreamCaptureStatus>
Source§fn ensure_not_capturing(&self) -> Result<()>
fn ensure_not_capturing(&self) -> Result<()>
Source§fn wait_event(&self, event: &Event, flags: EventWaitFlags) -> Result<()>
fn wait_event(&self, event: &Event, flags: EventWaitFlags) -> Result<()>
event. Read moreSource§fn join_regions(&self, regions: &[DeviceRegion<'_>]) -> Result<()>
fn join_regions(&self, regions: &[DeviceRegion<'_>]) -> Result<()>
impl Eq for Stream
Auto Trait Implementations§
impl !RefUnwindSafe for Stream
impl !UnwindSafe for Stream
impl Forget for Stream
impl Freeze for Stream
impl Move for Stream
impl Send for Stream
impl Sync for Stream
impl Unpin for Stream
impl UnsafeUnpin for Stream
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.