Skip to main content

OptimizedGraph

Struct OptimizedGraph 

Source
pub struct OptimizedGraph {
    pub roots: Vec<NodeId>,
    pub generation: u64,
    /* private fields */
}
Expand description

The transient view optimize_graph returns — the realize-roots it optimized for plus the topology generation it ran under. It is not stored on the graph; the optimized form is the graph itself (with its Op::Branch decision points, of which A3a emits none).

The dispatch order is derived on demand from fuel-graph’s run extraction so the run view is always recomputed from the current arena — never a stale snapshot. This is the shape PR-A3b swaps the bridge onto in place of ExecutionPlan::order.

Fields§

§roots: Vec<NodeId>

The realize roots this optimization targeted (the same targets the bridge passes today).

§generation: u64

SystemTopology generation snapshotted at optimize time — mirrors crate::plan::ExecutionPlan::generation so a later chunk-boundary check can detect a topology shift exactly as the executor does today.

Implementations§

Source§

impl OptimizedGraph

Source

pub fn runs(&self, graph: &Graph) -> Vec<Run>

Extract the runs of the optimized graph, in topological order of their entries (delegates to extract_runs_multi). A branchless, single-residency graph yields exactly one run.

Source

pub fn placement_of(&self, node: NodeId) -> Option<DeviceLocation>

The device the optimizer decided this node runs on — the observable form of the placement decision, for callers that need to check where work landed rather than infer it from timing.

This is the resolved effective placement, not a hint. It is the same map the residency pass uses to decide where to stitch cross-device copies, resolved by the priority in effective_placements: residency-declaring ops → explicit Graph::placement → input residency → plan winner → backend stamp → view pass-through.

Do not substitute fuel_graph::Graph::placement for this. That is only level 2 of the six — a hint set by inserted copies and caller overrides. The planner’s actual choice for a compute node arrives at level 4 (“plan winner”), so Graph::placement returns None for precisely the nodes whose placement is interesting, and reading that None as “unplaced” is a wrong answer that looks like a null one.

Returns None if the node is unknown to this optimization or if the residency pass did not run (no pinned_device; see the field docs) — the two are deliberately not distinguished here because neither means “placed nowhere”. Use OptimizedGraph::has_placements to tell them apart before drawing a conclusion from a None.

Source

pub fn has_placements(&self) -> bool

Whether placement was computed at all. Distinguishes “this node has no placement” from “no node does, because the pass was skipped” — the difference between a real observation and an absent instrument.

Source

pub fn placements(&self) -> impl Iterator<Item = (NodeId, DeviceLocation)> + '_

Every resolved (node, device) pair, for dumping a whole graph’s placement. Empty iterator when placement was not computed — check OptimizedGraph::has_placements first if that distinction matters.

Source

pub fn dispatch_order(&self, graph: &Graph) -> Vec<NodeId>

The flat executable dispatch order — the arm-0 single-route lowering (PR-A4). It follows arm 0 through every Op::Branch (pre-run, arm-0’s run, post-run) and skips every non-arm-0 arm’s run, via fuel_graph::lower_runs_arm0.

For a graph with zero Op::Branch nodes this is the exact NodeId sequence today’s executor walks via crate::plan::compile_plan(...).order — the equivalence gate proves it (no arm to skip ⇒ identical to concatenating fuel_graph::run::lower_run over the runs). For a branched graph it is the single-route lowering on arm 0 = the DP winner (the route realize used before the branch was recorded), so a branched graph realizes to the same result. The Phase-C runtime picker is what will later select non-arm-0 arms at the decision points.

Source

pub fn branch_count(&self, graph: &Graph) -> usize

The number of Op::Branch decision points in the arena. Counting over the whole arena (not just the roots’ reachable set) is the stronger claim. Zero for a single-route graph (CPU-only build, or any graph with no genuine ≥2-placement fork); PR-A4’s deliberate-fork pathfinder emits one per genuine placement fork.

Trait Implementations§

Source§

impl Clone for OptimizedGraph

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 Debug for OptimizedGraph

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more