Skip to content

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

Open
Vadson159 wants to merge 1 commit into
xcl-dev:mainfrom
Vadson159:test/recomp-flat-global
Open

Vadson159 wants to merge 1 commit into
xcl-dev:mainfrom
Vadson159:test/recomp-flat-global

Conversation

@Vadson159

Copy link
Copy Markdown
Contributor

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.

Add an integration test suite verifying RDNA2 ENC_FLAT (FLAT_*) and
previously untested ENC_FLAT_GLBL (GLOBAL_*) memory instructions on the
GPU across all supported wave execution configurations (wave64,
split-wave64, wave32, wave32@hw64):

- Multi-dword loads/stores (DWORD, DWORDX2, DWORDX3, DWORDX4),
  VDST == ADDR register overlap, signed 12-bit ENC_FLAT_GLBL offsets vs
  unsigned 12-bit ENC_FLAT offsets, SADDR == off 64-bit VGPR addresses
  vs SGPR + VGPR addressing, and mem_windows=2 translation
- Sub-dword and D16 loads/stores across unaligned and dword-straddling
  offsets
- All 32-bit and 64-bit (_X2) integer atomics plus GLOBAL_ATOMIC_CSUB,
  including alignment truncation, GLC=0/1 sentinel/old-value handling,
  EXEC masking, and multi-lane contention

Measured via scripts/test.ps1 on AMD Ryzen 7 9800X3D / AMD Radeon RX
9070 XT (DXC 1.8.2502.11): 780 passed, 0 failed, 41 ignored
(XCL_SAMPLE_* unset), 1 GPU test skipped (no heap windows); standalone
gpu_recomp_flat_global: 4 passed, 0 failed.

Assisted-by: Antigravity (exact model name not provided to agent)
@mantavisual

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

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

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

Thanks!

@ivall ivall added the off-goal Does not bear on the current goal (world loading); waits until it is reached label Nov 24, 2026
@github-actions

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the stale No activity for 3 days; closed 4 days later unless something happens label Nov 28, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown

merge-check

  • base: 078358a
  • head: a77b505
  • 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 PR triage: duplicate PRs and batch-tested PRs, each checked by two contributors #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

@github-actions github-actions Bot added area:tests Unit, integration, e2e tests, or testtitle gpu:amd Code is specific to AMD / RDNA / wave64 GPUs (scope tag; see needs:amd-test) needs-1st-check Passes gates; needs first independent merge-check (#3041) labels Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:tests Unit, integration, e2e tests, or testtitle gpu:amd Code is specific to AMD / RDNA / wave64 GPUs (scope tag; see needs:amd-test) needs-1st-check Passes gates; needs first independent merge-check (#3041) off-goal Does not bear on the current goal (world loading); waits until it is reached stale No activity for 3 days; closed 4 days later unless something happens

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants