fix(agc): require the widest subgroup for compute programs wider than the device #1408

Merged
hashaam1217 merged 1 commit from upstream-pr/1408 into main 2026-10-08 13:25:26 +00:00
hashaam1217 commented 2026-10-08 02:42:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hashaam1217 on 2026-10-08T02:42:56Z.


What

dispatch requires a subgroup size only for compute programs compiled for 32 host lanes. A program compiled for more lanes than the device's maxSubgroupSize gets no requirement. On a device whose subgroup size varies, the driver can then run it narrower than the 32 lanes the wave32 isolation from f1d8ec89 relies on.

That is the third run of agc_driver_wave32_subgroup (wide.subgroupSize = 64 on 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 with thread 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:

  • Programs from Target() or ComputeTarget() never exceed the maximum, so they get the same requirement as before.
  • NVIDIA (fixed 32) only gains a requirement it already meets.
  • A device that defaults to 64 with a maximum of 64 is unchanged.

Depends on #1185 for any effect: on main, computeWave32 stays 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 9619edff with #1185 merged, without and with this change:

wave32_subgroup on Intel (pipeline subgroup sizes, APS5_PIPELINE_STATS=1) Intel full suite NVIDIA full suite
#1185 fails: 32, then 16 14 failures 408/408
#1185 + this passes: 32, then 32 13 failures: the same minus wave32_subgroup 408/408
  • Intel Iris Xe (Alder Lake GT2), Mesa 25.2.8 ANV. Full suite run without flat_store and global_vcc_base, whose compiles need several GiB (#1256). The remaining 13 failures need shaderFloat64 or VK_KHR_shader_clock, plus pixel_lds and vop1_float_unary (#1250).
  • NVIDIA RTX 3060 Laptop, driver 595.91.07. No tests skipped.
  • This branch alone, on 9619edff: NVIDIA 408/408, and wave32_subgroup on Intel still fails at the first run as on main.
  • tools/check_conventions.py --base origin/main passed.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #1185
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4781057165 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1408). Originally posted by [hashaam1217](https://github.com/hashaam1217) on 2026-10-08T02:42:56Z. --- ### What `dispatch` requires a subgroup size only for compute programs compiled for 32 host lanes. A program compiled for more lanes than the device's `maxSubgroupSize` gets no requirement. On a device whose subgroup size varies, the driver can then run it narrower than the 32 lanes the wave32 isolation from f1d8ec89 relies on. That is the third run of `agc_driver_wave32_subgroup` (`wide.subgroupSize = 64` on 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 with `thread 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: - Programs from `Target()` or `ComputeTarget()` never exceed the maximum, so they get the same requirement as before. - NVIDIA (fixed 32) only gains a requirement it already meets. - A device that defaults to 64 with a maximum of 64 is unchanged. Depends on #1185 for any effect: on main, `computeWave32` stays 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 9619edff with #1185 merged, without and with this change: | | `wave32_subgroup` on Intel (pipeline subgroup sizes, `APS5_PIPELINE_STATS=1`) | Intel full suite | NVIDIA full suite | |---|---|---|---| | #1185 | fails: 32, then 16 | 14 failures | 408/408 | | #1185 + this | passes: 32, then 32 | 13 failures: the same minus `wave32_subgroup` | 408/408 | - Intel Iris Xe (Alder Lake GT2), Mesa 25.2.8 ANV. Full suite run without `flat_store` and `global_vcc_base`, whose compiles need several GiB (#1256). The remaining 13 failures need `shaderFloat64` or `VK_KHR_shader_clock`, plus `pixel_lds` and `vop1_float_unary` (#1250). - NVIDIA RTX 3060 Laptop, driver 595.91.07. No tests skipped. - This branch alone, on 9619edff: NVIDIA 408/408, and `wave32_subgroup` on Intel still fails at the first run as on main. - `tools/check_conventions.py --base origin/main` passed. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #1185 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Dextroid17 commented 2026-10-08 03:19:03 +00:00 (Migrated from github.com)

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:

cmake --build build --target agc_driver_graphics_tests --parallel 16
ctest -R agc_driver -j 16    →  166/166 passed

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 leaves pNext unset, 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:

if (hasExtension(VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME) && state->subgroup.subgroupSize > 32u) {
    ...
    state->computeWave32 = …;
    state->maxComputeSubgroupSize = subgroupSize.maxSubgroupSize;   // your line
}

On a device whose default subgroup size is 32 — the 32-lane case, which is the one where "widest available" matters — subgroupSize > 32u is false, so computeWave32 stays false and maxComputeSubgroupSize stays 0. Your new line at the pipeline creation site is gated on computeWave32, so on those devices it never runs; and if computeWave32 were somehow true while maxComputeSubgroupSize were 0, min(hostSubgroupSize, 0) would be 0, which is not a valid requiredSubgroupSize.

#1185 is the other half, and neither works alone. It widens that guard to >= 32u, which makes computeWave32 true on a 32-default device — but it does not record maxComputeSubgroupSize, 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5450951033 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1408#pullrequestreview-5450951033). Originally posted by [Dextroid17](https://github.com/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:** ``` cmake --build build --target agc_driver_graphics_tests --parallel 16 ctest -R agc_driver -j 16 → 166/166 passed ``` **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 leaves `pNext` unset, 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: ```cpp if (hasExtension(VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME) && state->subgroup.subgroupSize > 32u) { ... state->computeWave32 = …; state->maxComputeSubgroupSize = subgroupSize.maxSubgroupSize; // your line } ``` On a device whose default subgroup size is 32 — the 32-lane case, which is the one where "widest available" matters — `subgroupSize > 32u` is false, so `computeWave32` stays `false` **and `maxComputeSubgroupSize` stays `0`**. Your new line at the pipeline creation site is gated on `computeWave32`, so on those devices it never runs; and if `computeWave32` were somehow true while `maxComputeSubgroupSize` were `0`, `min(hostSubgroupSize, 0)` would be `0`, which is not a valid `requiredSubgroupSize`. **#1185 is the other half, and neither works alone.** It widens that guard to `>= 32u`, which makes `computeWave32` true on a 32-default device — but it does not record `maxComputeSubgroupSize`, 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.
johnmaia commented 2026-10-08 09:30:31 +00:00 (Migrated from github.com)

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):

device driver full suite with this PR
RX 7600 (RDNA3) RADV, Linux 430/430
RTX 4080 NVIDIA 617.42, Windows 426/426
UHD 770 (Raptor Lake-S, i7-13700K) Intel 101.6129, Windows 422/426: sdwa_float_selectors and vopc_compare (f16 denormals flushed without a declared mode, as reported in #981), vop1_float_unary (#1250), vop3_mad_i64 (#1246)
UHD 730 (Alder Lake-S) ANV, Linux 427/430: flat_store timeout (#1256), pixel_lds, vop1_float_unary (#1250)

agc_driver_wave32_subgroup, pipeline subgroup sizes from APS5_PIPELINE_STATS=1, 3 runs each:

device main main + this PR
UHD 730, ANV 32, then 16: fails, thread 16 v_mbcnt_lo_u32_b32 is 0, expected 16 (3/3) 32, then 32: passes
UHD 770, Intel Windows 32, then 32: passes (3/3) 32, then 32: passes

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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6056916487 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1408#issuecomment-6056916487). Originally posted by [johnmaia](https://github.com/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): | device | driver | full suite with this PR | | --- | --- | --- | | RX 7600 (RDNA3) | RADV, Linux | 430/430 | | RTX 4080 | NVIDIA 617.42, Windows | 426/426 | | UHD 770 (Raptor Lake-S, i7-13700K) | Intel 101.6129, Windows | 422/426: `sdwa_float_selectors` and `vopc_compare` (f16 denormals flushed without a declared mode, as reported in #981), `vop1_float_unary` (#1250), `vop3_mad_i64` (#1246) | | UHD 730 (Alder Lake-S) | ANV, Linux | 427/430: `flat_store` timeout (#1256), `pixel_lds`, `vop1_float_unary` (#1250) | `agc_driver_wave32_subgroup`, pipeline subgroup sizes from `APS5_PIPELINE_STATS=1`, 3 runs each: | device | `main` | `main` + this PR | | --- | --- | --- | | UHD 730, ANV | 32, then 16: fails, `thread 16 v_mbcnt_lo_u32_b32 is 0, expected 16` (3/3) | 32, then 32: passes | | UHD 770, Intel Windows | 32, then 32: passes (3/3) | 32, then 32: passes | 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.
Dextroid17 commented 2026-10-08 10:37:43 +00:00 (Migrated from github.com)

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. Your agc_driver_wave32_subgroup pair is the missing evidence — main reads 32 then 16 and fails on t16 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's maxComputeSubgroupSize line 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6058025772 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1408#issuecomment-6058025772). Originally posted by [Dextroid17](https://github.com/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. Your `agc_driver_wave32_subgroup` pair is the missing evidence — `main` reads 32 then 16 and fails on `t16 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's `maxComputeSubgroupSize` line 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.
adriadam10 commented 2026-10-08 13:25:22 +00:00 (Migrated from github.com)

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_subgroup on UHD 730: 32 then 16 on main, 32 then 32 with this PR; RADV and NVIDIA unchanged). Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6060879005 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1408#issuecomment-6060879005). Originally posted by [adriadam10](https://github.com/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_subgroup` on UHD 730: 32 then 16 on `main`, 32 then 32 with this PR; RADV and NVIDIA unchanged). Merging once CI is green.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!1408
No description provided.