Tests: verify RDNA2 FLAT and GLOBAL memory ops on the GPU #1626

Open
Vadson159 wants to merge 1 commit from upstream-pr/1636 into main
Vadson159 commented 2026-11-24 18:27:37 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Vadson159 on 2026-11-24T18:27:37Z.


Adds standalone GPU execution and translation integration tests in crates/xcl/tests/gpu_recomp_flat_global.rs covering RDNA2 ENC_FLAT (FLAT_) and previously untested ENC_FLAT_GLBL (GLOBAL_) memory instructions per the AMD RDNA2 ISA specification.

What is in it

  • lat_and_global_translate_and_compile_with_dxc: verifies ENC_FLAT unsigned 12-bit (x00000800u) vs ENC_FLAT_GLBL signed 12-bit (xFFFFF800u) offsets, mem_windows = 2 register selection ( 1, 3, s5), and DXC cs_6_6 compilation across all four wave configs (wave64, split-wave64, wave32, wave32@hw64), skipping via
    unner::skip_test("no DXC") if DXC is absent.
  • gpu_flat_and_global_multi_dword_and_offsets: executes FLAT_STORE/LOAD_DWORD/X2/X3/X4, VDST == ADDR overlap (FLAT_LOAD_DWORDX2/X4, GLOBAL_LOAD_DWORD), +2048 vs -2048 offsets, GLOBAL_STORE/LOAD_DWORD (SADDR = 0x7D/x7F, negative offsets), GLOBAL_STORE/LOAD_DWORDX3, GLOBAL_LOAD_DWORDX4, and divergent EXEC masking across active wave configs.
  • gpu_flat_and_global_sub_dword_and_d16: executes FLAT_LOAD_UBYTE/SBYTE/USHORT/SSHORT, FLAT_STORE_BYTE/SHORT, FLAT_LOAD/STORE__D16/D16_HI, and previously untested GLOBAL sub-dword/D16 instructions across unaligned and dword-straddling byte offsets with EXEC masking.
  • gpu_flat_and_global_atomics_32_and_64: table-driven GPU verification of all 13 FLAT_ATOMIC_* 32-bit ops, all 13 FLAT_ATOMIC_X2 64-bit ops, previously untested 32/64-bit GLOBAL_ATOMIC ops and positive GLOBAL_ATOMIC_CSUB, alignment truncation (& ~3, & ~7), GLC=0 sentinel preservation vs GLC=1 old-value return, EXEC masking, and shared-address multi-lane contention (ADD, XOR, CMPSWAP, ADD_X2, CMPSWAP_X2).

Tested

  • Hardware / toolchain: Windows x64, AMD Ryzen 7 9800X3D, AMD Radeon RX 9070 XT, Windows SDK DXC 1.8.2502.11,
    ustc 1.100.0 (0ef1bc386 2026-11-09).
  • .\scripts\test.ps1 (cargo build --workspace && cargo test --workspace -- --test-threads=4): 780 passed, 0 failed, 41 ignored (XCL_SAMPLE_* unset; 1 GPU test skipped on this adapter: heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows).
  • cargo test -p xcl --test gpu_recomp_flat_global -- --nocapture: 4 passed, 0 failed, 0 ignored (0 skipped).
  • cargo clippy -p xcl --test gpu_recomp_flat_global -- --no-deps: 0 warnings in crates/xcl/tests/gpu_recomp_flat_global.rs (452 pre-existing warnings in xcl lib).

Not tested

  • Retail game smoke runs (scripts/smoke.ps1) and XCL_SAMPLE_*-gated tests (XCL_SAMPLE_RPF, XCL_SAMPLE_DLLS, XCL_SAMPLE_TTPF, XCL_SAMPLE_BCPACK, XCL_SAMPLE_BK2, XCL_SAMPLE_BVH4, XCL_SAMPLE_AWC, XCL_SAMPLE_XG, XCL_SAMPLE_DXC unset; tests-only PR).
  • heap_window_out_of_memory_falls_back_to_the_switch_form (skipped on this adapter:
    o heap windows).

AI use

  • Antigravity (exact model name not provided to agent): wrote crates/xcl/tests/gpu_recomp_flat_global.rs, ran the test suite and clippy checks, and prepared this PR.
