docs: measure integer image atomics on 32-bit surfaces on gfx1100 #7939

Merged
DavidAmsellem merged 2 commits from upstream-pr/7939 into main 2026-10-20 04:00:24 +00:00
DavidAmsellem commented 2026-10-19 15:12:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-19T15:12:02Z.


What

The Image atomics entry says that image atomics on 32_SINT and 32_FLOAT surfaces "act on the raw dword through an R32_UINT storage view", with no measurement behind it. This adds one, from a gfx1100 (RX 7900 XT, RDNA3) with the hardware oracle. The 13 integer image atomics (swap, cmpswap, add, sub, smin, umin, smax, umax, and, or, xor, inc and dec) give identical results on 32_UINT, 32_SINT and 32_FLOAT T#s, and those results match a raw-dword model.

Method: a 512-texel 1D T# (TYPE 8) is built in SGPRs over the oracle's extra bytes, with one texel per lane, so no lanes contend. Each lane runs one image_atomic_<op> ... glc, waits, and reads the texel back with image_load ... glc dlc. Both the returned dword and the stored dword are compared with the model, using coarse memory.

Values: every pair of 0, 1, 0x7fffffff, 0x80000000, 0xffffffff, 1.0, -1.0, a quiet NaN, π, 5 and -5, as old texel and data: 121 rows per op and format. cmpswap alternates a comparand equal to the old value and one equal to the data.

32_UINT 32_SINT 32_FLOAT
old dword returned 121/121, every op 121/121, every op 121/121, every op
stored dword = raw-dword model 121/121, every op 121/121, every op 121/121, every op
identical to 32_UINT, row by row n/a every op every op

So add on a 32_FLOAT texel adds the bits (1.0 + 1.0 stores 0x7f000000, not 2.0). smin/smax are signed and umin/umax unsigned whatever the format. NaN and infinities are only bit patterns. wave32 and wave64 agree.

Control: the same kernel with 16_UINT and 8_8_8_8_UINT T#s does not match. 16_UINT returns the old dword on 11 of 121 rows, because the texels are 2 bytes wide. 8_8_8_8_UINT stores 0xff for 0x7fffffff data. So the T# format is read, and the identical results on the three 32-bit formats are the hardware's answer, not an ignored format field.

gfx1100 has no float image atomics (llvm-mc -mcpu=gfx1100 rejects image_atomic_fmin, image_atomic_fmax and image_atomic_fcmpswap). thuanquang measured them on gfx1031 (RX 6700 XT, RDNA2): the integer rows match gfx1100, and fmin, fmax and fcmpswap return and store the same dwords on 32_UINT, 32_SINT and 32_FLOAT (19,200 of 19,200 rows). The entry now cites that, so the float part is measured on RDNA2; the console's gfx1013 is still unmeasured, and the entry says so. The 8_8_8_8_UINT control behaves differently on the two GPUs, so the entry keeps 16_UINT as the control that shows the format is read. The 32-bit formats use the GFX11 codes 20, 21 and 22, which match GFX10. No behaviour changes.

