fix(agc): require 32-wide compute subgroups on devices whose default is 32 #1185
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1185"
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 kr4y4 on 2026-10-07T16:45:24Z.
What
VulkanDeviceenablesVK_EXT_subgroup_size_control, and makes compute pipelines compiled for 32 host lanes require a 32-lane subgroup, only when the device's default subgroup size is above 32 (ecda77d5, written for devices that default to 64). A device whose default is 32 but whose subgroup size can vary never gets the requirement, so its driver may run those pipelines on narrower subgroups. DPP,ds_permute/ds_swizzle,permlane16and lane reads then return wrong values without an error.The Intel Windows driver reports, for a Raptor Lake-S iGPU:
subgroupSizeminSubgroupSizemaxSubgroupSizerequiredSubgroupSizeStagessubgroupSizeControlCOMPUTEThe condition is now
>= 32, so such devices take the same path. A device whose subgroup is fixed at 32 (NVIDIA: min = max = 32) only gains a requirement it already meets. Devices that default above 32, and lavapipe (8), are unchanged.Tested
Windows 11 (26200), WinLibs GCC 15.2.0 r7, CI configure flags,
ctest --output-on-failure --timeout 120 --repeat until-fail:3.Intel Raptor Lake-S Mobile Graphics (driver 32.0.101.6790, Vulkan 1.4.311). On main these fail; with this change they pass:
agc_driver_dpp16_inactive_sourcelane 16 mov_quad_perm_fi is 0xd0944996, expected 0xdeaddeadagc_driver_dpp16_operandslane 20 masks_exec_pk_fmac_f16 is 0x3cbc41af, expected 0x3f014000agc_driver_dpp16_row_share_xmasklane 16 mov_row_share0 is 0xdd7dd010, expected 0xdeaddeadagc_driver_dpp8lane 16 mov_inactive is 0xac9f21df, expected 0xdeaddeadagc_driver_ds_permutelane 0 permute is 0x00000000, expected 0x0000101fagc_driver_ds_swizzlelane 0 bitmask_reverse is 0x00000000, expected 0x14aa4e71agc_driver_lds_addtidlane 0 plane 10 (ds_write_addtid_b32, fill) is 0x5d6ea59d, expected 0x6cd7983dagc_driver_lds_atomics64lane 0 ds_add_u64 is 0xdeadbeefdeadbeef, expected 0x74ab8b7debd0f042agc_driver_permlane16lane 0 permlanex16_identity is 0xdeaddead, expected 0xc88b2875f71bf7fd: 31 failures on main, 21 with this change, none new. The remaining 21 have other causes on this device: noshaderFloat64(the f64 tests, both division tests andfloat16_dotthrow64-bit float instructions need the Float64 capability, which the device lacks), noVK_KHR_shader_clock(shader_clock), and wrong values in the buffer and image atomics tests,look_back_scan,sdwa_float_selectors,vop1_float_unary,vop3_mad_i64andvopc_compare, which this change does not affect.agc_driver_flat_storetimes out intermittently on this device, with and without the change.cea1ef13: the nine tests above andagc_driver_wave32_subgrouppass, run withANYPS5_GPU=Intel.NVIDIA RTX 4070 Laptop GPU (driver 32.0.15.9597): full suite 394/394 passed with this change.
Not covered: the Intel driver accepts a required subgroup size only for compute (
requiredSubgroupSizeStagesisCOMPUTE), so graphics stages on it can still run on subgroups narrower than the 32 lanes they were compiled for.Checklist
main; no other open PR implements the same thing🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by hashaam1217 on 2026-10-08T01:33:28Z.
Tested on Linux: Intel Iris Xe (Alder Lake GT2), Mesa 25.2.8 ANV, kernel 7.0, at
2cc5735dwith this line applied,ANYPS5_GPU=Intel ctest -j1 --timeout 180. ANV reports the same subgroup properties as the Raptor Lake Windows driver:subgroupSize32, min 8, max 32,requiredSubgroupSizeStagesCOMPUTE | TASK | MESH.19 tests go from fail to pass:
dpp16_inactive_source,dpp16_operands,dpp16_row_share_xmask,dpp8,ds_append_consume,ds_permute,ds_swizzle,ds_wrxchg2_b64,global_store_addtid,lds_addtid,lds_atomics64,look_back_scan,permlane16,read_first_lane,read_lane,scalar_program_flow,scalar_wide_loads,wave_uniform,write_lane. On main,ds_wrxchg2_b64andlds_atomics64also hang the GPU here (i915 ... context reset due to GPU hang, about 8 s each); with the change they pass in 0.1 s. No test that passes on main fails with the change.Still failing with the change (16 of 402):
shaderFloat64orVK_KHR_shader_clock.wave32_subgroup: the 32-lane run now compiles at SIMD32 and passes. The third run (wide.subgroupSize = 64, fromf1d8ec89) gets no required size becausehostSubgroupSizeis 64, and ANV compiles it at SIMD16:thread 16 v_mbcnt_lo_u32_b32 is 0, expected 16. WithAPS5_PIPELINE_STATS=1the two pipelines reportsubgroup=32andsubgroup=16. That run relies on the driver choosing at least 32 lanes by itself, which the Windows driver evidently does and ANV does not.pixel_lds: fragment stage, whichrequiredSubgroupSizeStagesdoes not include (your "Not covered" note).vop1_float_unary:lane 13 fract_f32 v5 is 0x3f7fbd2b, expected 0x3f7fbd2c, a rounding difference in Intel'sfractthat is unrelated to subgroups. I will send a separate PR for it.flat_storeandglobal_vcc_base: killed by a 6 GiB memory limit while ANV compiles their pipelines.flat_storeis killed on main as well.Compile cost. With the requirement, ANV has to compile at SIMD32, and the same SPIR-V takes 2 to 3 times longer and spills. Measured with
ANYPS5_NO_SHADER_CACHE=1 MESA_SHADER_CACHE_DISABLE=true APS5_PIPELINE_STATS=1, one test at a time in a cgroup limited to 5 GiB:global_store_addtidglobal_store_addtidglobal_vcc_baseglobal_vcc_baseflat_storePeak RSS per test (GNU
time):global_store_addtid0.59 GiB on main and 2.49 GiB with the change,global_vcc_base2.73 GiB and killed at the limit,flat_storekilled at the limit in both. Mesa caches the binaries on disk, so later runs are fast (global_store_addtidpasses in 0.17 s from the cache).I don't think this blocks the change, since without it these shaders produce wrong results. It does mean the first compile of a large compute shader on Linux Intel gets slower and needs more memory, and
flat_storealready needs about 7 GiB on main (numbers in #1256).Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-08T01:50:03Z.
Review: COMMENTED
Built and ran it — external PRs get no CI here, so this is an independent build on a different platform and a different driver from yours.
Linux (CachyOS, GCC, Release), NVIDIA GeForce RTX 3080 Ti / driver 615.71.09:
The guard widening reads correctly. Widening the outer condition from
> 32uto>= 32uonly decides whether the capabilities are queried; the inner condition still requiressubgroupSizeControl,minSubgroupSize <= 32,maxSubgroupSize >= 32, andVK_SHADER_STAGE_COMPUTE_BITinrequiredSubgroupSizeStages. So a device that cannot honour a required size cannot be made to enter the wave32 path by this change — the widening can only turn the requirement on where it can actually be satisfied. That is the safe direction.What I could and could not verify. Our device reports:
So the new guard does fire here — but because
min == max == 32, requiring 32 is a no-op on this device, and there is no width to vary to. My run therefore demonstrates no regression, not the effect. The effect (a varying width being pinned back to 32) needs a device whoseminSubgroupSize < 32, which I do not have; the Intel table in the description remains the only behavioural evidence for it.One process note for anyone re-running this: with only the two agc targets built I saw one failure, which disappeared once the full build completed. That was a stale-binary artifact of my tree, not your change — the suite wants a complete build.
Not blocking: on a device whose default is 32 and which supports
subgroupSizeControlbut does not list COMPUTE inrequiredSubgroupSizeStages,computeWave32stays false and nothing changes — I read that as intended (no requirement where none can be made), just confirming.This is a comment, not an approval — I have no merge rights here.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by kr4y4 on 2026-10-08T01:51:47Z.
Thanks for the ANV run. It's a second driver with the same 8–32 range, and it fixes more tests there than here.
wave32_subgroupthird run. It compiles the program for a 64-lane host (wide.subgroupSize = 64) on a device whosemaxSubgroupSizeis 32. NorequiredSubgroupSizecan match that, so the run passes only if the driver picks 32 lanes by itself. Outside the test,hostSubgroupSizecomes fromTarget()/ComputeTarget(), so a 64-lane host program only exists on devices that default to 64. A follow-up could skip that run whenmaxSubgroupSize < 64, or pin it to the device maximum. I'd keep it out of this PR.Compile cost. Agreed, SIMD32 on ANV is slower and spills more, but without the requirement these programs give wrong lanes. All three of those programs go through the BDA store expansion tracked in #1256. Per program:
flat_storehas fifteen 32-bit address stores,global_store_addtidsix, andglobal_vcc_basetwo or six, plus BDA loads and an atomic (APS5_DUMP_IR=all).Imported from boykopovar/AnyPS5. Originally posted by kr4y4 on 2026-10-08T01:58:21Z.
Thanks for the independent build. Yes, that's intended: if a device can't take a required size for compute,
computeWave32stays false and nothing changes, because there's no requirement it could honour.For the effect itself there are now two devices with
minSubgroupSize = 8: the Raptor Lake-S Windows driver in the description, and @hashaam1217's Alder Lake GT2 on Mesa ANV above (19 tests from fail to pass, none from pass to fail).Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-08T02:17:28Z.
That resolves my only question — and it matches how the code reads to me: widening the guard can only turn the requirement on where a device can actually honour it, so a device that cannot take a required size for compute keeps its previous behaviour exactly rather than silently assuming one.
On the earlier point about the run being no-regression rather than the effect: with that confirmed, my measurement sits where it should.
399/399on the whole suite and161/161on agc here is evidence the change is safe on a 32-lane device, and your Intel table remains the evidence for the behaviour it fixes. Nothing further from me.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T08:53:30Z.
Checked the guard:
computeWave32still requiressubgroupSizeControl,minSubgroupSize <= 32 <= maxSubgroupSizeandCOMPUTEinrequiredSubgroupSizeStages, so widening> 32to>= 32only turns the requirement on where the device can honour it. Built on currentmain, ctest 426/426 on lavapipe; CI green on this head (linux, windows, conventions). The Intel effect (Raptor Lake Windows, Alder Lake ANV) rests on the two independent runs in the thread, which we can't reproduce here. Merging.