pub struct ComputeGraph { /* private fields */ }Expand description
Directed acyclic graph of compute nodes with resource binding management.
Implementations§
Source§impl ComputeGraph
impl ComputeGraph
Sourcepub fn add_node(&mut self, node: GraphNode) -> Result<(), GraphError>
pub fn add_node(&mut self, node: GraphNode) -> Result<(), GraphError>
Add a node to the graph.
§Errors
Returns GraphError::DuplicateNode if a node with the same ID already
exists.
Sourcepub fn bind_resource(
&mut self,
node_id: u32,
binding: ResourceBinding,
) -> Result<(), GraphError>
pub fn bind_resource( &mut self, node_id: u32, binding: ResourceBinding, ) -> Result<(), GraphError>
Attach a resource binding to an existing node.
§Errors
Returns GraphError::NodeNotFound if the node does not exist.
Returns GraphError::IncompatibleBinding if the resource type is not
appropriate for the node kind (e.g. binding a buffer to a Barrier).
Sourcepub fn add_edge(&mut self, from: u32, to: u32) -> Result<(), GraphError>
pub fn add_edge(&mut self, from: u32, to: u32) -> Result<(), GraphError>
Add a directed edge: from → to (node from must execute before to).
§Errors
GraphError::NodeNotFoundif either node is missing.GraphError::CyclicEdgeif the edge would introduce a cycle.
Sourcepub fn execution_order(&self) -> Result<ExecutionPlan, GraphError>
pub fn execution_order(&self) -> Result<ExecutionPlan, GraphError>
Compute a valid ExecutionPlan via topological ordering (Kahn’s
algorithm with deterministic tie-breaking by node ID).
§Errors
Returns GraphError::CycleDetected if the graph contains a cycle
(defensive; the add_edge invariant should prevent this).
Sourcepub fn validate(&self) -> Result<(), GraphError>
pub fn validate(&self) -> Result<(), GraphError>
Validate that every Kernel and Copy node has at least one resource
binding and that no required named bindings are missing.
Barrier nodes are not checked (they do not use resource bindings).
§Errors
Returns the first GraphError::MissingBinding encountered.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of nodes in the graph.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Number of directed edges in the graph.
Sourcepub fn predecessors(&self, node_id: u32) -> Result<Vec<u32>, GraphError>
pub fn predecessors(&self, node_id: u32) -> Result<Vec<u32>, GraphError>
Return the IDs of all direct predecessors (nodes that must run before
node_id).
§Errors
Returns GraphError::NodeNotFound if the ID is not registered.
Sourcepub fn successors(&self, node_id: u32) -> Result<Vec<u32>, GraphError>
pub fn successors(&self, node_id: u32) -> Result<Vec<u32>, GraphError>
Return the IDs of all direct successors (nodes that must run after
node_id).
§Errors
Returns GraphError::NodeNotFound if the ID is not registered.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ComputeGraph
impl RefUnwindSafe for ComputeGraph
impl Send for ComputeGraph
impl Sync for ComputeGraph
impl Unpin for ComputeGraph
impl UnsafeUnpin for ComputeGraph
impl UnwindSafe for ComputeGraph
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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