Skip to main content

Stream

Struct Stream 

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

An asynchronous work queue on the current CUDA device.

Implementations§

Source§

impl Stream

Source

pub fn begin_capture(&self, mode: CaptureMode) -> Result<()>

Begin recording operations submitted to this stream into a graph.

Source

pub fn end_capture(&self) -> Result<Graph>

Stop capture and return the graph of everything recorded.

Source

pub fn capture<F>(&self, mode: CaptureMode, f: F) -> Result<Graph>
where F: FnOnce(&Stream) -> Result<()>,

Convenience wrapper: run f, capturing its submissions to this stream, and return the resulting graph.

Source

pub fn is_capturing(&self) -> Result<bool>

true if this stream is currently recording into a graph.

Source§

impl Stream

Source

pub fn new() -> Result<Self>

Create a stream with default (legacy-default-stream-synchronizing) flags on the current device.

Source

pub fn non_blocking() -> Result<Self>

Create a non-blocking stream — does not synchronize with the legacy default stream.

Source

pub unsafe fn from_raw(handle: cudaStream_t) -> Self

Adopt a raw cudaStream_t handle. The wrapper will call cudaStreamDestroy on drop.

§Safety

handle must be a live stream on the current device. Do not destroy it externally.

Source

pub fn with_flags(flags: u32) -> Result<Self>

Create a stream with raw flags (see cudaStreamFlags).

Source

pub fn synchronize(&self) -> Result<()>

Block the calling thread until all prior work on this stream is complete.

Source

pub fn is_complete(&self) -> Result<bool>

Ok(true) if all queued work has finished, Ok(false) if work remains.

Source

pub fn device(&self) -> Device

The device this stream belongs to.

Source

pub fn as_raw(&self) -> cudaStream_t

Raw cudaStream_t handle. Use with care.

Source

pub fn with_priority(flags: u32, priority: i32) -> Result<Self>

Create a stream with a specific scheduling priority (lower = higher priority). Use stream_priority_range to discover the legal range on the current device.

Source

pub fn priority(&self) -> Result<i32>

This stream’s scheduling priority.

Source

pub fn flags(&self) -> Result<u32>

This stream’s flags bitmask.

Source

pub fn wait_event(&self, event: &Event, flags: u32) -> Result<()>

Wait for event on this stream — blocks future work on self until the event has completed.

Source§

impl Stream

Source

pub fn launch_host_func<F>(&self, f: F) -> Result<()>
where F: FnOnce() + Send + 'static,

Enqueue a host-side callback on this stream. Runs on a driver-owned thread after prior stream work completes.

The closure is boxed and freed after it runs; a panic inside aborts the process.

Source

pub unsafe fn write_value_32( &self, addr: *mut c_void, value: u32, flags: u32, ) -> Result<()>

Enqueue a 32-bit write of value to device memory addr.

§Safety

addr must be a live device-addressable pointer.

Source

pub unsafe fn write_value_64( &self, addr: *mut c_void, value: u64, flags: u32, ) -> Result<()>

§Safety

Same as [write_value_32].

Source

pub unsafe fn wait_value_32( &self, addr: *mut c_void, value: u32, flags: u32, ) -> Result<()>

Block the stream until the 32-bit device memory at addr satisfies the condition selected by flags (GEQ / EQ / AND / NOR, optionally OR’d with FLUSH).

§Safety

addr must be a live device-addressable pointer.

Source

pub unsafe fn wait_value_64( &self, addr: *mut c_void, value: u64, flags: u32, ) -> Result<()>

§Safety

Same as [wait_value_32].

Source

pub unsafe fn attach_mem_async( &self, dev_ptr: *mut c_void, length: usize, flags: u32, ) -> Result<()>

Associate a managed-memory region with this stream (cudaStreamAttachMemAsync). Pass flags = 0 for the default.

§Safety

dev_ptr must be a managed-memory allocation.

Source

pub fn copy_attributes_from(&self, src: &Stream) -> Result<()>

Copy CUDA-managed attributes (access-policy window, sync policy) from src onto self.

Source

pub unsafe fn batch_mem_op( &self, params: &mut [CUstreamBatchMemOpParams], flags: u32, ) -> Result<()>

Enqueue a batch of stream mem-ops (WAIT_VALUE_32/64, WRITE_VALUE_32/64) atomically. Much cheaper than issuing the ops one at a time.

Build entries with baracuda_cuda_sys::types::CUstreamBatchMemOpParams::write_value_32 etc. Pass flags = 0 for the default.

§Safety

Every entry’s address must be a live device-addressable pointer.

Trait Implementations§

Source§

impl Clone for Stream

Source§

fn clone(&self) -> Stream

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Stream

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.