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 function

build_kernel_program

build_kernel_program(body: List[OpDesc], config: PipelineConfig, sched: ScheduleConfig = ScheduleConfig(scheduling=SchedulingStrategy.IDENTITY, sched_barrier_mask=85, auto_waits=True, drain_lgkm_mask=0, auto_drain=False, lds_contention_penalty=0, wait_lgkm_first=8, wait_vm_last=6, lgkm_per_load_a=0, lgkm_per_load_b=0, lgkm_after_last=False, minimal_barriers=False, omit_mma_set_prio=False, max_vgpr=999999, global_before_frag=False, barrier_before_pre_ops=False, inter_block_lgkm_drain=False, partial_prologue_drain=False, wrap_waits_with_sched_barrier=False), edges: List[DepEdge] = List()) -> PipelineProgram

Build the finalized PipelineProgram for a double-buffer kernel.

Runs the full pipeline: LDG construction β†’ CSP/greedy scheduling β†’ program building β†’ redistribution β†’ auto-waits β†’ auto-drain β†’ verification. Returns the PipelineProgram before expansion to entries.

Used by ScheduleCompiler.compile() for double-buffer kernel derivation and by derive_prologue_from_program() for prologue extraction.

Args:

  • ​body (List[OpDesc]): Loop body op list (typically PipelineSchedule.build_body()).
  • ​config (PipelineConfig): Pipeline configuration (depth, MMA grid, etc.).
  • ​sched (ScheduleConfig): Scheduling configuration (CSP knobs, wait overrides).
  • ​edges (List[DepEdge]): Optional dependency edges to drive scheduling. If empty (default), falls back to derive_edges_from_ops(body, config) (preserves existing behavior for callers that don't override PipelineSchedule.derive_edges). Schedules that need extra edges (e.g., cross-half FRAGβ†’MMA for cross-stage rotation) should override derive_edges and pass them through here.

Returns:

PipelineProgram: Finalized PipelineProgram before expansion to entries.