A kernel that observes its threadgroup partition runs its ragged dispatchThreads grids on its
partial-threadgroups variant, one VkPipeline of the call's threadgroup size (MultiRegion 1),
while its whole grids took the plain pipeline (MultiRegion 0): two driver compiles of the same
module. On a guest's run on an RX 7900 XTX the plain one, for a kernel of 2,415,531 words, was
26.9 s of a 39.8 s warm pass.
Now a kernel whose base module holds compile_memory::COUNTED_WORDS (65,536) SPIR-V words or more
runs every direct dispatch of a threadgroup size on that variant, every thread live, where its
ragged grids of the same form run there (it observes its partition, and for a one-row grid in
one-row threadgroups otherwise than through its simdgroups alone, whose such grids run flat).
Where the variant is refused it falls back to the plain pipeline as before. Smaller kernels keep
the plain pipeline. Both forms give the same answers, so there is no switch and no FAST-PATHS
row.
- Binder: on a partial-threadgroups plan, a whole Threads grid takes the same L-sized regions
per group-count chunk, unflagged (no NONUNIFORM), and a Threadgroups dispatch's regions have
MultiRegion 1, so one specialization of a threadgroup size runs all of them.
- Translator API: CompiledFunction::observes_threadgroup_partition and
observes_partition_through_simdgroups_alone state the two partition facts the compile already
decides, so the runtime can decide at creation which form a kernel's ragged grids take.
- Runtime: compute::partial_direct takes whole grids and dispatchThreadgroups of such a kernel
(ComputePipelineState::whole_on_partial). WorkCounts::whole_dispatches_on_partial_variants
counts each such dispatch. A creation's predicted region is not made for such a kernel's
predicted dispatch, which would run on the variant, not the base.
- GPU cost, measured once on the XTX (RADV) with the probe on steelbrain/uniform-partial-probe:
1,048,576 threads in 64, partial/plain 0.997 to 1.020 over four straight-line kernels, words
equal. Stated at partial_direct and in docs/API.md's dispatch-regions paragraph.
Tests: engine_partial_threadgroups's whole_grids_run_on_the_partial_plan_with_every_thread_live
(whole Threads and Threadgroups dispatches on the partial plan give the split's and Metal's
words, and every grid of a threadgroup size takes one specialization, on the CPU interpreter);
the runtime's a_large_kernel_s_whole_grids_run_on_its_partial_variant (a large kernel makes one
VkPipeline over whole grids of both forms and a ragged one, counting 3 whole dispatches, with the
plain pipeline's words; a small kernel makes the plain pipeline's and the variant's, counting 0).
heap_trimmed makes its two large makings at two threadgroup sizes, since its whole and ragged
grids now share one.