IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
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:

  1. Core β€” producer/consumer roles, dependency kind, loop distance. loop_distance = -1 means "derive from producer.k_offset": K_PREV β†’ d=0 (current-iteration load), otherwise d=1 (prefetch).

  2. Field matching β€” require same channel / stage / subtile between the producer and consumer ops. use_config_match activates the PipelineConfig.compute_match_key() logic (Phase 1 register-FLOW).

  3. Half predicates (double-buffer) β€” same_half / cross_half / producer_half constrain which half each op lives in.

  4. 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.

  5. 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, or OUTPUT).
  • ​loop_distance (Int): Loop iterations between producer and consumer (0, 1, or -1). -1 derives from producer.k_offset: K_PREV β†’ d=0 (current-iteration load), otherwise d=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): Use PipelineConfig.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_PREV only, 2 = non-K_PREV only). 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 of producer_role).
  • ​consumer_ordinal (Int): Consumer ordinal filter (-1 = any, N = Nth occurrence of consumer_role).
  • ​first_match_only (Bool): Break after the first consumer match per producer.

Implemented traits​

AnyType, Copyable, ImplicitlyCopyable, ImplicitlyDeletable, Movable