test: verify overlapping private LDS byte and halfword writes #860

Merged
MrSkelee merged 2 commits from upstream-pr/866 into main 2026-11-23 15:26:33 +00:00
MrSkelee commented 2026-11-23 14:52:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MrSkelee on 2026-11-23T14:52:23Z.


Lowers 5 sub-dword Local Data Share (LDS) read and write instructions in tools/compute_store_aot.py (cs_6_0) for thread-private LDS memory:

  • ds_read_i16: 16-bit signed load with sign-extension (offsets 0, 2)
  • ds_read_u8: 8-bit unsigned load with zero-extension (offsets 0..3)
  • ds_read_i8: 8-bit signed load with sign-extension (offsets 0..3)
  • ds_write_b16: 16-bit partial write with halfword masking (offsets 0, 2)
  • ds_write_b8: 8-bit partial write with byte masking (offsets 0..3)

Highlights

  • Operand & Addressing Validation:
    • Requires thread-private allocation (--lds-bytes >= 128), a verified local_x << 2 base address, and immediate s_waitcnt lgkmcnt(0) after every DS operation.
    • Enforces valid byte and halfword alignments/offsets: ds_read_i16/ds_write_b16 reject odd offsets; ds_read_u8/ds_read_i8/ds_write_b8 reject offsets > 3.
    • Rejects partial sub-dword writes without an earlier defining full-word store (ds_write_b32).
  • Offscreen Readback (WARP & Hardware):
    • Added dedicated lds_signed and lds_subwrite fixtures to tests/compute_store_check.py alongside private.
    • Compares 320 UAV words across dispatches of 1 and 3 groups against Python CPU reference bit-loops.
    • Includes negative mutation tests for sign extension, byte masking, and offset mutations that assert immediate mismatch detection.
  • Coverage: Credits 5 instructions on gfx1013 and gfx1030 under DS.

Verification

python -B tests/compute_store_check.py draw-lds-private "C:/Program Files (x86)/Windows Kits/10/bin/10.0.26100.0/x64/dxc.exe" "C:/Users/andre/Desktop/Xbox2Windows/out/build/dev/offscreen_check.exe" warp
python -B tests/rdna2_tools_check.py

Local results: 3/3 LDS draw fixtures passed (0 mismatches across 320 words for 1 and 3 groups), all 3 negative mutations detected, 75/75 unit tests passed.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6561995009 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/866). Originally posted by [MrSkelee](https://github.com/MrSkelee) on 2026-11-23T14:52:23Z. --- Lowers 5 sub-dword Local Data Share (LDS) read and write instructions in `tools/compute_store_aot.py` (`cs_6_0`) for thread-private LDS memory: - `ds_read_i16`: 16-bit signed load with sign-extension (offsets 0, 2) - `ds_read_u8`: 8-bit unsigned load with zero-extension (offsets 0..3) - `ds_read_i8`: 8-bit signed load with sign-extension (offsets 0..3) - `ds_write_b16`: 16-bit partial write with halfword masking (offsets 0, 2) - `ds_write_b8`: 8-bit partial write with byte masking (offsets 0..3) ### Highlights - **Operand & Addressing Validation**: - Requires thread-private allocation (`--lds-bytes >= 128`), a verified `local_x << 2` base address, and immediate `s_waitcnt lgkmcnt(0)` after every DS operation. - Enforces valid byte and halfword alignments/offsets: `ds_read_i16`/`ds_write_b16` reject odd offsets; `ds_read_u8`/`ds_read_i8`/`ds_write_b8` reject offsets > 3. - Rejects partial sub-dword writes without an earlier defining full-word store (`ds_write_b32`). - **Offscreen Readback (WARP & Hardware)**: - Added dedicated `lds_signed` and `lds_subwrite` fixtures to `tests/compute_store_check.py` alongside `private`. - Compares 320 UAV words across dispatches of 1 and 3 groups against Python CPU reference bit-loops. - Includes negative mutation tests for sign extension, byte masking, and offset mutations that assert immediate mismatch detection. - **Coverage**: Credits 5 instructions on `gfx1013` and `gfx1030` under `DS`. ### Verification ```powershell python -B tests/compute_store_check.py draw-lds-private "C:/Program Files (x86)/Windows Kits/10/bin/10.0.26100.0/x64/dxc.exe" "C:/Users/andre/Desktop/Xbox2Windows/out/build/dev/offscreen_check.exe" warp python -B tests/rdna2_tools_check.py ``` Local results: 3/3 LDS draw fixtures passed (0 mismatches across 320 words for 1 and 3 groups), all 3 negative mutations detected, 75/75 unit tests passed.
upstream-sync closed this pull request 2026-11-24 06:45:10 +00:00
stan495 commented 2026-11-24 06:49:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-23T14:58:27Z.


Thanks for working on this! #865 has landed on main and covers the same private LDS byte and halfword operations in the compute translator, including partial writes, signed and unsigned reads, and tests for every supported offset. If there’s a case in #866 that #865 missed, it would be worth keeping as a focused follow-up. Otherwise, I think we can close this as covered by #865.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7104827176 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/866#issuecomment-7104827176). Originally posted by [stan495](https://github.com/stan495) on 2026-11-23T14:58:27Z. --- Thanks for working on this! #865 has landed on `main` and covers the same private LDS byte and halfword operations in the compute translator, including partial writes, signed and unsigned reads, and tests for every supported offset. If there’s a case in #866 that #865 missed, it would be worth keeping as a focused follow-up. Otherwise, I think we can close this as covered by #865.
R0Y00 commented 2026-11-24 06:49:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T15:01:21Z.


#865 landed the five instruction forms and the disjoint-write controls. I kept your read-before-write fixture and based it on that implementation. It now reads the same byte before the halfword write, after that write, and after an overlapping byte write as part of the full word. That checks that the earlier reads survive both overwrites and that the final write preserves the other bytes.

WARP and RTX 4060 Laptop matched the full 320-word readback for one and three groups. Dropping the halfword write mismatched the intermediate read at word 1. Dropping the byte write mismatched the final word at word 2. LLVM 15 also passed. The updated branch is test-only and is waiting for a fresh CI run.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7104901839 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/866#issuecomment-7104901839). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-23T15:01:21Z. --- #865 landed the five instruction forms and the disjoint-write controls. I kept your read-before-write fixture and based it on that implementation. It now reads the same byte before the halfword write, after that write, and after an overlapping byte write as part of the full word. That checks that the earlier reads survive both overwrites and that the final write preserves the other bytes. WARP and RTX 4060 Laptop matched the full 320-word readback for one and three groups. Dropping the halfword write mismatched the intermediate read at word 1. Dropping the byte write mismatched the final word at word 2. LLVM 15 also passed. The updated branch is test-only and is waiting for a fresh CI run.
MrSkelee commented 2026-11-24 06:49:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MrSkelee on 2026-11-23T15:02:10Z.


Awesome, thank you @R0Y00! Glad the overlapping write fixture and readback checks are useful as a dedicated regression test.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7104923138 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/866#issuecomment-7104923138). Originally posted by [MrSkelee](https://github.com/MrSkelee) on 2026-11-23T15:02:10Z. --- Awesome, thank you @R0Y00! Glad the overlapping write fixture and readback checks are useful as a dedicated regression test.
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!860
No description provided.