Skip to main content

Mojo function

sched_barrier_pairs

sched_barrier_pairs[pairs: Int, valu_cnt: Int, group: Int]()

Emits pairs schedule groups of shape [1 MFMA, valu_cnt VALU].

Each call expands to two schedule_group_barrier invocations under sync_id=group: one declaring "1 MFMA in this group" and one declaring "valu_cnt VALUs in this group". pairs > 1 recurses to emit additional pairs in the same sync_id, all of which LLVM orders relative to each other (see [[patterns/amd-iglp-instruction-group-interleave-pattern]]).

Note valu_cnt is the count of VALU instructions in each group, not a VALU-to-MFMA ratio; LLVM derives the interleave from the group declaration. Mojo's underlying schedule_group_barrier(mask, size, sync_id) docstring labels size as a "repeat count" β€” that is misleading; it is the instruction count per group.

Parameters:

  • ​pairs (Int): Number of (MFMA, VALU) groups to emit, all sharing sync_id=group.
  • ​valu_cnt (Int): VALU instructions per group.
  • ​group (Int): IGroupLP sync_id. Reuse within one cluster's pair sequence; pick distinct ids for distinct clusters so their constraints stay independent. 1-10 typical for MHA main+epilogue.