A pressured kernel takes the Emulated tier in place of the widest mode's pin

On a device whose compiler picks a kernel's SIMD width between a minSubgroupSize below 32 and a
maxSubgroupSize of 32 (ANV), the Direct tier's required subgroup size of 32 with full subgroups
compiles the kernel in the widest mode, where each lane's value takes four times the registers
of the narrowest one. A kernel with many live values spills there, and its driver compile grows
to seconds and past them; one real kernel never finished compiling on an Iris Xe.

The kernel stage now takes the Emulated tier (each simdgroup 32 consecutive threads, its
operations and lockstep barriers through workgroup memory and barriers, no required size) when
the device has those facts, the inlined entry holds more than 256 instructions, and an estimated
peak of live 32-bit words passes 36. Both tiers are exact; it is not a speed-for-accuracy choice.

- lower/simd/pressure.rs: the estimate. Live intervals in layout order (a value stays live across
  both arms of a branch, as on a SIMT device), a phi's incoming value used at the end of its
  predecessor, a value read in a loop held to the loop's end; widths are the lowered ones (a wide
  pointer from a pointer load or inttoptr is 8 words, and its resident-set search holds 14 more
  where it is made). Linear in the body, metered.
- lower/simd/mod.rs: widest_pin, WIDEST_PIN_FLOOR, WIDEST_PIN_WORDS, the census entry
  simd.emulated.widest-pin, and the calibration table in the module docs.
- workgroup::check is atomic: divergent::plan returns its demotions, which join `cross` only
  once nothing refuses, so a kernel the Emulated tier refuses keeps its Direct tier.
- Runtime: WorkCounts::widest_pin_kernels_emulated counts such translations.
- docs/API.md section 3 states the rule and the calibration.

Calibration: an authored kernel (S steps, K live float accumulators, a lockstep pair in divergent
flow each step, P = 1 the accesses through a loaded pointer) on an Iris Xe (RPL-P, ANV),
vkCreateComputePipelines and GPU time, both tiers, one run each. At 34 estimated words or fewer
the two compile alike and the pin runs as fast or faster; from 40 the pinned compile took 1.6 to
24 times the emulated one and its GPU time 1.5 to 25 times (P1 K48 S32: 25.8 s vs 1.3 s compile,
1.985 vs 0.081 ms GPU). Answers were the same bits on both tiers in every run. The estimate took
5.2 ms of a 3.41 s release translation (225 MB peak RSS) of a 162,914-instruction kernel.

Test: engine_simd_lockstep's a_pressured_kernel_takes_the_emulated_tier_in_place_of_the_widest_mode
(the Iris profile: unpadded, below the floor and a low-pressure chain stay Direct, a fan of
live values takes Emulated with the census entry; the RTX 5080 laptop and RDNA3 profiles and a
kernel the Emulated tier refuses stay Direct).
This commit is contained in:
Anees Iqbal committed 2026-11-13 03:45:33 -08:00
1 parent a0467ab6fa
commit a9b4f8adae
10 files changed
+629 -52

No files matched your search

+36
View File
@@ -707,6 +707,42 @@ placeholders (a kernel's local size is 1). Create each pipeline from a planned d
one device pins only what that device can take; `DeviceProfile::check` tells whether another
device can.
A kernel whose simdgroups run on 32-lane subgroups pins a required size of 32 with full
subgroups. On a device whose compiler chooses a kernel's SIMD width between a `minSubgroupSize`
below 32 and a `maxSubgroupSize` of 32 (ANV), that pin compiles the kernel in the device's widest
mode, where each lane's value takes four times the registers of the narrowest one. A kernel whose
entry, inlined, holds more than 256 AIR instructions and whose values are estimated to hold more
than 36 32-bit words at once (live intervals over the body in layout order, a value read in a loop
held to the loop's end) takes the emulated simdgroup tier there instead: each simdgroup is 32
consecutive threads, its operations and lockstep barriers go through workgroup memory and
workgroup barriers, and its module pins no subgroup size, so the driver chooses the width. Both
forms are exact. The runtime counts such kernels (`WorkCounts::widest_pin_kernels_emulated`). A
kernel the emulated tier refuses (a 64-bit exchange, or a scratch that does not fit beside its
threadgroup memory) keeps the pin.
The bounds come from an authored kernel measured on an Iris Xe (RPL-P, ANV): `S` steps, each a
branch on one of `K` live `float` accumulators whose arm stores a device word and loads the next
(a lockstep pair in divergent flow, so a subgroup barrier there), with `P` 1 the arm's accesses
going through a pointer it loads from memory (a resident-set search a step), then every
accumulator updated. Pressure, not size, separates the cases. The driver's compile time
(`vkCreateComputePipelines`) and the GPU time of a dispatch of 12,288 threads, pinned and
emulated, one run each (compile times varied up to twice between runs):
| `P K S` | AIR instructions | estimated words | compile ms, pinned | emulated | GPU ms, pinned | emulated |
|------------|-----------------:|----------------:|-------------------:|---------:|---------------:|---------:|
| `0 16 128` | 7,850 | 24 | 589 | 559 | 0.129 | 0.159 |
| `1 4 32` | 874 | 34 | 783 | 766 | 0.010 | 0.018 |
| `0 32 64` | 7,050 | 40 | 6,652 | 282 | 1.061 | 0.107 |
| `1 16 16` | 1,042 | 46 | 971 | 300 | 0.070 | 0.015 |
| `1 16 64` | 4,066 | 46 | 11,987 | 2,585 | 0.319 | 0.074 |
| `1 48 32` | 5,186 | 78 | 25,799 | 1,277 | 1.985 | 0.081 |
At 34 estimated words or fewer the two compile alike and the pinned kernel runs as fast or
faster; from 40 the pinned compile took 1.6 to 24 times the emulated one and its GPU time 1.5 to
25 times. At or below 256 instructions every pinned compile measured took at most 102 ms. Answers
were the same bits on both tiers. The estimate costs time linear in the body: 5 ms of a 3.4 s
release translation of a 162,914-instruction kernel.
### What the module contains
Every stage states the size and shape of its module, counted by the verifier that runs on every