AGC: 64-bit LDS atomics under the workgroup lock never finish in workgroups over 64 threads on AMD RDNA 2 (Windows) #6666

Closed
opened 2026-10-16 03:22:18 +00:00 by tezzgod74 · 3 comments
tezzgod74 commented 2026-10-16 03:22:18 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by tezzgod74 on 2026-10-16T03:22:18Z.


On an AMD RDNA 2 iGPU (Windows), a 64-bit LDS atomic under the workgroup lock (LockedLdsUpdate, SpirvMemoryInstructions.cpp:1310) never finishes once the workgroup has more than 64 threads. With 64 or fewer it gives the exact result. This is what agc_driver_lds_mixed_width_atomics hits: it is the only LDS 64-bit test above 64 threads (256). LdsAtomics64 uses 32 and LdsBeyondDeviceLimit 64.

Ryzen 9 7950X iGPU (RDNA 2, 0x164e), driver 32.0.21045.5002, Windows 11 Pro 10.0.26300, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, main 5d9dcc42d. The RX 9060 XT (RDNA 4, 0x7590, 32.0.31041.1004) in the same machine is the control. Measured with a local change to the test that sets the uniform kernel's workgroup width and times Dispatch + WaitIdle:

Kernel Wave Threads iGPU RX 9060 XT
uniform (16 × ds_add_u64 + ds_add_u32) 32 32, 64 exact, 51-53 ms exact
32 128, 256 4.1-4.2 s, output never written exact, 2.5-59 ms
64 64 exact, 53 ms exact
64 128, 256 4.2-5.2 s, output never written exact
same, ds_add_u32 replaced by s_nop (64-bit only) 32 64 exact (0x000003fffffffc00), 30 ms exact
32 128, 256 4.2 s, output never written exact
  • The threshold is the thread count, not the wave count. In wave64, 128 threads (2 waves) fail; in wave32, 64 threads (2 waves) pass.
  • It doesn't need the 32-bit atomics that #2675 put under the lock: 64-bit atomics alone fail the same way.
  • On this iGPU the dispatch ends after about 4 s with nothing written, no Vulkan error and no TDR event (4101) in the system log. On an RX 6400 (RDNA 2) the same test ran past 10 s with a TDR (#5271). On a Vega iGPU (GCN 5) the output is also left unwritten (#3882). #3358 lists it failing on a Radeon 780M as well. It passes on RDNA 3.5 (#3882) and RDNA 4 (above).

LockedLdsUpdate elects one lane per wave for the OpAtomicCompareExchange and leaves the loop on a wave-uniform ballot (#833), so lanes of one wave never wait on each other, and the results are exact up to 64 threads. Over 64 threads, a workgroup on RDNA 2 can occupy both CUs of a WGP. That may be what changes, but I haven't confirmed it.

Not related to #6284 (ASTRO BOT on RX 6600 XT), whose cached modules contain no LockedLdsUpdate.

Reproduce

$env:ANYPS5_GPU = "Radeon(TM) Graphics"
ctest --test-dir build -R '^agc_driver_lds_mixed_width_atomics$' --output-on-failure
AGC graphics: lds mixed width atomics uniform run 0: lane 0 read 0xdeadbeefdeadbeef, expected 0x00001ffffffff000 after 4096 ds_add_u64 and 4096 ds_add_u32 on one slot

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5877750725 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6666). Originally posted by [tezzgod74](https://github.com/tezzgod74) on 2026-10-16T03:22:18Z. --- On an AMD RDNA 2 iGPU (Windows), a 64-bit LDS atomic under the workgroup lock (`LockedLdsUpdate`, [SpirvMemoryInstructions.cpp:1310](https://github.com/boykopovar/AnyPS5/blob/5d9dcc42d/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cpp#L1310)) never finishes once the workgroup has more than 64 threads. With 64 or fewer it gives the exact result. This is what `agc_driver_lds_mixed_width_atomics` hits: it is the only LDS 64-bit test above 64 threads (256). `LdsAtomics64` uses 32 and `LdsBeyondDeviceLimit` 64. Ryzen 9 7950X iGPU (RDNA 2, 0x164e), driver 32.0.21045.5002, Windows 11 Pro 10.0.26300, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, `main` 5d9dcc42d. The RX 9060 XT (RDNA 4, 0x7590, 32.0.31041.1004) in the same machine is the control. Measured with a local change to the test that sets the uniform kernel's workgroup width and times `Dispatch` + `WaitIdle`: | Kernel | Wave | Threads | iGPU | RX 9060 XT | |---|---|---|---|---| | uniform (16 × `ds_add_u64` + `ds_add_u32`) | 32 | 32, 64 | exact, 51-53 ms | exact | | | 32 | 128, 256 | **4.1-4.2 s, output never written** | exact, 2.5-59 ms | | | 64 | 64 | exact, 53 ms | exact | | | 64 | 128, 256 | **4.2-5.2 s, output never written** | exact | | same, `ds_add_u32` replaced by `s_nop` (64-bit only) | 32 | 64 | exact (`0x000003fffffffc00`), 30 ms | exact | | | 32 | 128, 256 | **4.2 s, output never written** | exact | - The threshold is the thread count, not the wave count. In wave64, 128 threads (2 waves) fail; in wave32, 64 threads (2 waves) pass. - It doesn't need the 32-bit atomics that #2675 put under the lock: 64-bit atomics alone fail the same way. - On this iGPU the dispatch ends after about 4 s with nothing written, no Vulkan error and no TDR event (4101) in the system log. On an RX 6400 (RDNA 2) the same test ran past 10 s with a TDR (#5271). On a Vega iGPU (GCN 5) the output is also left unwritten (#3882). #3358 lists it failing on a Radeon 780M as well. It passes on RDNA 3.5 (#3882) and RDNA 4 (above). `LockedLdsUpdate` elects one lane per wave for the `OpAtomicCompareExchange` and leaves the loop on a wave-uniform ballot (#833), so lanes of one wave never wait on each other, and the results are exact up to 64 threads. Over 64 threads, a workgroup on RDNA 2 can occupy both CUs of a WGP. That may be what changes, but I haven't confirmed it. Not related to #6284 (ASTRO BOT on RX 6600 XT), whose cached modules contain no `LockedLdsUpdate`. ### Reproduce ``` $env:ANYPS5_GPU = "Radeon(TM) Graphics" ctest --test-dir build -R '^agc_driver_lds_mixed_width_atomics$' --output-on-failure ``` ``` AGC graphics: lds mixed width atomics uniform run 0: lane 0 read 0xdeadbeefdeadbeef, expected 0x00001ffffffff000 after 4096 ds_add_u64 and 4096 ds_add_u32 on one slot ``` AI-assisted: yes
MarcZX10 commented 2026-10-16 03:37:52 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T03:37:52Z.


I opened PR #6670 for a concrete SPIR-V issue in the lock setup: every invocation currently emits a non-atomic store of zero to the same workgroup lock before the barrier. The PR changes this to one store from LocalInvocationIndex == 0 and adds a structural regression check with a negative control. The focused SPIR-V lock test and conventions check pass on Linux; I could not run the reported AMD Windows GPU case here. If you can run agc_driver_lds_mixed_width_atomics on your RDNA 2 setup against the PR head, that would establish whether this race explains the hang.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6207524824 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6666#issuecomment-6207524824). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-16T03:37:52Z. --- I opened [PR #6670](https://github.com/boykopovar/AnyPS5/pull/6670) for a concrete SPIR-V issue in the lock setup: every invocation currently emits a non-atomic store of zero to the same workgroup lock before the barrier. The PR changes this to one store from `LocalInvocationIndex == 0` and adds a structural regression check with a negative control. The focused SPIR-V lock test and conventions check pass on Linux; I could not run the reported AMD Windows GPU case here. If you can run `agc_driver_lds_mixed_width_atomics` on your RDNA 2 setup against the PR head, that would establish whether this race explains the hang.
LeandroLP23 commented 2026-10-16 14:48:59 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-16T14:48:59Z.


RDNA 3 data point: agc_driver_lds_mixed_width_atomics passes 3 of 3 here, in under 0.3 s each, so the stall looks specific to RDNA 2 rather than to AMD's Windows driver in general.

Windows 11 (26300), Radeon 860M (RDNA 3.5, 1002:1114, driver 32.0.13058.8001), WinLibs GCC 15.2.0, Release, main 82ddae75b + #6436 (which only changes the SPIR-V words passed to vkCreateShaderModule), #6670 not applied.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6218082429 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6666#issuecomment-6218082429). Originally posted by [LeandroLP23](https://github.com/LeandroLP23) on 2026-10-16T14:48:59Z. --- RDNA 3 data point: `agc_driver_lds_mixed_width_atomics` passes 3 of 3 here, in under 0.3 s each, so the stall looks specific to RDNA 2 rather than to AMD's Windows driver in general. Windows 11 (26300), Radeon 860M (RDNA 3.5, `1002:1114`, driver 32.0.13058.8001), WinLibs GCC 15.2.0, Release, `main` `82ddae75b` + #6436 (which only changes the SPIR-V words passed to `vkCreateShaderModule`), #6670 not applied. AI-assisted: yes (Claude Code).
keravyn-ops commented 2026-10-17 08:27:41 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by keravyn-ops on 2026-10-17T08:27:41Z.


RDNA 3 data point: Radeon 780M (Ryzen Z1 Extreme, 0x15bf), AMD driver 25.10.20.01 (32.0.21020.1007), Windows 11 Home 10.0.26100, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release.

Build agc_spirv_lds_atomic_lock agc_driver_lds_mixed_width_atomics (256 threads), 3 runs
main 5d9dcc42d pass pass 3/3, 0.18–0.92 s
#6670 at 4864a7480 pass pass 3/3, 0.21–0.81 s

The test ran in full (lds mixed width atomics tests passed, no skip). So with this driver the 780M is not affected — the failure listed for a 780M in #3358 does not reproduce here on either build. With #3882 (RDNA 3.5 passes) and the RX 9060 XT above, the stall is so far seen only on RDNA 2 and GCN 5.

AI-assisted: yes (runs made on the device above).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6231735733 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6666#issuecomment-6231735733). Originally posted by [keravyn-ops](https://github.com/keravyn-ops) on 2026-10-17T08:27:41Z. --- RDNA 3 data point: Radeon 780M (Ryzen Z1 Extreme, 0x15bf), AMD driver 25.10.20.01 (32.0.21020.1007), Windows 11 Home 10.0.26100, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. | Build | `agc_spirv_lds_atomic_lock` | `agc_driver_lds_mixed_width_atomics` (256 threads), 3 runs | |---|---|---| | `main` 5d9dcc42d | pass | pass 3/3, 0.18–0.92 s | | #6670 at 4864a7480 | pass | pass 3/3, 0.21–0.81 s | The test ran in full (`lds mixed width atomics tests passed`, no skip). So with this driver the 780M is not affected — the failure listed for a 780M in #3358 does not reproduce here on either build. With #3882 (RDNA 3.5 passes) and the RX 9060 XT above, the stall is so far seen only on RDNA 2 and GCN 5. AI-assisted: yes (runs made on the device above).
Sign in to join this conversation.
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#6666
No description provided.