shader: lower gfx1030 fixed-address integer atomic reductions #1347

Merged
stan495 merged 1 commit from upstream-pr/1354 into main 2026-11-24 09:31:12 +00:00
stan495 commented 2026-11-24 09:00:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-24T09:00:25Z.


Summary

  • Lower one fixed-address non-returning gfx1030 32-bit buffer_atomic_add/sub/and/or/xor/smin/umin/smax/umax operation to the matching HLSL raw UAV interlocked operation. Use modular arithmetic for subtraction and the matching signedness overload for min/max.
  • Require a verified descriptor and data VGPR, DWORD-aligned immediate, zero scalar offset, and off. Refuse glc, indexed access, and any additional UAV operation. The tested lane guard selects different numbers of contending threads.
  • Compare every output word against an independent reduction reference, and exercise LLVM 15 assembly, disassembly, and the compute-container CLI.

Validation

Commit tested 07f0d40b34329e4955b283cd82151ff9aa6554a9.

cmake --build --preset dev --target offscreen_check
$env:CTEST_PARALLEL_LEVEL = '2'
ctest --preset dev --no-tests=error -R '^compute_store_aot_' -V --output-junit "$PWD/out/compute-store-07f0d40b.xml"
python -B tools/form_coverage.py out/compute-store-07f0d40b.xml --records out/build/dev/form_coverage --gaps gfx1030 --json out/compute-store-07f0d40b.json
python -B tests/form_coverage_check.py
python -B tests/docs_links_check.py

48 passed, 0 failed, 0 capability skips. The passing WARP and hardware fixtures both record all nine new forms. Windows build 26300.9974, WARP on Microsoft Basic Render Driver (10.0.26100.9818), and hardware on Intel Arc B390 (32.0.101.8509). The debug layer was unavailable on both. The dispatches execute translated DXIL. The wrong-operation and signedness mutants fail at word 1, including add vs. sub (eec30576 expected, 9cc88614 actual) and signed vs. unsigned min (a434c802 expected, 2434c800 actual).

python3 -B tests/compute_store_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1

Passed on Ubuntu 22.04.5 with LLVM 15.0.7. Coverage and docs self-checks passed.

The D16 load, formatted-store, and atomic-reduction fixture modes all passed on both adapters from the simulated integration bed1478a361de258dcad11bbf9bc8446cf2427bb, with #1343, #1346, and this branch applied in order.

git diff --check and git merge-tree --write-tree refs/remotes/origin/main HEAD passed, with main at c4966c6439b2747831d160a346d8f466ff094b25.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6578224621 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1354). Originally posted by [stan495](https://github.com/stan495) on 2026-11-24T09:00:25Z. --- ## Summary - Lower one fixed-address non-returning gfx1030 32-bit `buffer_atomic_add/sub/and/or/xor/smin/umin/smax/umax` operation to the matching HLSL raw UAV interlocked operation. Use modular arithmetic for subtraction and the matching signedness overload for min/max. - Require a verified descriptor and data VGPR, DWORD-aligned immediate, zero scalar offset, and `off`. Refuse `glc`, indexed access, and any additional UAV operation. The tested lane guard selects different numbers of contending threads. - Compare every output word against an independent reduction reference, and exercise LLVM 15 assembly, disassembly, and the compute-container CLI. ## Validation Commit tested `07f0d40b34329e4955b283cd82151ff9aa6554a9`. ```powershell cmake --build --preset dev --target offscreen_check $env:CTEST_PARALLEL_LEVEL = '2' ctest --preset dev --no-tests=error -R '^compute_store_aot_' -V --output-junit "$PWD/out/compute-store-07f0d40b.xml" python -B tools/form_coverage.py out/compute-store-07f0d40b.xml --records out/build/dev/form_coverage --gaps gfx1030 --json out/compute-store-07f0d40b.json python -B tests/form_coverage_check.py python -B tests/docs_links_check.py ``` 48 passed, 0 failed, 0 capability skips. The passing WARP and hardware fixtures both record all nine new forms. Windows build `26300.9974`, WARP on Microsoft Basic Render Driver (`10.0.26100.9818`), and hardware on Intel Arc B390 (`32.0.101.8509`). The debug layer was unavailable on both. The dispatches execute translated DXIL. The wrong-operation and signedness mutants fail at word 1, including add vs. sub (`eec30576` expected, `9cc88614` actual) and signed vs. unsigned min (`a434c802` expected, `2434c800` actual). ```sh python3 -B tests/compute_store_check.py binary llvm-mc-15 llvm-objcopy-15 libLLVM-15.so.1 ``` Passed on Ubuntu 22.04.5 with LLVM 15.0.7. Coverage and docs self-checks passed. The D16 load, formatted-store, and atomic-reduction fixture modes all passed on both adapters from the simulated integration `bed1478a361de258dcad11bbf9bc8446cf2427bb`, with #1343, #1346, and this branch applied in order. `git diff --check` and `git merge-tree --write-tree refs/remotes/origin/main HEAD` passed, with main at `c4966c6439b2747831d160a346d8f466ff094b25`.
upstream-sync closed this pull request 2026-11-24 10:02:27 +00:00
tedin7 commented 2026-11-24 10:02:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T09:22:45Z.

Review: COMMENTED


Technical peer-review at commit 07f0d40b34329e4955b283cd82151ff9aa6554a9.

Verification

  • Linux / LLVM-19:
    • git diff --check origin/main...HEAD: clean.
    • tests/docs_links_check.py: passed (16 Markdown files, 300 links).
    • tests/bidi_controls_check.py: passed (1119 tracked files).
    • tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so: passed.
    • tests/rdna2_tools_check.py: passed (138 tests, 18 skipped).
    • tests/form_coverage_check.py: passed.
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev): 2/2 passed (compute_store_aot_mubuf_reduction_{warp,hardware}) in 4.61s.
    • Release /O2 (--preset release): 2/2 passed in 4.53s.

