pub struct Stream { /* private fields */ }
Expand description
CUDA stream.
Implementations§
Source§impl Stream
impl Stream
Sourcepub fn null() -> Self
pub fn null() -> Self
Create a Stream
object that represent the default stream, also known as the null stream.
Refer to the CUDA documentation for more information regarding the default (“null”) stream:
§Prefer owned streams
It is recommended to use owned streams as much as possible, for two reasons:
- Using streams to separate semanticly unrelated streams of operations allows the GPU to overlap operations and improved parallelism.
- Using the default stream can incur implicit synchronization, even on other streams, which causes their performance to degrade.
Note that it is not enforced that there is only one Stream
object that represents the
default stream. This is safe because all operations are serialized anyway.
Sourcepub async fn synchronize(&self) -> Result<(), Error>
pub async fn synchronize(&self) -> Result<(), Error>
Synchronize stream. This future will only return once all currently enqueued work on the stream is done.
§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.