pub struct GpuStream { /* private fields */ }Expand description
A CUDA stream obtained from the libtorch stream pool.
RAII: the stream is returned to the pool on drop.
Implementations§
Source§impl GpuStream
impl GpuStream
Sourcepub fn new(device: Device, high_priority: bool) -> Result<Self>
pub fn new(device: Device, high_priority: bool) -> Result<Self>
Create a new CUDA stream from the pool on the given device.
high_priority: if true, uses a high-priority stream that preempts
normal-priority work at SM boundaries.
Sourcepub fn synchronize(&self) -> Result<()>
pub fn synchronize(&self) -> Result<()>
Block the CPU thread until all work on this stream completes.
Sourcepub fn wait_event(&self, event: &GpuEvent) -> Result<()>
pub fn wait_event(&self, event: &GpuEvent) -> Result<()>
Make this stream wait for a recorded event before executing any further work. Does not block the CPU.
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Non-blocking check: has all work on this stream completed?
Sourcepub fn current(device: Device) -> Result<Self>
pub fn current(device: Device) -> Result<Self>
The calling thread’s current stream on device (the default
stream unless a StreamGuard is active). The returned value
owns only the wrapper — dropping it never destroys the
underlying stream.
Trait Implementations§
Auto Trait Implementations§
impl !Sync for GpuStream
impl Freeze for GpuStream
impl RefUnwindSafe for GpuStream
impl Unpin for GpuStream
impl UnsafeUnpin for GpuStream
impl UnwindSafe for GpuStream
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
Mutably borrows from an owned value. Read more