Run a one-row threadgroup of a lockstep-only kernel on its own pipeline

OpenCL C's scale kernel (if (i < n) b[i] *= k) uses no simdgroup
operation, yet on the RTX 5080 a dispatch in threadgroups of 16 paid a
second compile on emulated simdgroups and its degrade notice. The
lockstep pass orders b[i]'s read and write: two threads of a simdgroup
share their grid position's x where the threadgroup is narrower than 32
and taller than one row. The pair stands where only some threads run, so
its barrier is a subgroup barrier (a tangle barrier under maximal
reconvergence), which pins the kernel to the Direct tier's whole 32-lane
subgroups, and a 16-thread region was a partial simdgroup for the
emulated variant. In a threadgroup of one row no two threads of a
simdgroup share an x, so no pair meets and no barrier is needed.

- The lockstep analysis runs its pairs a second time where each
  simdgroup lies within one row (a position's x then differs by 1 to 31
  between two threads, as an index does), only where a subgroup barrier
  keeps a 32-lane tier; Lockstep::rows records that none conflicts.
- Lowering takes the inserted simdgroup barriers' class after selection,
  so it knows whether they are the kernel's only simdgroup semantics;
  then, on a flattened tier, the kernel records RuntimeFact::RowLockstep.
- The binder runs a one-row region of such a kernel on the planned
  pipeline whatever its width, that region without
  REQUIRE_FULL_SUBGROUPS where it is not whole subgroups. A partial
  region of two rows still takes the emulated variant.

Tests: the binder's rules (one row of 1, 16, 48 threads planned and
unflagged, 32 and 64 flagged, a 100-thread grid's edge, two-row partial
regions on the variant, no fact no exception); and on the RTX 5080
profile the scale shape keeps Direct, records RowLockstep and plans 1,
16 and 48 threads on its one pipeline, while b[gid >> 1] and a kernel
reading its lane do not.

(cherry picked from commit a6c76c206d4438e3948b05464cef7d65fd63d5ab)
This commit is contained in:
Anees Iqbal committed 2026-11-07 11:43:21 -08:00
1 parent 5e4e9bc60c
commit fe494f10cd
18 files changed
+369 -26

No files matched your search

+3 -1
View File
@@ -1733,7 +1733,9 @@ bound.
two.
- `metal2vulkan-degrade-emulated-simdgroups` (performance). `EmulatedSimdgroups`: A dispatch whose
threadgroups are not whole subgroups of the kernel's pinned subgroup size runs on the kernel's
emulated-simdgroups variant. Cost: a second compile of the kernel whose simdgroup operations go
emulated-simdgroups variant. A threadgroup of one row of a kernel whose only simdgroup semantics
are the barriers its lockstep order took, ordering pairs that meet only where a simdgroup spans
two rows, runs on the kernel's own pipeline instead. Cost: a second compile of the kernel whose simdgroup operations go
through threadgroup memory between barriers.
- `metal2vulkan-degrade-separate-depth-stencil` (performance). `SeparateDepthStencil`: A pass of
separate depth and stencil textures, or of a stencil-only texture alone at custom sample