perf(shader): let spanned waves run at any host subgroup size where it can be narrower than 32 #8004
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8004"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-19T17:19:41Z.
What
#7922 spans a single-wave wave64 compute program over full 32-lane host subgroups, pinned with a required subgroup size of 32. On Intel that pin forces SIMD32, where every 32-bit value takes twice the registers of SIMD16.
Stray's (PPSA02101) dominant compute program
0x2011300000is about 80% of the GPU time of a frame once it spans. ANV reports it as 81,332 instructions with 1,095 spills, 6,959 fills and 420 live registers at the peak.On a device whose compute subgroups can be narrower than 32 lanes (
minSubgroupSize < 32), a spanned wave now leaves the width to the driver:LocalInvocationIndex, which is the guest lane because a spanned module declares a 64×1×1 workgroup. It wasSubgroupId * 32 + SubgroupLocalInvocationId.EmitSubgroupShuffleInHalf) goes through thewave_exchangeslots that full-wave shuffles already use. The barriers it adds are covered by #7922's uniformity check. Ballots, full-wave shuffles and the LDS lock loop were already independent of the host subgroup width.SpirvEmitInfo::anySubgroupSizegives the artifact a host subgroup size of 0, socomputeSubgroupSizerequests no size and the pipeline is created withREQUIRE_FULL_SUBGROUPS | ALLOW_VARYING_SUBGROUP_SIZE. A 64-lane workgroup is a multiple of everymaxSubgroupSize. Compute pipeline captures accept that pair of flags without a required size, and replay checkscomputeFullSubgroupsfor it.VulkanDevicesets the newSpirvTarget::spannedAnySubgrouponly where spanning is on andminSubgroupSize < 32. NVIDIA (32 only) and AMD (32 or 64) keep the pinned 32-lane layout, where the in-half shuffle stays a subgroup shuffle. The flag is part of the cache key and of the serialized request, as version 45, aftermain's version 43 point fields and version 44fusedExactArithmetic.Tested
Intel Arc (Meteor Lake), Mesa 26.2.4 ANV, Fedora 44, Linux 7.2.10, GCC 16.2.1, Release.
Shader statistics.
APS5_PIPELINE_STATS=1on Stray: the largest compute executables now compile at SIMD8 or SIMD16 with no spills:0x2011300000takes about 29 ms per dispatch inAPS5_PROFILE_GPU, against about 100 ms with #7922 alone.ctestonmain04078b107+ #7922 + this PR:request_serializerandagc_shader_memorycover version 38, a version 37 request read without the flag, and the cache key.agc_compute_pipeline_capturecovers the new flag pair and rejects it with a required size.agc_driver_lds_mask_waterfallpasses.main57fdffd91:main:application_heap_scripting,application_heap_lazy,agc_driver_f64_rounding_denormal_modes,agc_driver_guest_memory_lifetime,agc_driver_mesh_barycentric_emulationandagc_driver_multisample_retirement.application_heaptests fail.spanned|request_serializer|agc_shader_memory|compute_pipeline_capture|lds|ballot|wave|subgroup|readlane|dpp|permlane|denormal_flush|shader_disk_cache|guardedpass withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, as the ones that exist onmaindo there. Neither log has aVUID-error or a missing-layer line.agc_shader_memoryandrequest_serializeralso read requests of earlier versions frommain, up to version 44, which have nospannedAnySubgroupbyte.Stray, frames 20 to 50 of the boot (
APS5_TRACE_FRAMES=20:30, 3840x2160). The builds are #7922 + #7811, against #7922 + this PR + #7811; Stray needs #7811 to start (#7693). Three interleaved rounds after one warm run each, every capture started below 55 °C:That is −41% GPU time and −19% frame time. Against
main+ #7811 in #7922's runs (303.4 ms GPU, 449.3 ms p50), the two PRs together are −66% and −37%.trace_digest.py, first capture of each:aps5-summary.jsonllines, #7922 + #7811:#7922 + this PR + #7811:
Traces, digests and summaries:
ThatsLeo:evidence/spanned-any-subgroup.Runs by others, on earlier heads:
mainto 76.5 / 75.8 ms with #7922 and this PR.Not tested: other Intel GPUs, and other titles on the Arc.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-20T01:56:26Z.
Runs on NVIDIA and AMD (the "Not tested" list), plus two problems that block a merge onto current main.
1. Serialization version 38 is already taken on main.
dd41527ce(feat(shader): emulate smooth barycentrics on the mesh path, merged after this PR's base7a015c094) movedRequestSerializerto version 38 and reads a mesh barycentric flag underversion >= 38u. This PR also bumps 37 to 38.git merge-tree origin/main 2276a44aamergesRequestSerializer.cppwithout a conflict, and the result reads both fields under version 38:A version-38 request that current main writes has no trailing
spannedAnySubgroupbyte, so this reader would read past its end. I read this from the merged code and didn't run it. The next free version avoids it. (Disclosure: my own open #7410 currently takes 39 for its wave-shared VGPR fields, so whichever lands second moves up one.)RequestSerializerTests.cppconflicts in the same places, aroundInsertMeshBarycentricFlag.SpirvSpecialization.cppfrom #7922 conflicts with main'sWordArenachange.2.
spanned_uniformity_testsdoesn't link with MinGW. This comes from #7922 and is carried here. At #7922's head753bb56e3, a Windows MinGW GCC 15.2 Release build stops at:The neighbouring
spirv_validator_exit_testsin the same function addsif(MINGW) target_link_libraries(... PRIVATE libc)and thePATHprepend. With those 5 lines added locally forspanned_uniformity_tests, everything links. The runs below use that local fix.3. Runs. Windows 11 26300, MinGW GCC 15.2 Release, on the PR's own base: #7922 head
753bb56e3against this PR head2276a44aa(#7922 + this PR). GPUs: RTX 5070 Ti (NVIDIA 617.42) and Ryzen 5 9600X Radeon iGPU (ANYPS5_GPU=AMD, 32.0.21042.62), both withANYPS5_REQUIRE_VULKAN=1. Test set:ctest -R "agc|shader|spirv|recomp|spanned|request_serializer", 814 tests.address_passes,pass_input_hazardlayered_volume_vertex_no_gpl,draw_cache_reuse_off,stencil_replay_no_gplpass_input_hazardpass_input_hazardagc_trimmed_importAll of these also fail on current main on this machine.
spanned_uniformity,request_serializer,agc_compute_pipeline_capture,agc_shader_memoryandagc_driver_lds_mask_waterfallpass on both GPUs. Both devices logsingle-wave wave64 compute spans full subgroups: 1, of any size: 0, so as the PR says, NVIDIA (32 only) and this AMD driver (minSubgroupSize32) keep the pinned layout.Forced path. Neither GPU reaches the new code by itself, and lavapipe doesn't either: its
computeWave32is false, so spanning is off there. To run theLocalInvocationIndexlane numbering, thewave_exchangein-half shuffle and theREQUIRE_FULL_SUBGROUPS | ALLOW_VARYING_SUBGROUP_SIZEpipelines on these GPUs, I made a local probe build (not for merge) that also setsspannedAnySubgroupwhenRVM_FORCE_ANY_SUBGROUPis set. The logs showof any size: 1on both GPUs. Run withANYPS5_NO_SHADER_CACHE=1, the same 814 tests have no new failures on either GPU.agc_trimmed_importfails on AMD on main as well. I didn't record which width the AMD driver picked underALLOW_VARYING_SUBGROUP_SIZE.Not measured: frame time or GPU time. The perf claim is Intel-only, and NVIDIA and AMD modules don't change by the rule above.
AI-assisted: yes (Claude Code); results above were run on this machine.
Imported from boykopovar/AnyPS5. Originally posted by CPritch on 2026-10-20T07:23:39Z.
Ran this on GTA V (PPSA04263 01.010.002), Linux 7.2.8-zen1-2-zen, NVIDIA GeForce RTX 5060 Laptop GPU, NVIDIA 615.71.09, Graphics Mode Performance, the Story prologue after Resume Story, with no input.
main
eaa5c9238against maineaa5c9238+ #8004 at 2276a44aa, same machine and session, two runs each in the order A B A B, window frames 4400:700, caches warm, APS5_TRACE_EVENTS=4194304 (BUILD.md's remedy for full trace buffers), no other APS5_TRACE_* or APS5_PROFILE_* switch, log not redirected. The harness navigates the menus from frame dumps in boot and load to present 4200 (APS5_DUMP_FRAMES=140, every 30 presents), which stop before the window.Frame p50: main 81.4, 81.3 ms, with #8004 76.5, 75.8 ms (-5.2 ms, -6.4 %). GPU busy per present: 64.7 and 60.2 ms.
This head carries #7922's commit 753bb56e3, so the numbers are #7922 and #8004 together.
Not tested: other scenes, Fidelity mode, other GPUs.
Written with AI assistance (Claude Code); measured on the machine above.
Summary lines (main, then the PR):
{"commit":"eaa5c9238687","dirty":false,"env":{"APS5_DUMP_FRAMES":"140","APS5_DUMP_FRAMES_EVERY":"30","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"","APS5_TRACE_EVENTS":"4194304","APS5_TRACE_FRAMES":"4400:700"},"gpu":"NVIDIA GeForce RTX 5060 Laptop GPU","driver":"NVIDIA 615.71.09","os":"Linux 7.2.8-zen1-2-zen","resolution":"3840x2160","window":{"spec":"frames 4400:700","first_present":4400,"ms":58118.742},"presents":700,"frame_ms":{"p50":81.36,"p90":91.573,"p99":114.238,"max":122.09},"gpu_busy_ms_per_present":64.665,"worker_busy_pct":{"queue worker 0x0":3679.04},"top_phases_ms_per_frame":{"Driver.EndSubmission":2987.559,"Driver.Packet":64.701,"Graphics.Draw":60.931,"Graphics.Draw.draw_and_resource_release":57.172,"Driver.Packet.draw":51.574,"Driver.Draw":51.353,"VideoOut.Flip":25.814,"Driver.Present":25.801},"trace_dropped":false,"trace":"aps5-trace-eaa5c9238687-1093456.json.gz"}
{"commit":"fb3b7487e2be","dirty":false,"env":{"APS5_DUMP_FRAMES":"140","APS5_DUMP_FRAMES_EVERY":"30","APS5_NO_PAD_INPUT":"1","APS5_PAD_INPUT_FILE":"","APS5_TRACE_EVENTS":"4194304","APS5_TRACE_FRAMES":"4400:700"},"gpu":"NVIDIA GeForce RTX 5060 Laptop GPU","driver":"NVIDIA 615.71.09","os":"Linux 7.2.8-zen1-2-zen","resolution":"3840x2160","window":{"spec":"frames 4400:700","first_present":4400,"ms":54938.319},"presents":700,"frame_ms":{"p50":76.457,"p90":85.706,"p99":107.809,"max":148.413},"gpu_busy_ms_per_present":60.704,"worker_busy_pct":{"queue worker 0x0":3786.492},"top_phases_ms_per_frame":{"Driver.EndSubmission":2905.761,"Driver.Packet":63.588,"Graphics.Draw":55.513,"Graphics.Draw.draw_and_resource_release":51.733,"Driver.Packet.draw":50.213,"Driver.Draw":50.0,"Driver.Draw.shader_compile_and_link":24.464,"Driver.Draw.draw_enqueued":20.516},"trace_dropped":false,"trace":"aps5-trace-fb3b7487e2be-1103783.json.gz"}
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-20T08:09:29Z.
Rebase handoff — rebased onto current
main(3fd1cc393, both commits, authorship unchanged). Two-part resolution:maingrew theWordArena/ArenaAllocatorinfrastructure since your branch — kept it (yourusingaliases forOpcode/Resultare superseded bymain's local functions, but your code'sVisitIdOperandsuse needed its alias restored besidemain'sInstruction).mainaddedInsertMeshBarycentricFlaginsertions at five sites your version-bump rewrites touch — all five kept across your edits.mainhadn't changed that entry since your base).Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, AMD RX 9070 XT / RADV): builds;request_serializerpasses; 1673/1676 — green apart from the three knownmainfailures (#7584 BDA, #7784 guest-memory, tessellation), none from this PR; conventions pass (one pre-existing[debt-length]finding). Functional verification only — no performance measured on my side.To pick it up:
Head is
7aae6840d.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T23:45:43Z.
@ThatsLeo Thanks for this, and thanks to @blawesom for the rebase and to @wachi35676 / @CPritch for the runs. Before a full review, three things need to land on the branch:
version > 39u. This PR's 38 merges without a text conflict but would make current main's v38 requests read a trailingspannedAnySubgroupbyte they don't have. Please move it to the next free version (40 today, but check main when you rebase) and update the serializer tests to match. blawesom'srebase/8004still writes 38.spanned_uniformity_testsfails to link with MinGW GCC 15.2 (undefined reference to __gxx_personality_v0, from #7922's commit). The neighbouringspirv_validator_exit_testscallsconfigure_windows_unwind(spirv_validator_exit_tests)(recompiler CMakeLists.txt), which is probably what this target is missing.#7922's single commit is this PR's first commit, so one review will cover both once these are in.
Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-20T23:46:24Z.
@oneandonlydean @wachi35676 All three are in. #8004 is rebased onto
main559f35d68on top of the updated #7922.spannedAnySubgroupis now read from version 40 (mainis at 39).agc_shader_memoryalso checks that a version 39 request frommain, without the byte, reads back unchanged.spanned_uniformity_testsnow getsconfigure_windows_unwind,CXX_EXTENSIONS OFFand the MinGWlibclink andPATHprepend, asspirv_validator_exit_testshas. I couldn't build with MinGW here, so a confirmation would help.main. lavapipe passes 1746 of 1748. The validation-layer run of the focused tests shows noVUID-error. Details are in the description.@blawesom, thanks for the handoff. I redid the rebase myself because it also needed the version move. @CPritch, thanks for the GTA V numbers; they're quoted in both descriptions.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T00:31:44Z.
@ThatsLeo One more move on the version, sorry: #8697 just merged and took request version 41 (
float32DenormPreserve, read at>= 41u). So 40 now sits below whatmainwrites. Could you write 42 and readspannedAnySubgroupat>= 42u, after main's 41 field, and update the serializer tests to match? The rebase onto currentmainalso conflicts inRequestSerializer.cpp,tests/RequestSerializerTests.cppandtests/ShaderMemory.cpp. #7922 merges cleanly as it is, so its CI is going ahead now.Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-21T00:46:20Z.
@oneandonlydean Done. The request is now version 42, and
spannedAnySubgroupis written aftermain'sfloat32DenormPreserveand read at>= 42u. #8004 is rebased ontomain57fdffd91. The #7922 commits on this branch are the same as on #7922, only rebased.RequestSerializerTests.cppandShaderMemory.cppcame from both branches adding a trailing byte, so every legacy-version case now drops two.request_serializerandagc_shader_memoryalso read a version 41 request frommain: it keeps its denormal-preserve flag and gets nospannedAnySubgroup. A version 39 request still reads as before, and version 43 is rejected.main.application_heaptests fail.VUID-error.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-21T12:55:06Z.
@oneandonlydean Rebased onto
main7280a17ec.mainnow writes version 42 for the pixelsampleOrderfield, sospannedAnySubgroupmoved to version 43. It is written last and read at>= 43u.main's new version 41, 34, 32 and 30sampleOrdercases now drop the extra trailing byte too.request_serializerandagc_shader_memoryalso read version 42 requests frommainwithout the flag. Both pass, as dospanned_uniformityandagc_compute_pipeline_capture, and only test files changed in the conflict resolution.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-22T03:52:23Z.
@ThatsLeo thanks for the rebase, and sorry for the slow reply. I've checked 0017bbe73c:
spannedAnySubgroupis written last at version 43 and read at>= 43u, and the fixtures match. That looks right to me.It conflicts with
mainagain, though:mainmoved on, anddocs/dev/debt/shader.mdnow conflicts (the code files merge cleanly). Could you rebase once more? Then I'll run the full CI on the new head.On the version: 43 is free on
maintoday (mainis at 42), but several open PRs also claim 43. Whichever merges first keeps it, and the others bump tomain+ 1, so you may need to re-bump if one of them lands before this one.