Repository navigation
Wave64 compute and mesh programs at one lane per invocation on 32-wide hosts when they never observe the wave #2013
Replies: 3 comments 4 replies
|
No. A per-program wave64 layout isn't on any branch of mine and I'm not planning one, so it's yours. My performance work has moved off my fork onto a tree based on upstream main. Recompiler changes are reviewed by @adriadam10. |
|
Thanks @oneandonlydean, I'll take it. Here is where I'd start, with a question about the design for @adriadam10 before I write it. What
Analysis. I'd do it on the IR rather than the RDNA program, where the wave-level operations are explicit:
Compute only at first. Mesh stays at two lanes until I've understood the The question: where the decision lives.
I'd go with (a). Is carrying the layout in the program's metadata fine with you, or would you rather keep it a function of the request? Measurement. In the PR: register count and local memory per program from |
|
I ran #4339's decision log over Ghost of Yōtei's compute shaders and posted the numbers there (#4339 (comment)). It mostly confirms the size pattern. On |
Uh oh!
There was an error while loading. Please reload this page.
Problem
On a host whose subgroup is 32 wide (NVIDIA), every wave64 compute and mesh program runs two guest lanes per host invocation:
laneCountis 2 whenever the program is wave64 and the host subgroup is 32 (SpirvEmitter.cpp), whatever the program does.SpirvModuleSetup.cpp), and every lane-varying value is emitted once per lane (SpirvFlowEmitter.cpp).#304 already shares the wave-uniform values between the two lanes, but each host invocation still holds both lanes' VGPRs, and NVIDIA caps an invocation at 255 registers. #611 measured PPSA21564 mesh shaders at 255 registers with 624-784 B of local memory per thread, and 448 B left even with every exec select removed. On a 64-wide host the same programs run one lane per invocation. In #357, PPSA21564 runs were pinning one wave64 compute program (0x500597a00) to another layout with
APS5_TWO_LANE/APS5_INEXACT_SINGLE_LANEto avoid an NVIDIA spill hang; neither switch is onmainnow.Two lanes per invocation are required only when the program looks at the wave as a whole. Many wave64 programs never do: each lane reads its inputs, computes, and writes its own results.
Proposal
Choose the layout per program. A wave64 compute or mesh program on a 32-wide host runs at one guest lane per invocation (the layout
APS5_SINGLE_LANEforces today,Recompiler.cpp), with the full workgroup and a required subgroup size of 32, when an IR analysis proves that no result depends on the other half of the wave:v_readlane/v_readfirstlaneof a lane-varying value,v_writelane, DPP,v_permlane*,ds_swizzle,ds_permute/ds_bpermute,v_mbcnt,ds_append/ds_consume.s_cbranch_execz/vccz(or SCC from a lane mask) is taken per host subgroup, so one half can skip a region the other half runs. That is invisible only if the region has no scalar effect seen after it: no SALU result live out of the region, no scalar store, no message. A conservative first version rejects any such region with a scalar definition used later.s_barrier; across two host subgroups that needs a barrier, whichWaveLdsScopecan only place when the workgroup is one wave.Every other wave64 program keeps two lanes per invocation. Nothing changes for wave32 or on 64-wide hosts. The choice depends only on the program and the target, so the cache key needs nothing new.
Measurement plan for the PR:
APS5_PIPELINE_STATS=1register count and local memory per program before and after, the share of wave64 programs that qualify, and execution tests for each rejected case (a ballot, anexeczregion with a live SALU result, intra-wave LDS exchange in a multi-wave workgroup) next to accepted ones.Questions
APS5_INEXACT_SINGLE_LANE. Is a per-program layout already on your branch or planned? I don't want to duplicate it.APS5_SINGLE_LANE=allwithAPS5_PIPELINE_STATS=1gives an upper bound on the register and spill savings without any change. Rendering may differ under it, since it ignores rules 1-3, so it is a measurement only. If anyone with a title that has many wave64 compute or mesh programs (PPSA21564, for example) can post the register and local memory numbers from both runs, that would show whether this is worth doing.All reactions