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 as a single dispatch
against its original buffers. 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 — one dispatch re-running every recorded kernel 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.
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>
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> 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