Skip to content

amd: seed atomic RMW as divergent - #150

Merged
Zaneham merged 1 commit into
masterfrom
fix/amd-atomic-divergence
Aug 1, 2026
Merged

amd: seed atomic RMW as divergent#150
Zaneham merged 1 commit into
masterfrom
fix/amd-atomic-divergence

Conversation

@Zaneham

@Zaneham Zaneham commented Aug 1, 2026

Copy link
Copy Markdown
Owner

The AMD divergence analysis wasn't seeding BIR_ATOMIC_* RMW ops as divergent, so a GEP off an atomicAdd result took the scalar path in isel_gep and emitted s_add_u32 with a VGPR source. The verifier caught it; hardware would just fault. This is the "AMD path currently trips a regalloc bug on the byte-copy loop" note in docs/mainframe.md and examples/launch_sysprint.c, both cleared here.

Seeds BIR_ATOMIC_{ADD,SUB,AND,OR,XOR,MIN,MAX,XCHG,CAS} alongside BIR_THREAD_ID and the shuffles. ATOMIC_LOAD and ATOMIC_STORE don't need seeding. Per-thread SYSPRINT now compiles clean on AMD; test suite unchanged (347/11/1 before and after).

Not GPU-executed on my end (no HSA runtime on this Windows box). Verifier's vfy_sop is check #1 for exactly this class, so it's a strong proxy, but the actual hardware run is worth doing before merging.

…path

atomicAdd (and the rest of the atomic RMW family) returns the pre-op value
seen by *this lane* — even with a uniform address and operand, lanes
serialise on the atomic and each gets a different old value back. The
isel already puts the result in a VGPR, but divergence_analysis was
missing the seed, so a downstream GEP off the atomic result took the
scalar path in isel_gep and emitted s_add_u32 with a VGPR source. The
verifier caught it as "VGPR in scalar source"; hardware would just
fault.

Seed BIR_ATOMIC_{ADD,SUB,AND,OR,XOR,MIN,MAX,XCHG,CAS} alongside
BIR_THREAD_ID and BIR_SHFL_*. ATOMIC_LOAD stays out (uniform if the
address is uniform, propagation handles the rest); ATOMIC_STORE has
no result to track.

Unblocks per-thread SYSPRINT on AMD. Docs and the launcher comment
were carrying the "AMD path currently trips a regalloc bug" caveat,
which is no longer true.
@Zaneham Zaneham added the backend: AMD AMD GFX9/10/11/12 backend (isel, regalloc, ELF encode) label Aug 1, 2026
@Zaneham
Zaneham merged commit 4da655f into master Aug 1, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend: AMD AMD GFX9/10/11/12 backend (isel, regalloc, ELF encode)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant