AMD's non-LLPC compiler hoists the volatile poll load out of a loop, so BufferWorkgroupPublication spins on a stale value #1600

Open
opened 2026-11-26 10:01:24 +00:00 by github-bot · 0 comments
Owner

@⁠Nawid3333 on GitHub · 2026-10-17 14:39 UTC · original

BufferWorkgroupPublicationWave32 and Wave64 fail on my Ryzen 7600X iGPU (RDNA2, AMD's non-LLPC compiler, driver 26.8.1 on Windows) and pass on the RX 9070 XT (LLPC). From ticket 1 on, every workgroup reaches the poll limit (0x8000000x) and never sees its predecessor's value.

Kyty's SPIR-V is fine: the poll is OpLoad ... Volatile on a Coherent buffer inside the loop (OpLoopMerge, back edge to the header). The iGPU's driver emits that load (buffer_load_dword ... glc dlc) once, before the loop label, and the loop then counts to 1,000,000 on the stale value. SPIR-V says a Volatile access "cannot be eliminated, duplicated, or combined with other accesses", so this is a driver bug. The Vulkan memory model does not help: with MakePointerVisible|NonPrivatePointer at device scope the iGPU still hoists the load.

Two standard forms keep the load in the loop on both GPUs:

  1. OpAtomicLoad at device scope, relaxed. With coherent (GLC) word loads from storage buffers emitted that way in LoadWordInBounds, both tests pass on both GPUs, also with 32-wide subgroups (after dropping their check for Volatile in the SPIR-V). The iGPU's compiler turns it into buffer_atomic_add of 0; LLPC emits a plain buffer_load_b32 ... scope:SCOPE_DEV. Tests that look for Volatile in the SPIR-V of such loads would need updating.
  2. The volatile load followed by OpMemoryBarrier (device, Acquire|UniformMemory), checked in the ISA only. The iGPU then keeps the plain buffer_load_dword ... glc dlc in the loop and adds buffer_gl0_inv and buffer_gl1_inv after it.

I haven't measured what either costs on that compiler. @⁠Nmzik which would you prefer, for all coherent word loads or only those inside loops? I can open the PR.

Written with Claude Code (AI): it measured this on my PC and traced it in the code.

**@⁠Nawid3333** on GitHub · 2026-10-17 14:39 UTC · [original](https://github.com/KytyPS5/KytyPS5/issues/1600) `BufferWorkgroupPublicationWave32` and `Wave64` fail on my Ryzen 7600X iGPU (RDNA2, AMD's non-LLPC compiler, driver 26.8.1 on Windows) and pass on the RX 9070 XT (LLPC). From ticket 1 on, every workgroup reaches the poll limit (`0x8000000x`) and never sees its predecessor's value. Kyty's SPIR-V is fine: the poll is `OpLoad ... Volatile` on a `Coherent` buffer inside the loop (`OpLoopMerge`, back edge to the header). The iGPU's driver emits that load (`buffer_load_dword ... glc dlc`) once, before the loop label, and the loop then counts to 1,000,000 on the stale value. SPIR-V says a Volatile access "cannot be eliminated, duplicated, or combined with other accesses", so this is a driver bug. The Vulkan memory model does not help: with `MakePointerVisible|NonPrivatePointer` at device scope the iGPU still hoists the load. Two standard forms keep the load in the loop on both GPUs: 1. `OpAtomicLoad` at device scope, relaxed. With coherent (GLC) word loads from storage buffers emitted that way in `LoadWordInBounds`, both tests pass on both GPUs, also with 32-wide subgroups (after dropping their check for `Volatile` in the SPIR-V). The iGPU's compiler turns it into `buffer_atomic_add` of 0; LLPC emits a plain `buffer_load_b32 ... scope:SCOPE_DEV`. Tests that look for `Volatile` in the SPIR-V of such loads would need updating. 2. The volatile load followed by `OpMemoryBarrier` (device, `Acquire|UniformMemory`), checked in the ISA only. The iGPU then keeps the plain `buffer_load_dword ... glc dlc` in the loop and adds `buffer_gl0_inv` and `buffer_gl1_inv` after it. I haven't measured what either costs on that compiler. @⁠Nmzik which would you prefer, for all coherent word loads or only those inside loops? I can open the PR. Written with Claude Code (AI): it measured this on my PC and traced it in the code.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:01:24 +00:00
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/KytyPS5--KytyPS5#1600
No description provided.