Skip to main content

Graph

Struct Graph 

Source
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>

Source

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 Handle the 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§

Source§

impl<R: Runtime> Clone for Graph<R>

Source§

fn clone(&self) -> Self

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<R: Runtime> Debug for Graph<R>

Source§

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

Formats the value using the given formatter. Read more

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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<T> TuneInputs for T
where T: Clone + Send + Sync + 'static,

Source§

type At<'a> = T

The concrete input type at lifetime 'a.