<!-- greyfinch-sync:ivall/xcl:issue:5477990323 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1636). Originally posted by [Vadson159](https://github.com/Vadson159) on 2026-11-24T18:27:37Z. --- Adds standalone GPU execution and translation integration tests in crates/xcl/tests/gpu_recomp_flat_global.rs covering RDNA2 ENC_FLAT (FLAT_*) and previously untested ENC_FLAT_GLBL (GLOBAL_*) memory instructions per the AMD RDNA2 ISA specification. **What is in it** - lat_and_global_translate_and_compile_with_dxc: verifies ENC_FLAT unsigned 12-bit (x00000800u) vs ENC_FLAT_GLBL signed 12-bit (xFFFFF800u) offsets, mem_windows = 2 register selection ( 1, 3, s5), and DXC cs_6_6 compilation across all four wave configs (wave64, split-wave64, wave32, wave32@hw64), skipping via unner::skip_test("no DXC") if DXC is absent. - gpu_flat_and_global_multi_dword_and_offsets: executes FLAT_STORE/LOAD_DWORD/X2/X3/X4, VDST == ADDR overlap (FLAT_LOAD_DWORDX2/X4, GLOBAL_LOAD_DWORD), +2048 vs -2048 offsets, GLOBAL_STORE/LOAD_DWORD (SADDR = 0x7D/x7F, negative offsets), GLOBAL_STORE/LOAD_DWORDX3, GLOBAL_LOAD_DWORDX4, and divergent EXEC masking across active wave configs. - gpu_flat_and_global_sub_dword_and_d16: executes FLAT_LOAD_UBYTE/SBYTE/USHORT/SSHORT, FLAT_STORE_BYTE/SHORT, FLAT_LOAD/STORE_*_D16/_D16_HI, and previously untested GLOBAL_* sub-dword/D16 instructions across unaligned and dword-straddling byte offsets with EXEC masking. - gpu_flat_and_global_atomics_32_and_64: table-driven GPU verification of all 13 FLAT_ATOMIC_* 32-bit ops, all 13 FLAT_ATOMIC_*_X2 64-bit ops, previously untested 32/64-bit GLOBAL_ATOMIC_* ops and positive GLOBAL_ATOMIC_CSUB, alignment truncation (& ~3, & ~7), GLC=0 sentinel preservation vs GLC=1 old-value return, EXEC masking, and shared-address multi-lane contention (ADD, XOR, CMPSWAP, ADD_X2, CMPSWAP_X2). **Tested** - Hardware / toolchain: Windows x64, AMD Ryzen 7 9800X3D, AMD Radeon RX 9070 XT, Windows SDK DXC 1.8.2502.11, ustc 1.100.0 (0ef1bc386 2026-11-09). - .\scripts\test.ps1 (cargo build --workspace && cargo test --workspace -- --test-threads=4): 780 passed, 0 failed, 41 ignored (XCL_SAMPLE_* unset; 1 GPU test skipped on this adapter: heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows). - cargo test -p xcl --test gpu_recomp_flat_global -- --nocapture: 4 passed, 0 failed, 0 ignored (0 skipped). - cargo clippy -p xcl --test gpu_recomp_flat_global -- --no-deps: 0 warnings in crates/xcl/tests/gpu_recomp_flat_global.rs (452 pre-existing warnings in xcl lib). **Not tested** - Retail game smoke runs (scripts/smoke.ps1) and XCL_SAMPLE_*-gated tests (XCL_SAMPLE_RPF, XCL_SAMPLE_DLLS, XCL_SAMPLE_TTPF, XCL_SAMPLE_BCPACK, XCL_SAMPLE_BK2, XCL_SAMPLE_BVH4, XCL_SAMPLE_AWC, XCL_SAMPLE_XG, XCL_SAMPLE_DXC unset; tests-only PR). - heap_window_out_of_memory_falls_back_to_the_switch_form (skipped on this adapter: o heap windows). **AI use** - Antigravity (exact model name not provided to agent): wrote crates/xcl/tests/gpu_recomp_flat_global.rs, ran the test suite and clippy checks, and prepared this PR.
mantavisual commented 2026-11-24 21:09:15 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by mantavisual on 2026-11-24T20:03:06Z.


Test report for a77b5050574c33379987476898442ba1f1c1d068 on NVIDIA, which is not in the PR's hardware list.

Tested

  • RTX 4060 8 GB (driver 616.92, wave32), i5-13600K, 32 GB, Windows 11 Pro 22631, Rust 1.100.0 MSVC, DXC 1.9.2602.17 (SDK 10.0.26100), debug.
  • cargo test --workspace --locked --no-fail-fast -- --test-threads=4: 780 passed, 0 failed, 41 ignored. All 4 new tests ran.
  • Merged locally with main c160d86: 862 passed, 0 failed, 42 ignored.
  • SKIPPED in both: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).

Do the tests notice a broken translator?

  • Gap: with the sign extension of the GLOBAL offset removed in flat_atomic, all 4 tests still pass, because the GLOBAL atomics only use offsets 0x00 to 0x48. Subtracting 0x40 from the GLOBAL 32-bit offsets (& 0xFFF) and adding 0x40 to v2 passes normally and fails with that break (I enlarged mem32 to 0x8000 bytes to keep the broken run in bounds).
  • Of 7 other breaks, 6 made the tests fail, one of them by a device hang rather than an assertion. Masking 64-bit addresses with 3 instead of 7 was not noticed, perhaps because this GPU aligns them itself.

Not tested: AMD, native wave64, retail title.

AI use: Claude Code (Claude Opus 5.5) ran this on my machine, wrote the report and posted it for me.

<!-- greyfinch-sync:ivall/xcl:comment:7142971926 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1636#issuecomment-7142971926). Originally posted by [mantavisual](https://github.com/mantavisual) on 2026-11-24T20:03:06Z. --- Test report for `a77b5050574c33379987476898442ba1f1c1d068` on NVIDIA, which is not in the PR's hardware list. **Tested** - RTX 4060 8 GB (driver 616.92, wave32), i5-13600K, 32 GB, Windows 11 Pro 22631, Rust 1.100.0 MSVC, DXC 1.9.2602.17 (SDK 10.0.26100), debug. - `cargo test --workspace --locked --no-fail-fast -- --test-threads=4`: 780 passed, 0 failed, 41 ignored. All 4 new tests ran. - Merged locally with main `c160d86`: 862 passed, 0 failed, 42 ignored. - SKIPPED in both: `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware` (no wave64), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). **Do the tests notice a broken translator?** - Gap: with the sign extension of the GLOBAL offset removed in `flat_atomic`, all 4 tests still pass, because the GLOBAL atomics only use offsets 0x00 to 0x48. Subtracting 0x40 from the GLOBAL 32-bit offsets (`& 0xFFF`) and adding 0x40 to v2 passes normally and fails with that break (I enlarged `mem32` to 0x8000 bytes to keep the broken run in bounds). - Of 7 other breaks, 6 made the tests fail, one of them by a device hang rather than an assertion. Masking 64-bit addresses with 3 instead of 7 was not noticed, perhaps because this GPU aligns them itself. **Not tested:** AMD, native wave64, retail title. **AI use:** Claude Code (Claude Opus 5.5) ran this on my machine, wrote the report and posted it for me.
DavidM1911 commented 2026-11-24 21:09:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T20:56:14Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored.

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7144255578 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1636#issuecomment-7144255578). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T20:56:14Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~22 ignored. Thanks!
github-actions[bot] commented 2026-11-28 08:00:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-28T08:00:46Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7236304119 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1636#issuecomment-7236304119). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T08:00:46Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 06:21:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:21:18Z.


