A large kernel's whole grids run on its partial-threadgroups variant
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.
This commit is contained in:
1 parent
11b6ad08e9
commit
03c587b9ee
14 files changed
+445
-94
No files matched your search
+14
-2
@@ -1492,8 +1492,20 @@ which `LoweringInputs::partial_threadgroups` compiles) runs such a grid as the t
|
||||
threads fill at the dispatch's threadgroup size instead, the last along an axis Metal's partial
|
||||
threadgroup, so every remainder takes the same `VkPipeline`; a kernel the variant cannot run
|
||||
exactly (a tile function, a stage-input region, compute derivatives, emulated simdgroups) is
|
||||
refused it, `Unsupported{GpuEncodedIndirectCommands, NotImplemented}`, and keeps the edges. A kernel that steps a stage-in attribute by thread position, or reads
|
||||
`[[grid_origin]]` or `[[grid_size]]`, needs the encoder's stage-in region:
|
||||
refused it, `Unsupported{GpuEncodedIndirectCommands, NotImplemented}`, and keeps the edges. On
|
||||
that plan a grid of whole threadgroups, of `Threads` or `Threadgroups`, takes the same regions
|
||||
unflagged (each `MultiRegion` 1, every thread live), so one `VkPipeline` of a threadgroup size runs
|
||||
all of a kernel's direct dispatches. `metal2vulkan-runtime` runs a kernel's whole grids there where
|
||||
its module holds 65,536 SPIR-V words or more and its ragged grids run there too: it observes its
|
||||
threadgroup partition (`CompiledFunction::observes_threadgroup_partition`), and for a one-row grid
|
||||
in threadgroups of one row otherwise than through its simdgroups alone
|
||||
(`observes_partition_through_simdgroups_alone`, whose such grids run flat). That is one driver
|
||||
compile of the module instead of two: on a guest's run on an RX 7900 XTX, the plain pipeline's
|
||||
compile of a kernel of 2,415,531 words was 26.9 s of a 39.8 s warm pass. Measured once on that GPU
|
||||
(RADV) over four straight-line kernels, the variant ran their whole grids at 0.997 to 1.020 times
|
||||
the plain pipeline's GPU time. Smaller kernels keep the plain pipeline for whole grids. A kernel
|
||||
that steps a stage-in attribute by thread position, or reads `[[grid_origin]]` or `[[grid_size]]`,
|
||||
needs the encoder's stage-in region:
|
||||
|
||||
```rust
|
||||
match plan.instantiate_dispatch(&state, &dispatch) {
|
||||
|
||||
Reference in new issue
Block a user