ironaccelerator_core/stream.rs
1//! Streams and events. A stream is the unit of asynchronous submission;
2//! every backend has one (CUDA streams, HIP streams, Metal command queues,
3//! QNN graph executors).
4
5use crate::error::Result;
6
7#[cfg(not(feature = "std"))]
8use alloc::boxed::Box;
9
10pub trait Stream: Send + Sync {
11 /// Submit a no-op barrier and return when GPU has caught up.
12 fn synchronize(&self) -> Result<()>;
13 /// Whether all previously enqueued work has completed.
14 fn is_idle(&self) -> bool;
15 /// Record an event on this stream.
16 fn record(&self) -> Result<Box<dyn Event>>;
17}
18
19pub trait Event: Send + Sync {
20 /// Block until the recorded point is reached.
21 fn wait(&self) -> Result<()>;
22 /// Whether the event has fired.
23 fn is_complete(&self) -> bool;
24 /// Elapsed time in milliseconds between this event and `start`.
25 fn elapsed_ms(&self, start: &dyn Event) -> Result<f32>;
26}