pub struct DataflowGraph { /* private fields */ }Expand description
A dataflow graph built from an IR function’s statements.
Nodes correspond to statements and edges represent data/control dependencies between them.
Implementations§
Source§impl DataflowGraph
impl DataflowGraph
Sourcepub fn build(func: &Function) -> Self
pub fn build(func: &Function) -> Self
Build a dataflow graph from an IR function.
Walks statements in order, computes read/write sets, and creates dependency edges:
- RAW (DataFlow): a write followed by a read of the same expression
- WAR (AntiDependency): a read followed by a write of the same expression
- WAW (OutputDependency): two writes to the same expression
- Control: barriers create control edges to all subsequent memory operations
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Returns the number of nodes.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Returns the number of edges.
Sourcepub fn successors(&self, node_id: usize) -> Vec<&DfgEdge>
pub fn successors(&self, node_id: usize) -> Vec<&DfgEdge>
Returns all edges originating from the given node.
Sourcepub fn predecessors(&self, node_id: usize) -> Vec<&DfgEdge>
pub fn predecessors(&self, node_id: usize) -> Vec<&DfgEdge>
Returns all edges pointing to the given node.
Sourcepub fn topological_sort(&self) -> Result<Vec<usize>, DataflowError>
pub fn topological_sort(&self) -> Result<Vec<usize>, DataflowError>
Perform topological sort using Kahn’s algorithm.
Returns nodes in a valid execution order respecting all dependencies.
§Errors
Returns DataflowError::CycleDetected if the graph contains a cycle.
Sourcepub fn critical_path(&self) -> CriticalPathResult
pub fn critical_path(&self) -> CriticalPathResult
Compute the critical path through the DFG.
Assigns a unit cost of 1 to each node and computes the longest path from any source node (no predecessors) to any sink node (no successors).
Returns the cost for each node (longest path from any source to that node) and the critical path length.
Sourcepub fn critical_path_with_costs(&self, costs: &[usize]) -> CriticalPathResult
pub fn critical_path_with_costs(&self, costs: &[usize]) -> CriticalPathResult
Compute the critical path with custom per-node costs.
costs[i] is the execution cost of node i.
Returns the cost for each node and the critical path length.
Sourcepub fn parallel_groups(&self) -> Vec<Vec<usize>>
pub fn parallel_groups(&self) -> Vec<Vec<usize>>
Identify groups of independent nodes that can execute concurrently.
Returns a list of groups, where each group contains node IDs that have no dependencies between them and can execute in parallel.
Trait Implementations§
Source§impl Clone for DataflowGraph
impl Clone for DataflowGraph
Source§fn clone(&self) -> DataflowGraph
fn clone(&self) -> DataflowGraph
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more