pub struct Graph<R: Runtime> { /* private fields */ }Expand description
A captured graph produced by ComputeClient::stop_capture: a recorded
launch sequence that replay re-runs against its original
buffers, skipping the launch path it was recorded from. Cheap to clone
(shares one backend graph).
The graph itself lives in the backend server, referenced here only by
GraphId; this handle holds a reference-counted owner that releases the
backend graph once the last clone drops. The graph replays against the exact
device buffers used during capture. The caller keeps those input/output
Handles alive and, each iteration, writes fresh inputs into the input
handles (same device pointers) and reads the output handles after replaying —
see ComputeClient::stop_capture.
Stream ordering. replay always dispatches on the
stream the graph was captured on, but input writes and output reads go on the
writing client’s current stream. They are ordered against the replay only
when they land on that same stream, so keep the client pinned to the capture
stream (via set_stream) — or issue all writes,
replays, and reads from the same unpinned client — for the whole decode loop.
Refreshing inputs from a client on a different stream races the replay and
silently feeds it stale data.
Implementations§
Source§impl<R: Runtime> Graph<R>
impl<R: Runtime> Graph<R>
Sourcepub unsafe fn replay(&self)
pub unsafe fn replay(&self)
Replay the captured launch sequence — every recorded kernel re-run against the buffers it was captured with, on the stream it was captured on. Self-contained (the handle owns its device handle); no client needed.
How much of the launch path this skips depends on the backend: a hardware graph (CUDA, HIP) replays as one dispatch, while a software graph (wgpu) re-encodes the recorded dispatches from prebuilt state. Either way pipeline lookup, binding resolution and metadata upload happened once, at capture.
Non-blocking, like a kernel launch: this enqueues the dispatch and returns
immediately. A replay failure is not reported here — it lands in the
stream’s error queue and surfaces on the next
sync/flush (e.g. when
reading the output back).
§Safety
The dispatch re-runs the recorded kernels against the raw device pointers captured with them; nothing validates those buffers still exist or are unshared. The caller must guarantee, until the replay’s work completes on the stream:
- Liveness — every
Handlethe captured kernels read or wrote is still allocated. Freeing one returns its memory to the pool, and a later replay reads or corrupts whatever the allocator has since placed there. - No concurrent use — no other stream or thread touches buffers the graph reads or writes while the replay executes; the replay is ordered only against work on its capture stream.
- Same-stream refreshes — input writes and output reads are issued on
the capture stream (keep the client pinned to it via
set_stream, or do everything from the one client), so they order against the replay instead of racing it.
Trait Implementations§
Auto Trait Implementations§
impl<R> !RefUnwindSafe for Graph<R>
impl<R> !UnwindSafe for Graph<R>
impl<R> Freeze for Graph<R>
impl<R> Send for Graph<R>
impl<R> Sync for Graph<R>
impl<R> Unpin for Graph<R>
impl<R> UnsafeUnpin for Graph<R>where
Arc<GraphHandle<R>>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more