Files
metal2vulkan/docs
Anees Iqbal 9a01f1e8ee rt: an observer's dispatch runs its partial-threadgroups variant only where the variant's threadgroup memory, its vote word included, is within the device's limit
6453edbea7 and f090d99c9a run an observing kernel's whole grids, threadgroup
dispatches and indirect dispatches on its partial-threadgroups variant wherever
the threadgroup is whole groups of the variant's SIMD multiples. The variant's
predicated walk adds a 4-byte vote word of threadgroup memory
(RuntimeFact::PredicationVote, stated for a barrier in a loop) that the plain
module does not hold, and decide() did not count it. So a dispatch whose
threadgroup memory came within 4 bytes of maxComputeSharedMemorySize ran before
5205d18d12, and has been refused as Limit::ThreadgroupMemory since.

decide() now takes the encoder's threadgroup memory lengths and the device's
limit. It moves such a dispatch to the variant only where threadgroup_memory()
accepts the variant with those lengths. Otherwise the dispatch runs the plain
module, as it did before 5205d18d12. This is the fallback decide() already takes
for a threadgroup the variant cannot take, decided per dispatch from the
dispatch's own lengths against a Vulkan limit, so it adds no form. The make-ahead
and prepare_dispatch decide through the same call (Compiled::dispatched, with no
lengths at the make), so a state makes one pipeline: the variant's where its
static memory with the vote word fits, and the plain module's where it does not.
Ragged grids are unchanged: they took the vote word before, and they are refused
as before.

The test uses two observers, each with two barriers in a loop of four
iterations:
- vote_static declares the limit's bytes less 12. Metal reports that as the
  limit to the byte, because staticThreadgroupMemoryLength rounds up to 16, while
  the translator's arena with the vote word fits, so the variant is lowered. Its
  state at requiredThreadsPerThreadgroup 64 must make the plain module's pipeline
  with the state. A declaration of the limit itself never reached the variant:
  the translator refuses that variant at lowering (lower::simd::divergent).
- vote_length takes its region from the encoder, at the limit.
For each, a whole grid, a threadgroup dispatch and an indirect dispatch run on
the plain module, answer the program's words, and are not counted in
partial_variant_whole_grids. A ragged grid is refused as Limit::ThreadgroupMemory
at the limit plus 4.

Where a guest meets it, this is the consumer's answer, read from its code at
8566693615 and not measured:
- The guest reads maxThreadgroupMemoryLength = min(32768, the device's
  maxComputeSharedMemorySize).
- The validation profiles state 65536 for the 780M, and 49152 for the Iris Xe
  and the RTX 5080.
- Not on record per card: the RX 550 and the RX 7900 XTX (65536 by RADV's GFX7+
  value), and the RTX 3090 (49152 by NVIDIA's value; there is no Ampere profile).
- On those devices a guest that keeps to its 32768 bytes reaches at most
  32768 + 4, which fits.
- The one exposed host class is the Mac on KosmicKrisp, if KosmicKrisp states
  32768. That figure is pending: the consumer reads it with vulkaninfo.
The fix stands either way, because the runtime checks against the device's own
limit.

How it is verified: the test is expected to fail at 1133f4290a with only this
commit's test added, and to pass here, on lavapipe. The jobs are in the lane's
report. The test also runs on the round's card legs.
2026-11-22 05:44:19 -08:00
..