Code Review Notes

  • tools/compute_store_aot.py: Properly enforces cpu == "gfx1030", raw u0 (stride is None and output_format is None), off, zero scalar offset, 4-byte aligned offset <= 4095, verified s[base:base+3] descriptor at lgkmcnt(0), known data VGPR (src <= 255), and sole UAV store/atomic (stores / atomic_reduction mutual exclusion).
  • DXIL lowering: Modular subtraction ((0u - word)) with InterlockedAdd and signedness selection (int + asint(word) for smin/smax, uint otherwise) match the Interlocked* overloads cleanly.
  • Tests: Negative controls cover glc, idxen, non-zero scalar offset, unaligned/out-of-range offsets, unaligned/unwaited descriptor, unknown data VGPR, duplicate/mixed UAV ops, non-gfx1030, and structured stride; the GPU fixture exercises multi-group lane contention and wrong-op/wrong-signedness mutations.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6036613713 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1354#pullrequestreview-6036613713). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T09:22:45Z. **Review:** COMMENTED --- Technical peer-review at commit `07f0d40b34329e4955b283cd82151ff9aa6554a9`. ### Verification - **Linux / LLVM-19**: - `git diff --check origin/main...HEAD`: clean. - `tests/docs_links_check.py`: passed (16 Markdown files, 300 links). - `tests/bidi_controls_check.py`: passed (1119 tracked files). - `tests/compute_store_check.py binary llvm-mc-19 llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so`: passed. - `tests/rdna2_tools_check.py`: passed (`138` tests, `18` skipped). - `tests/form_coverage_check.py`: passed. - **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)**: - **Debug (`--preset dev`)**: 2/2 passed (`compute_store_aot_mubuf_reduction_{warp,hardware}`) in `4.61s`. - **Release `/O2` (`--preset release`)**: 2/2 passed in `4.53s`. ### Code Review Notes - **`tools/compute_store_aot.py`**: Properly enforces `cpu == "gfx1030"`, raw `u0` (`stride is None and output_format is None`), `off`, zero scalar offset, 4-byte aligned `offset <= 4095`, verified `s[base:base+3]` descriptor at `lgkmcnt(0)`, known data VGPR (`src <= 255`), and sole UAV store/atomic (`stores` / `atomic_reduction` mutual exclusion). - **DXIL lowering**: Modular subtraction (`(0u - word)`) with `InterlockedAdd` and signedness selection (`int` + `asint(word)` for `smin`/`smax`, `uint` otherwise) match the `Interlocked*` overloads cleanly. - **Tests**: Negative controls cover `glc`, `idxen`, non-zero scalar offset, unaligned/out-of-range offsets, unaligned/unwaited descriptor, unknown data VGPR, duplicate/mixed UAV ops, non-`gfx1030`, and structured stride; the GPU fixture exercises multi-group lane contention and wrong-op/wrong-signedness mutations.
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
R0Y00/Xbox2Windows!1347
No description provided.