For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Mojo struct
EdgeRule
struct EdgeRule
Declarative edge derivation rule.
Each rule describes a class of dependency edges: for every (producer,
consumer) pair whose OpDesc fields satisfy the predicates, emit a
DepEdge with the given kind and loop distance.
The evaluator (apply_edge_rules) pre-classifies ops by role, then for
each rule scans only relevant (producer_role, consumer_role) pairs and
checks the predicate fields. This replaces the hand-coded 4-phase
double-buffer logic and 8-rule single-buffer logic in
derive_edges_from_ops with inspectable data.
Fields fall into five groups:
-
Core β producer/consumer roles, dependency kind, loop distance.
loop_distance = -1means "derive from producer.k_offset": K_PREV β d=0 (current-iteration load), otherwise d=1 (prefetch). -
Field matching β require same channel / stage / subtile between the producer and consumer ops.
use_config_matchactivates thePipelineConfig.compute_match_key()logic (Phase 1 register-FLOW). -
Half predicates (double-buffer) β
same_half/cross_half/producer_halfconstrain which half each op lives in. -
K-offset filter β 0=any, 1=K_PREV only, 2=non-K_PREV only. Applied to the consumer for LDS-ANTI rules, to the producer for LDS-FLOW distance derivation.
-
Single-buffer predicates β
lc_producer/lc_consumer(loop- carried status),producer_ordinal/consumer_ordinal(Nth op of that role),first_match_only(break after first consumer match).
Fieldsβ
- βproducer_role (
OpRole): Producer op role for this rule. - βconsumer_role (
OpRole): Consumer op role for this rule. - βdep_kind (
DepKind): Dependency kind (FLOW,ANTI, orOUTPUT). - βloop_distance (
Int): Loop iterations between producer and consumer (0,1, or-1).-1derives fromproducer.k_offset:K_PREVβd=0(current-iteration load), otherwised=1(prefetch). - βmatch_channel (
Bool): Require the producer and consumer to share the same channel. - βmatch_stage (
Bool): Require the producer and consumer to share the same stage. - βmatch_subtile (
Bool): Require the producer and consumer to share the same subtile. - βuse_config_match (
Bool): UsePipelineConfig.compute_match_key()(Phase 1 register-FLOW). - βsame_half (
Bool): Require both ops to live in the same half. - βcross_half (
Bool): Require the ops to live in different halves. - βproducer_half (
Int): Producer half filter (-1= any,0= first half,1= second half). - βk_offset_filter (
Int): K-offset filter (0= any,1=K_PREVonly,2= non-K_PREVonly). Applied to the consumer for LDS-ANTI rules and to the producer for LDS-FLOW distance derivation. - βlc_producer (
Int): Loop-carried filter for the producer (-1= any,0= non-lc,1= lc). - βlc_consumer (
Int): Loop-carried filter for the consumer (-1= any,0= non-lc,1= lc). - βproducer_ordinal (
Int): Producer ordinal filter (-1= any,N= Nth occurrence ofproducer_role). - βconsumer_ordinal (
Int): Consumer ordinal filter (-1= any,N= Nth occurrence ofconsumer_role). - βfirst_match_only (
Bool): Break after the first consumer match per producer.
Implemented traitsβ
AnyType,
Copyable,
ImplicitlyCopyable,
ImplicitlyDeletable,
Movable
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!