Triage (#1607) – head a77b505

No open or merged PR makes the same change. #2143 also covers FLAT/GLOBAL/SCRATCH, but it checks direct-DXIL against HLSL output, not values on the GPU.
No problems found in the diff. The tests skip without a GPU, DXC and wave64 programs, so CI does not run them. The expected values (offsets of +/-2048, D16 halves, CSUB clamping, CMPSWAP winners, EXEC-masked lanes) have only been checked on the author's hardware.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7302776193 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1636#issuecomment-7302776193). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:21:18Z. --- **Triage (#1607)** – head a77b505 No open or merged PR makes the same change. #2143 also covers FLAT/GLOBAL/SCRATCH, but it checks direct-DXIL against HLSL output, not values on the GPU. No problems found in the diff. The tests skip without a GPU, DXC and wave64 programs, so CI does not run them. The expected values (offsets of +/-2048, D16 halves, CSUB clamping, CMPSWAP winners, EXEC-masked lanes) have only been checked on the author's hardware. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
grathepic commented 2026-12-02 23:36:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by grathepic on 2026-12-02T23:36:38Z.


merge-check

  • base: 078358a058
  • head: a77b505057
  • merge: clean (git diff --check exit 0)
  • build: cargo +1.98.1-x86_64-pc-windows-msvc build --offline --locked --workspace — exit 0 (36 pre-existing warnings in xcl lib)
  • tests: cargo +1.98.1-x86_64-pc-windows-msvc test --offline --locked --workspace --no-fail-fast -- --test-threads=4 (with XCL_DXC_DIR=C:\VulkanSDK\1.4.363.0\Bin) — 3010 passed, 0 failed, 52 ignored across 45 harnesses; 27 SKIPPED (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps, 1 no dxil.dll, 1 cannot disable the driver cache (Windows Developer Mode required)). All 4 new tests in tests\gpu_recomp_flat_global.rs (flat_and_global_translate_and_compile_with_dxc, gpu_flat_and_global_multi_dword_and_offsets, gpu_flat_and_global_sub_dword_and_d16, gpu_flat_and_global_atomics_32_and_64) ran and passed in 0.84s with 0 skips.
  • title run: not required (Tier 0 test-only PR; adds crates/xcl/tests/gpu_recomp_flat_global.rs with zero production code or dependency changes)
  • review: Read full 433-line diff. Strictly test-only (+433/-0, slightly over the ~400-line soft target). Covers FLAT unsigned vs GLOBAL signed offset encoding and DXC compilation across 4 wave configs, multi-dword loads/stores, sub-dword and D16 (including unaligned/straddling) ops, and 32/64-bit FLAT/GLOBAL atomics (table cases, shared-address multi-lane contention, EXEC masking, GLC=0/1). Memory layouts are in-bounds and disjoint per lane. Non-blocking note: GLOBAL_ATOMIC_* table entries only use non-negative offsets (0x00..0x48), while negative global offsets are covered by the load/store tests. No duplicates in #1607.
  • performance: not applicable (test-only; new harness completes in 0.84s)
  • verdict: safe to merge
  • hardware / tool and model: NVIDIA GeForce RTX 3080 (driver 32.0.16.2140), AMD Ryzen 7 5800X3D, Windows 11 (10.0.26300.0), Rust 1.98.1-x86_64-pc-windows-msvc, DXC 1.9.0.5512 (VulkanSDK, no dxil.dll) / Antigravity, Gemini 4 Neon
<!-- greyfinch-sync:ivall/xcl:comment:7362212548 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1636#issuecomment-7362212548). Originally posted by [grathepic](https://github.com/grathepic) on 2026-12-02T23:36:38Z. --- merge-check - base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a - head: a77b5050574c33379987476898442ba1f1c1d068 - merge: clean (`git diff --check` exit 0) - build: `cargo +1.98.1-x86_64-pc-windows-msvc build --offline --locked --workspace` — exit 0 (36 pre-existing warnings in `xcl` lib) - tests: `cargo +1.98.1-x86_64-pc-windows-msvc test --offline --locked --workspace --no-fail-fast -- --test-threads=4` (with `XCL_DXC_DIR=C:\VulkanSDK\1.4.363.0\Bin`) — 3010 passed, 0 failed, 52 ignored across 45 harnesses; 27 SKIPPED (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps, 1 no dxil.dll, 1 cannot disable the driver cache (Windows Developer Mode required)). All 4 new tests in `tests\gpu_recomp_flat_global.rs` (`flat_and_global_translate_and_compile_with_dxc`, `gpu_flat_and_global_multi_dword_and_offsets`, `gpu_flat_and_global_sub_dword_and_d16`, `gpu_flat_and_global_atomics_32_and_64`) ran and passed in 0.84s with 0 skips. - title run: not required (Tier 0 test-only PR; adds `crates/xcl/tests/gpu_recomp_flat_global.rs` with zero production code or dependency changes) - review: Read full 433-line diff. Strictly test-only (`+433/-0`, slightly over the ~400-line soft target). Covers FLAT unsigned vs GLOBAL signed offset encoding and DXC compilation across 4 wave configs, multi-dword loads/stores, sub-dword and D16 (including unaligned/straddling) ops, and 32/64-bit FLAT/GLOBAL atomics (table cases, shared-address multi-lane contention, `EXEC` masking, `GLC=0/1`). Memory layouts are in-bounds and disjoint per lane. Non-blocking note: `GLOBAL_ATOMIC_*` table entries only use non-negative offsets (`0x00..0x48`), while negative global offsets are covered by the load/store tests. No duplicates in #1607. - performance: not applicable (test-only; new harness completes in 0.84s) - verdict: safe to merge - hardware / tool and model: NVIDIA GeForce RTX 3080 (driver 32.0.16.2140), AMD Ryzen 7 5800X3D, Windows 11 (10.0.26300.0), Rust 1.98.1-x86_64-pc-windows-msvc, DXC 1.9.0.5512 (VulkanSDK, no dxil.dll) / Antigravity, Gemini 4 Neon
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1636:upstream-pr/1636'
git switch 'upstream-pr/1636'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1636'
git switch 'upstream-pr/1636'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1636'
git switch 'upstream-pr/1636'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1636'
git switch 'main'
git merge --squash 'upstream-pr/1636'
git switch 'main'
git merge --ff-only 'upstream-pr/1636'
git switch 'main'
git merge 'upstream-pr/1636'
git push origin 'main'
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
xcl-dev/xcl!1626
No description provided.