fix(agc): require the widest subgroup for compute programs wider than the device #1408
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1408"
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 hashaam1217 on 2026-10-08T02:42:56Z.
What
dispatchrequires a subgroup size only for compute programs compiled for 32 host lanes. A program compiled for more lanes than the device'smaxSubgroupSizegets no requirement. On a device whose subgroup size varies, the driver can then run it narrower than the 32 lanes the wave32 isolation fromf1d8ec89relies on.That is the third run of
agc_driver_wave32_subgroup(wide.subgroupSize = 64on a 32-lane device). With #1185 on Intel Iris Xe (Mesa ANV, subgroup sizes 8 to 32), the first run compiles at SIMD32 and passes. The third compiles at SIMD16 and fails withthread 16 v_mbcnt_lo_u32_b32 is 0, expected 16. This was discussed in #1185, where @krishnaraya4 suggested pinning it to the device maximum in a follow-up.The required size is now the smaller of the program's host width and the device's
maxSubgroupSize. It is attached when the host width is 32, as before, or when the host width is above the maximum:Target()orComputeTarget()never exceed the maximum, so they get the same requirement as before.Depends on #1185 for any effect: on main,
computeWave32stays false on devices whose default subgroup is 32, so this change does nothing there.Tested
Ubuntu 24.04.5, GCC 13.3.0, Release.
Main at
9619edffwith #1185 merged, without and with this change:wave32_subgroupon Intel (pipeline subgroup sizes,APS5_PIPELINE_STATS=1)wave32_subgroupflat_storeandglobal_vcc_base, whose compiles need several GiB (#1256). The remaining 13 failures needshaderFloat64orVK_KHR_shader_clock, pluspixel_ldsandvop1_float_unary(#1250).9619edff: NVIDIA 408/408, andwave32_subgroupon Intel still fails at the first run as on main.tools/check_conventions.py --base origin/mainpassed.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-08T03:19:03Z.
Review: COMMENTED
Built it and ran the agc suite — and while reading the surrounding code I found that this fix cannot take effect on its own. That is worth knowing before it is merged or reviewed in isolation.
Linux (CachyOS, GCC, Release), NVIDIA RTX 3080 Ti:
The change itself is right. For a wave64 program on a device whose maximum compute subgroup is 32,
std::min(shader.hostSubgroupSize, state->maxComputeSubgroupSize)gives 32 — a size the device can actually honour, where previously the program carried no requirement at all and could land on whatever the driver defaulted to. And on a device whose maximum is 64 the condition correctly leavespNextunset, since a wave64 program needs no requirement there.But the block it lives in is currently unreachable for exactly the devices it targets. The enclosing guard on main still reads:
On a device whose default subgroup size is 32 — the 32-lane case, which is the one where "widest available" matters —
subgroupSize > 32uis false, socomputeWave32staysfalseandmaxComputeSubgroupSizestays0. Your new line at the pipeline creation site is gated oncomputeWave32, so on those devices it never runs; and ifcomputeWave32were somehow true whilemaxComputeSubgroupSizewere0,min(hostSubgroupSize, 0)would be0, which is not a validrequiredSubgroupSize.#1185 is the other half, and neither works alone. It widens that guard to
>= 32u, which makescomputeWave32true on a 32-default device — but it does not recordmaxComputeSubgroupSize, which only your change does. So the wave64-on-32-max case needs both PRs, from two different authors, and each looks inert in isolation. Cross-referencing #1185 in the body would save the next reader that half hour — and if you would rather one PR carried both lines, that is a decision for you two to make, not for me.What I could not verify: the effect. Our device reports
minSubgroupSize == maxSubgroupSize == 32, so the guard is false here and your branch is dormant; the suite passing tells you nothing regressed, not that the fix works. A device whose maximum compute subgroup is below its wave64 size is the hardware that would show it.This is a comment, not an approval — I have no merge rights here.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-08T09:30:31Z.
Tested on top of current
main(ac951f8d, which has #1185; the merge is clean) on three device/OS combinations not covered above: AMD on Linux, NVIDIA on Windows and Intel on Windows, plus Mesa ANV for comparison.Full suite,
ANYPS5_REQUIRE_VULKAN=1, Release; Linux is Ubuntu 24.04.5 (GCC 13.3, Mesa 25.2.8), Windows is 11 (WinLibs GCC 15.2.0 r7):sdwa_float_selectorsandvopc_compare(f16 denormals flushed without a declared mode, as reported in #981),vop1_float_unary(#1250),vop3_mad_i64(#1246)flat_storetimeout (#1256),pixel_lds,vop1_float_unary(#1250)agc_driver_wave32_subgroup, pipeline subgroup sizes fromAPS5_PIPELINE_STATS=1, 3 runs each:mainmain+ this PRthread 16 v_mbcnt_lo_u32_b32 is 0, expected 16(3/3)So the Windows Intel driver already picks 32 for the wide program on its own; the requirement changes nothing there, and the effect is specific to ANV's choice. No change in results on RADV or NVIDIA.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-08T10:37:43Z.
Thanks — your ANV row is exactly the measurement I could not produce, so this closes the one thing I flagged.
My device reports
minSubgroupSize == maxSubgroupSize == 32, so the enclosing guard was false and the new line was dormant: the suite passing told us nothing about the fix, only that nothing regressed. Youragc_driver_wave32_subgrouppair is the missing evidence —mainreads 32 then 16 and fails ont16 v_mbcnt_lo_u32_b32 is 0, expected 16, this PR reads 32 then 32 and passes, and the Windows Intel driver picking 32 on its own is the useful control (it shows the requirement is a no-op there rather than the fix being device-specific magic).And testing on top of
ac951f8d— which carries #1185 — is the pairing I asked for: with #1185 in, the block is reachable on a 32-default device, and this PR'smaxComputeSubgroupSizeline is the half that makes it resolve. So the two are load-bearing together, as the note said, and your table demonstrates it on hardware rather than by reading the guard.Nothing further to ask from me. I can't reach the RADV/ANV/Intel set, so I have nothing to add on the other rows.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T13:25:22Z.
Checked the diff against
main(with #1185): build and ctest green here (454/454, lavapipe). The ANV effect is confirmed by @johnmaia's measurements (agc_driver_wave32_subgroupon UHD 730: 32 then 16 onmain, 32 then 32 with this PR; RADV and NVIDIA unchanged). Merging once CI is green.