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
6453edbea7andf090d99c9arun 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 before5205d18d12, 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 before5205d18d12. 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 at1133f4290awith 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.
This commit is contained in:
1 parent
1133f4290a
commit
9a01f1e8ee
6 files changed
+289
-27
No files matched your search
+2
-1
@@ -1442,7 +1442,8 @@ all of a kernel's direct dispatches. The runtime lowers a kernel that does not o
|
||||
partition once, as that variant, and runs every direct dispatch of it in its tiles; a kernel that
|
||||
observes its partition runs every dispatch, a whole grid, threadgroups, an indirect dispatch or
|
||||
a `dispatchThreads` grid that is not a whole number of threadgroups, on its partial-threadgroups
|
||||
variant at its own threadgroup size; an indirect dispatch states no grid in its region and takes
|
||||
variant at its own threadgroup size, where the variant takes the dispatch's threadgroup memory
|
||||
(the variant's predicated walk may add a vote word); an indirect dispatch states no grid in its region and takes
|
||||
the single-region form, unflagged. 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:
|
||||
|
||||
Reference in new issue
Block a user