pub struct Stream { /* private fields */ }
Expand description
A stream of work for the device to perform.
See the module-level documentation for more information.
Implementations§
source§impl Stream
impl Stream
sourcepub fn new(flags: StreamFlags, priority: Option<i32>) -> CudaResult<Stream>
pub fn new(flags: StreamFlags, priority: Option<i32>) -> CudaResult<Stream>
Create a new stream with the given flags and optional priority.
By convention, priority
follows a convention where lower numbers represent greater
priorities. That is, work in a stream with a lower priority number may pre-empt work in
a stream with a higher priority number. Context::get_stream_priority_range
can be used
to get the range of valid priority values; if priority is set outside that range, it will
be automatically clamped to the lowest or highest number in the range.
Examples:
use rustacuda::stream::{Stream, StreamFlags};
// With default priority
let stream = Stream::new(StreamFlags::NON_BLOCKING, None).unwrap();
// With specific priority
let priority = Stream::new(StreamFlags::NON_BLOCKING, 1i32.into()).unwrap();
sourcepub fn get_flags(&self) -> CudaResult<StreamFlags>
pub fn get_flags(&self) -> CudaResult<StreamFlags>
Return the flags which were used to create this stream.
Examples:
use rustacuda::stream::{Stream, StreamFlags};
let stream = Stream::new(StreamFlags::NON_BLOCKING, None).unwrap();
assert_eq!(StreamFlags::NON_BLOCKING, stream.get_flags().unwrap());
sourcepub fn get_priority(&self) -> CudaResult<i32>
pub fn get_priority(&self) -> CudaResult<i32>
Return the priority of this stream.
If this stream was created without a priority, returns the default priority. If the stream was created with a priority outside the valid range, returns the clamped priority.
Examples:
use rustacuda::stream::{Stream, StreamFlags};
let stream = Stream::new(StreamFlags::NON_BLOCKING, 1i32.into()).unwrap();
println!("{}", stream.get_priority().unwrap());
sourcepub fn synchronize(&self) -> CudaResult<()>
pub fn synchronize(&self) -> CudaResult<()>
Wait until a stream’s tasks are completed.
Waits until the device has completed all operations scheduled for this stream.
Examples:
use rustacuda::stream::{Stream, StreamFlags};
let stream = Stream::new(StreamFlags::NON_BLOCKING, 1i32.into()).unwrap();
// ... queue up some work on the stream
// Wait for the work to be completed.
stream.synchronize().unwrap();
sourcepub fn drop(stream: Stream) -> DropResult<Stream>
pub fn drop(stream: Stream) -> DropResult<Stream>
Destroy a Stream
, returning an error.
Destroying a stream can return errors from previous asynchronous work. This function destroys the given stream and returns the error and the un-destroyed stream on failure.
Example:
use rustacuda::stream::{Stream, StreamFlags};
let stream = Stream::new(StreamFlags::NON_BLOCKING, 1i32.into()).unwrap();
match Stream::drop(stream) {
Ok(()) => println!("Successfully destroyed"),
Err((e, stream)) => {
println!("Failed to destroy stream: {:?}", e);
// Do something with stream
},
}