Files
metal2vulkan/crates
Anees Iqbal a9b4f8adae 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).
2026-11-13 03:45:33 -08:00
..