Files
metal2vulkan/docs
Anees Iqbal 3a619009b7 Run one-row threadgroups of a row-lockstep kernel on a variant without its simdgroup barriers
What: a kernel whose only simdgroup semantics are lockstep simdgroup barriers that order pairs
meeting only where a simdgroup spans two rows (RowLockstep) kept them, their cross-lane class
and, on a device with tangled 32-lane subgroups, its pinned subgroup size, even for a dispatch
of one-row threadgroups, where no such pair meets. On the Iris Xe that pin makes ANV compile a
register-heavy kernel at SIMD32, which spills and takes seconds where SIMD8 takes 0.3 s.

- Address facts: a place among the threadgroup's linear threads (thread_index_in_threadgroup,
  and under rows thread_position_in_threadgroup's x, never the grid's) with its low five bits
  cleared (`& -32`) or shifted out (`>> k`, k >= 5) is one value per simdgroup (AddrFacts::
  aligned, in fixed). The lattice walk skips such terms like uniform ones, and its spread now
  holds two facts, the finest lattice and the whole bounded difference, either clearing a pair.
- Lockstep::rows holds where, under row facts, no conflicting pair wants more than a
  threadgroup barrier: threadgroup barriers stand where the whole threadgroup runs together,
  order every pair a simdgroup barrier would and need no subgroup size, so a one-row pipeline
  keeps them and drops only the simdgroup barriers (the argument is in Lockstep::rows' doc).
- VariantKey::one_row / LoweringInputs::one_row: the lockstep pass inserts only the threadgroup
  barriers where rows holds; the kernel states RuntimeFact::OneRow (Mechanism::Variant). The
  binder asks a dispatch whose every region is one row of a RowLockstep kernel for it
  (dispatch_variant), the planned pipeline still runs such a dispatch, and the variant's plan
  sends a dispatch with a taller region back (NeedsVariant). The runtime settles on it through
  dispatch_variant and prepares it beside the base where a one-thread dispatch asks for it.

Tests: engine_simd_emulated's a_one_row_dispatch_drops_the_lockstep_simdgroup_barriers on the
Iris profile (a tile whose halves meet only across rows plus a workgroup-uniform pair): the own
pipeline keeps its simdgroup and threadgroup lockstep barriers, CrossLane(BASIC), Direct and
RowLockstep, and leaves the expected words at 144 x 2 (the shared lane's included); the one-row
variant has one threadgroup lockstep barrier, no simdgroup one, (None, NoSubgroup), no subgroup
requirement and OneRow, and leaves the expected words at 128 x 1 and 48 x 1 at 8, 16 and 32
lanes; the binder sends 128 and 48 to the variant and 144 x 2 to the base, whose plan refuses
the variant 144 x 2; the kernel with a simdgroup sum keeps Direct and its own pipeline for 32,
128 and 144 x 2. a_row_of_a_lockstep_only_kernel_takes_one_compile now expects the one-row
variant for one-row threadgroups of the row kernel, and the pinned pipeline for whole ones of
the others. The mechanism table, the inputs-encoding test and api_signatures take the new items.
2026-11-12 11:02:40 -08:00
..