Docs: API.md states the local size contract of a kernel on subgroups, which its shuffles rely on

A translator consumer that is not metal2vulkan-runtime read nowhere in docs/API.md that a
kernel stating RuntimeFact::LocalSizeConstraint runs only threadgroups whose size is a multiple
of it, and that a dispatch at any other size runs the kernel's EmulatedSimdgroups variant. A
half simdgroup sum or product on the Direct and Cluster32 tiers now reads its sibling lanes by
xor shuffles in a block every lane executes, which name an inactive lane in a partial subgroup.
Section 6 now says so, and that the emulated variant gives Metal's answers for the partial
simdgroup, as the runtime's variant choice does (pipeline.rs: a module with multiples gets
KernelVariant::EmulatedSimdgroups).

Verified: docs only; the contract read from device::subgroup::requirement and the runtime's
variant choice.
This commit is contained in:
Anees Iqbal committed 2026-12-02 22:40:50 -08:00
1 parent 06ee627760
commit 0cd07d6612
1 file changed
+6 -1
+6 -1
View File
@@ -1370,7 +1370,12 @@ establishes no other bit.
## 6. At bind time
A kernel's dispatch runs as one or more regions, each a group count with its specialization and
push constants, and each distinct specialization is one `VkPipeline`. A kernel's
push constants, and each distinct specialization is one `VkPipeline`. A kernel whose simdgroups
run on subgroups states `RuntimeFact::LocalSizeConstraint { multiple }`: each region's local size
is a multiple of `multiple`, so every subgroup is full and, in a block every lane executes, a
simdgroup operation reads its sibling lanes by plain shuffles, none of them inactive. A dispatch
whose threadgroup size is not such a multiple runs the kernel's `EmulatedSimdgroups` variant, as
`metal2vulkan-runtime` does, which gives Metal's answers for the partial simdgroup. A kernel's
partial-threadgroups variant (`LoweringInputs::partial_threadgroups`) runs a grid that is not
whole threadgroups as the threadgroups its threads fill at the dispatch's threadgroup size, the
last along an axis Metal's partial threadgroup, so every remainder takes the same `VkPipeline`; a