pub struct Stream { /* private fields */ }
Expand description

Represents an NPP stream.

An NPP stream is a thin wrapper around a normal CUDA stream (async_cuda_core::Stream). It manages some additional context information required in NPP to statelessly execute on a user-provided stream.

This struct implements Deref such that it can be used as a normal async_cuda_core::Stream as well.

Usage

If the caller wants to use a stream context for mixed NPP and non-NPP operations, they should create an NPP stream and pass it as CUDA stream when desired. This should work out-of-the-box since Stream dereferences to async_cuda_core::Stream.

Implementations§

source§

impl Stream

source

pub fn null() -> Self

Create an NPP Stream that represent the default stream, also known as the null stream.

This type is a wrapper around the actual CUDA stream type: async_cuda_core::Stream.

source

pub async fn new() -> Result<Self, Error>

Create a new Stream for use with NPP.

This type is a wrapper around the actual CUDA stream type: async_cuda_core::Stream.

Methods from Deref<Target = Stream>§

source

pub async fn synchronize(&self) -> impl Future<Output = Result<(), Error>>

Synchronize stream. This future will only return once all currently enqueued work on the stream is done.

CUDA documentation

Behavior

In constrast to most of the API, this future does not become ready eagerly. Instead, a callback is pushed onto the given stream that will be invoked to make the future ready once all work on the stream that was previously queued asynchroneously is completed.

Internally, the future uses cudaStreamAddCallback to schedule the callback on the stream.

source

pub fn inner(&self) -> &Stream

Access the inner synchronous implementation of Stream.

Trait Implementations§

source§

impl Deref for Stream

§

type Target = Stream

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.