Tested

Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, AMD Radeon RX 7900 XT (gfx1100), ROCm HSA runtime through tools/hw-oracle. Float controls on every run: ieee=0 dx10_clamp=1 denorm32=3 denorm16=3 round32=0 round16=0 fp16_overflow=0. Every op, format and wave size ran: 9,438 rows, plus 726 control rows. Documentation only: python3 tools/check_conventions.py --base upstream/main passes, and nothing was built.

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 under Silent stubs in their library's technical debt file
  • 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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: AMD Radeon RX 7900 XT (gfx1100), hardware oracle through the ROCm HSA runtime, Linux Mint 22.3 / kernel 7.0.0-38
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4923157739 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7939). Originally posted by [DavidAmsellem](https://github.com/DavidAmsellem) on 2026-10-19T15:12:02Z. --- ### What The [Image atomics](docs/dev/debt/shader.md) entry says that image atomics on 32_SINT and 32_FLOAT surfaces "act on the raw dword through an R32_UINT storage view", with no measurement behind it. This adds one, from a gfx1100 (RX 7900 XT, RDNA3) with the [hardware oracle](docs/dev/HW_ORACLE.md). The 13 integer image atomics (`swap`, `cmpswap`, `add`, `sub`, `smin`, `umin`, `smax`, `umax`, `and`, `or`, `xor`, `inc` and `dec`) give identical results on 32_UINT, 32_SINT and 32_FLOAT T#s, and those results match a raw-dword model. Method: a 512-texel 1D T# (TYPE 8) is built in SGPRs over the oracle's `extra` bytes, with one texel per lane, so no lanes contend. Each lane runs one `image_atomic_<op> ... glc`, waits, and reads the texel back with `image_load ... glc dlc`. Both the returned dword and the stored dword are compared with the model, using `coarse` memory. Values: every pair of 0, 1, 0x7fffffff, 0x80000000, 0xffffffff, 1.0, -1.0, a quiet NaN, π, 5 and -5, as old texel and data: 121 rows per op and format. `cmpswap` alternates a comparand equal to the old value and one equal to the data. | | 32_UINT | 32_SINT | 32_FLOAT | | --- | --- | --- | --- | | old dword returned | 121/121, every op | 121/121, every op | 121/121, every op | | stored dword = raw-dword model | 121/121, every op | 121/121, every op | 121/121, every op | | identical to 32_UINT, row by row | n/a | every op | every op | So `add` on a 32_FLOAT texel adds the bits (1.0 + 1.0 stores 0x7f000000, not 2.0). `smin`/`smax` are signed and `umin`/`umax` unsigned whatever the format. NaN and infinities are only bit patterns. wave32 and wave64 agree. Control: the same kernel with 16_UINT and 8_8_8_8_UINT T#s does not match. 16_UINT returns the old dword on 11 of 121 rows, because the texels are 2 bytes wide. 8_8_8_8_UINT stores 0xff for 0x7fffffff data. So the T# format is read, and the identical results on the three 32-bit formats are the hardware's answer, not an ignored format field. gfx1100 has no float image atomics (`llvm-mc -mcpu=gfx1100` rejects `image_atomic_fmin`, `image_atomic_fmax` and `image_atomic_fcmpswap`). [thuanquang measured them on gfx1031](https://github.com/boykopovar/AnyPS5/pull/7939#issuecomment-6275099482) (RX 6700 XT, RDNA2): the integer rows match gfx1100, and `fmin`, `fmax` and `fcmpswap` return and store the same dwords on 32_UINT, 32_SINT and 32_FLOAT (19,200 of 19,200 rows). The entry now cites that, so the float part is measured on RDNA2; the console's gfx1013 is still unmeasured, and the entry says so. The 8_8_8_8_UINT control behaves differently on the two GPUs, so the entry keeps 16_UINT as the control that shows the format is read. The 32-bit formats use the GFX11 codes 20, 21 and 22, which match GFX10. No behaviour changes. ### Tested Linux Mint 22.3 (Ubuntu 24.04 base), kernel 7.0.0-38, AMD Radeon RX 7900 XT (gfx1100), ROCm HSA runtime through `tools/hw-oracle`. Float controls on every run: `ieee=0 dx10_clamp=1 denorm32=3 denorm16=3 round32=0 round16=0 fp16_overflow=0`. Every op, format and wave size ran: 9,438 rows, plus 726 control rows. Documentation only: `python3 tools/check_conventions.py --base upstream/main` passes, and nothing was built. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: AMD Radeon RX 7900 XT (gfx1100), hardware oracle through the ROCm HSA runtime, Linux Mint 22.3 / kernel 7.0.0-38 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-19 15:17:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T15:17:37Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 7965 docs/dev/debt/shader.md L66-67

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 docs/dev/debt/shader.md
PR 5371 docs/dev/debt/shader.md
PR 5426 docs/dev/debt/shader.md
PR 5500 docs/dev/debt/shader.md
PR 5941 docs/dev/debt/shader.md
PR 6009 docs/dev/debt/shader.md
PR 6235 docs/dev/debt/shader.md
PR 6280 docs/dev/debt/shader.md
PR 6412 docs/dev/debt/shader.md
PR 6488 docs/dev/debt/shader.md
PR 6977 docs/dev/debt/shader.md
PR 7085 docs/dev/debt/shader.md
PR 7223 docs/dev/debt/shader.md
PR 7392 docs/dev/debt/shader.md
PR 7395 docs/dev/debt/shader.md
PR 7484 docs/dev/debt/shader.md
PR 7684 docs/dev/debt/shader.md
PR 7888 docs/dev/debt/shader.md
PR 7922 docs/dev/debt/shader.md
PR 8004 docs/dev/debt/shader.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6270690077 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7939#issuecomment-6270690077). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-19T15:17:37Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 7965](https://www.github.com/boykopovar/AnyPS5/pull/7965) | `docs/dev/debt/shader.md` [L66-67](https://github.com/boykopovar/AnyPS5/blob/525e299fc085c400de4a703c6b1ab105eefb50c7/docs/dev/debt/shader.md#L66-L67) | | | Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `docs/dev/debt/shader.md` | | [PR 5371](https://www.github.com/boykopovar/AnyPS5/pull/5371) | `docs/dev/debt/shader.md` | | [PR 5426](https://www.github.com/boykopovar/AnyPS5/pull/5426) | `docs/dev/debt/shader.md` | | [PR 5500](https://www.github.com/boykopovar/AnyPS5/pull/5500) | `docs/dev/debt/shader.md` | | [PR 5941](https://www.github.com/boykopovar/AnyPS5/pull/5941) | `docs/dev/debt/shader.md` | | [PR 6009](https://www.github.com/boykopovar/AnyPS5/pull/6009) | `docs/dev/debt/shader.md` | | [PR 6235](https://www.github.com/boykopovar/AnyPS5/pull/6235) | `docs/dev/debt/shader.md` | | [PR 6280](https://www.github.com/boykopovar/AnyPS5/pull/6280) | `docs/dev/debt/shader.md` | | [PR 6412](https://www.github.com/boykopovar/AnyPS5/pull/6412) | `docs/dev/debt/shader.md` | | [PR 6488](https://www.github.com/boykopovar/AnyPS5/pull/6488) | `docs/dev/debt/shader.md` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `docs/dev/debt/shader.md` | | [PR 7085](https://www.github.com/boykopovar/AnyPS5/pull/7085) | `docs/dev/debt/shader.md` | | [PR 7223](https://www.github.com/boykopovar/AnyPS5/pull/7223) | `docs/dev/debt/shader.md` | | [PR 7392](https://www.github.com/boykopovar/AnyPS5/pull/7392) | `docs/dev/debt/shader.md` | | [PR 7395](https://www.github.com/boykopovar/AnyPS5/pull/7395) | `docs/dev/debt/shader.md` | | [PR 7484](https://www.github.com/boykopovar/AnyPS5/pull/7484) | `docs/dev/debt/shader.md` | | [PR 7684](https://www.github.com/boykopovar/AnyPS5/pull/7684) | `docs/dev/debt/shader.md` | | [PR 7888](https://www.github.com/boykopovar/AnyPS5/pull/7888) | `docs/dev/debt/shader.md` | | [PR 7922](https://www.github.com/boykopovar/AnyPS5/pull/7922) | `docs/dev/debt/shader.md` | | [PR 8004](https://www.github.com/boykopovar/AnyPS5/pull/8004) | `docs/dev/debt/shader.md` |
thuanquang commented 2026-10-19 19:08:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-19T19:08:54Z.


The same measurement on RDNA 2: RX 6700 XT (gfx1031), through the HIP runtime of AMD's Windows driver, so the ISA runs as written. A 1024-texel 1D T# (TYPE 8) built in SGPRs, one texel per lane. Each lane writes its old value with global_store_dword ... glc, runs image_atomic_<op> ... glc, reads the texel back with image_load ... glc dlc and the raw dword with global_load_dword ... glc dlc. Your 11 values, 121 pairs per op and format, cmpswap comparand alternating old and data, IEEE 0, wave32 and wave64:

32_UINT 32_SINT 32_FLOAT 16_UINT 8_8_8_8_UINT
old dword returned, 13 integer ops 121/121 each 121/121 each 121/121 each 11/121 (3/121 for cmpswap) 121/121 each
stored dword = raw-dword model 121/121 each 121/121 each 121/121 each 5-58/121 121/121 each
image_load of the old value through the T# 121/121 121/121 121/121 11/121 33/121

So gfx1031 agrees with your gfx1100 rows on the three 32-bit formats. One control differs: on gfx1031 the atomics on an 8_8_8_8_UINT T# also act on the raw dword (add of 0x7fffffff to 0 stores 0x7fffffff), while image_load through the same T# returns the red channel only (the 33 rows are those with an old value below 256). 16_UINT, with 2-byte texels, does not match, so the texel size is read.

gfx1031 has the float image atomics, so the part the entry assumes can be measured there. image_atomic_fmin, image_atomic_fmax and image_atomic_fcmpswap over 20 x 20 pairs (signed zeros, denormals, the smallest normal, ±1, π, the largest normals, infinities, quiet and signalling NaNs of both signs and with payloads), at IEEE 0 and 1, with f32 denormals flushed and kept, wave32 and wave64: every returned and stored dword is the same on 32_UINT, 32_SINT and 32_FLOAT (19,200 of 19,200 rows). So the "float results are assumed to match those measured on 32_UINT surfaces" part holds on this GPU.

Those results follow the LDS float atomics rule in shader.md, including its denormal flush. The 32-bit forms flush both operands when bit 0 of the f32 denormal field is clear, and buffer_atomic_* and global_atomic_* do the same. The emulator's image, buffer and global paths don't flush: #8055.

This is desktop RDNA 2, not the console's gfx1013.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6275099482 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7939#issuecomment-6275099482). Originally posted by [thuanquang](https://github.com/thuanquang) on 2026-10-19T19:08:54Z. --- The same measurement on RDNA 2: RX 6700 XT (gfx1031), through the HIP runtime of AMD's Windows driver, so the ISA runs as written. A 1024-texel 1D T# (TYPE 8) built in SGPRs, one texel per lane. Each lane writes its old value with `global_store_dword ... glc`, runs `image_atomic_<op> ... glc`, reads the texel back with `image_load ... glc dlc` and the raw dword with `global_load_dword ... glc dlc`. Your 11 values, 121 pairs per op and format, `cmpswap` comparand alternating old and data, IEEE 0, wave32 and wave64: | | 32_UINT | 32_SINT | 32_FLOAT | 16_UINT | 8_8_8_8_UINT | |---|---|---|---|---|---| | old dword returned, 13 integer ops | 121/121 each | 121/121 each | 121/121 each | 11/121 (3/121 for `cmpswap`) | 121/121 each | | stored dword = raw-dword model | 121/121 each | 121/121 each | 121/121 each | 5-58/121 | 121/121 each | | `image_load` of the old value through the T# | 121/121 | 121/121 | 121/121 | 11/121 | 33/121 | So gfx1031 agrees with your gfx1100 rows on the three 32-bit formats. One control differs: on gfx1031 the atomics on an 8_8_8_8_UINT T# also act on the raw dword (`add` of 0x7fffffff to 0 stores 0x7fffffff), while `image_load` through the same T# returns the red channel only (the 33 rows are those with an old value below 256). 16_UINT, with 2-byte texels, does not match, so the texel size is read. gfx1031 has the float image atomics, so the part the entry assumes can be measured there. `image_atomic_fmin`, `image_atomic_fmax` and `image_atomic_fcmpswap` over 20 x 20 pairs (signed zeros, denormals, the smallest normal, ±1, π, the largest normals, infinities, quiet and signalling NaNs of both signs and with payloads), at IEEE 0 and 1, with f32 denormals flushed and kept, wave32 and wave64: every returned and stored dword is the same on 32_UINT, 32_SINT and 32_FLOAT (19,200 of 19,200 rows). So the "float results are assumed to match those measured on 32_UINT surfaces" part holds on this GPU. Those results follow the LDS float atomics rule in `shader.md`, including its denormal flush. The 32-bit forms flush both operands when bit 0 of the f32 denormal field is clear, and `buffer_atomic_*` and `global_atomic_*` do the same. The emulator's image, buffer and global paths don't flush: #8055. This is desktop RDNA 2, not the console's gfx1013.
DavidAmsellem commented 2026-10-19 22:10:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DavidAmsellem on 2026-10-19T22:10:08Z.


@thuanquang thank you, this closes the part I could not measure on gfx1100.

I'll update the entry with your gfx1031 rows: the integer atomics match on the three 32-bit formats on both GPUs, and your fmin, fmax and fcmpswap results (19,200 of 19,200 rows identical on 32_UINT, 32_SINT and 32_FLOAT) confirm the float part that the entry only assumed. It will cite your comment and still say that gfx1013 is unmeasured.

Your 8_8_8_8_UINT control is a real difference between the two GPUs: on gfx1100 the atomics on that T# did not follow the raw-dword model, while on gfx1031 they do. The entry will keep only 16_UINT as the control that shows the format is read, since it differs on both.

The missing denormal flush on the image, buffer and global float atomic paths belongs in its own change, so I'll leave it to #8055.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6278479936 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/7939#issuecomment-6278479936). Originally posted by [DavidAmsellem](https://github.com/DavidAmsellem) on 2026-10-19T22:10:08Z. --- @thuanquang thank you, this closes the part I could not measure on gfx1100. I'll update the entry with your gfx1031 rows: the integer atomics match on the three 32-bit formats on both GPUs, and your `fmin`, `fmax` and `fcmpswap` results (19,200 of 19,200 rows identical on 32_UINT, 32_SINT and 32_FLOAT) confirm the float part that the entry only assumed. It will cite your comment and still say that gfx1013 is unmeasured. Your 8_8_8_8_UINT control is a real difference between the two GPUs: on gfx1100 the atomics on that T# did not follow the raw-dword model, while on gfx1031 they do. The entry will keep only 16_UINT as the control that shows the format is read, since it differs on both. The missing denormal flush on the image, buffer and global float atomic paths belongs in its own change, so I'll leave it to #8055.
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!7939
No description provided.