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

OpDesc

struct OpDesc

Describes a single operation in the pipeline schedule.

Fields: tag: The type of operation (kernel-specific, used by _emit dispatch). stage: Buffer stage index (0 or 1 for double-buffering). subtile: Subtile index within the stage (0 or 1). k_offset: How to compute the K dimension offset for loads. vm_cost: Number of vmcnt (global load) ops this produces. lgkm_cost: Number of lgkmcnt (LDS) ops this produces. wait_value: For WAIT_VM/WAIT_LGKM ops, the count to wait for. resource: Hardware execution unit (GLOBAL_MEM, LDS, MMA_UNIT, SCALAR). latency: Estimated execution latency in cycles. role: Pipeline data-flow role (GLOBAL_LOAD, FRAGMENT_LOAD, etc.). channel: Data path identifier for edge derivation. Ops on the same channel share a buffer (e.g., 0=A matrix, 1=B matrix). -1 = none. vgpr_def: VGPRs this op brings into scope (new live register values). vgpr_kill: VGPRs this op releases (last use of some register buffer).

Fields​

  • ​tag (Int):
  • ​stage (Int):
  • ​subtile (Int):
  • ​k_offset (KOffsetKind):
  • ​vm_cost (Int):
  • ​lgkm_cost (Int):
  • ​wait_value (Int):
  • ​resource (ResourceKind):
  • ​latency (Int):
  • ​role (OpRole):
  • ​channel (Int):
  • ​vgpr_def (Int): VGPRs this op brings into scope (new live register values).
  • ​vgpr_kill (Int): VGPRs this op releases (last use of some register buffer).

Implemented traits​

AnyType, Copyable, ImplicitlyCopyable, ImplicitlyDestructible, Movable

Methods​

__init__​

__init__(out self, *, tag: Int, stage: Int = 0, subtile: Int = 0, k_offset: KOffsetKind = KOffsetKind.NONE, vm_cost: Int = 0, lgkm_cost: Int = 0, wait_value: Int = 0, resource: ResourceKind = ResourceKind.NONE, latency: Int = 0, role: OpRole = OpRole.NONE, channel: Int = -1, vgpr_def: Int = 0, vgpr_kill: Int = 0)

is_present​

is_present(self) -> Bool

True if this is a real op (not the NONE sentinel).

Returns:

Bool

op​

static op(tag: Int, resource: ResourceKind, latency: Int, role: OpRole, *, channel: Int = -1, stage: Int = 0, subtile: Int = 0, k_offset: KOffsetKind = KOffsetKind.NONE, vm_cost: Int = 0, lgkm_cost: Int = 0, wait_value: Int = 0, vgpr_def: Int = 0, vgpr_kill: Int = 0) -> Self

Construct an OpDesc with all metadata inline.

All scheduling metadata (tag, resource, latency, role, channel) is specified directly. Per-instance fields (stage, subtile, k_offset) are keyword arguments.

logical​

static logical(tag: Int, *, channel: Int = -1, stage: Int = 0, subtile: Int = 0, k_offset: KOffsetKind = KOffsetKind.NONE) -> Self

Declare a logical op β€” buffer metadata only, no hardware costs.

Resource, latency, and role are left as sentinel values (NONE/0). Call annotate_ops() with a TargetCostModel to fill them in before scheduling. This separates the algorithm (what ops exist) from the target (how expensive they are).

barrier​

static barrier() -> Self

wait_vm​

static wait_vm[count: Int]() -> Self

wait_vm_n​

static wait_vm_n(count: Int) -> Self

Runtime-parameterized wait_vm (for ScheduleConfig-driven waits).

wait_lgkm​

static wait_lgkm[count: Int]() -> Self

wait_lgkm_n​

static wait_lgkm_n(count: Int) -> Self

Runtime-parameterized wait_lgkm (for ScheduleConfig-driven waits).

set_prio​

static set_prio[priority: Int]() -> Self

Priority hint: s_setpriopriority.

schedule_barrier​

static schedule_barrier() -> Self

Compiler scheduling fence.

none​

static none() -> Self

No-op sentinel (used for optional MMA block fields).

sched_group_barrier​

static sched_group_barrier[mask: Int, count: Int]() -> Self

Schedule_group_barrier hint. Mask encoded in subtile, count in wait_value.