Shader tests: a cross-half UAV ordering probe under Emulate (#3766) #3874

Open
omarsaifuddin wants to merge 20 commits from upstream-pr/3874 into main
omarsaifuddin commented 2026-11-30 06:34:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by omarsaifuddin on 2026-11-30T06:34:28Z.


Stacked on #189 (base 3e39e34). The change is the last commit; the rest of the diff is #189's branch.

What

An ignored probe for the Emulate form of #3766, ported from ColorMeBoom's probe/main-uav-order (itself neonbyte1's uav_write_then_read).

Lane writer of each console wave stores 1 + a dword only it loaded to its wave's slot; lane reader then loads the slot. On the console the reader sees the store: both lanes are in one wave and the instructions are in program order. The probe runs it under Wave64Mode::Emulate for three programs — no lane reads, plus a DPP op, plus a v_readlane — on every NVIDIA adapter. The DPP and readlane forms declare WaveSize(64) on main and never build on a 32-lane host; under Emulate they translate and run.

Measured (RTX 3070 Ti, Windows 11, driver 32.0.16.2140, wave 32..=32)

Stale reads per reads, PROBE_RUNS=64, one group per dispatch. Writer in the high half, reader in the low half:

program 64 threads 256 1024
no lane reads 64 / 64 247 / 256 594 / 1024
DPP 64 / 64 247 / 256 735 / 1024
v_readlane 64 / 64 221 / 256 650 / 1024
  • The same-half pair (5 -> 6) reads correctly in every row; the other direction (5 -> 40) is stale at 256 and 1024 threads (1/256 and 42/1024 with no lane reads).
  • Every store landed (unwritten slots 0), so this is read reordering, not a lost store.
  • Emulate does not order a console wave's UAV accesses across its two host halves.
  • The group-shared barrier that DPP/v_readlane force is barrier(1 | 8): it fences LDS, not device memory, so it does not help.

On main the same probe gives the same pattern for the no-lane-read program (w40 -> r5: 64/64, 243/256, 595/1024), so the gap is not Emulate-specific in outcome — only in reach, since Emulate is what translates the wave64 programs on this host.

Running it

PROBE_RUNS=64 cargo test -p victory-shader --lib -- probe_uav_write_then_read_across_halves_emulate -- --ignored --nocapture --test-threads=1

It is #[ignore]d because it demonstrates the bug; it should be un-ignored, or its counts asserted, once a fix lands. A fix for #3766 needs to cover this form: a barrier(2 | ...) at a group-uniform point, or neonbyte1's meeting/console-flow approach.

Credit: the program and instruction words are ColorMeBoom's probe in #3766, ported from neonbyte1's suggest/uav-order-all-forms.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5560309231 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3874). Originally posted by [omarsaifuddin](https://github.com/omarsaifuddin) on 2026-11-30T06:34:28Z. --- Stacked on #189 (base `3e39e34`). The change is the **last commit**; the rest of the diff is #189's branch. ## What An ignored probe for the Emulate form of #3766, ported from ColorMeBoom's [`probe/main-uav-order`](https://github.com/ColorMeBoom/VIctory/tree/probe/main-uav-order) (itself neonbyte1's `uav_write_then_read`). Lane `writer` of each console wave stores 1 + a dword only it loaded to its wave's slot; lane `reader` then loads the slot. On the console the reader sees the store: both lanes are in one wave and the instructions are in program order. The probe runs it under `Wave64Mode::Emulate` for three programs — no lane reads, plus a DPP op, plus a `v_readlane` — on every NVIDIA adapter. The DPP and readlane forms declare `WaveSize(64)` on main and never build on a 32-lane host; under Emulate they translate and run. ## Measured (RTX 3070 Ti, Windows 11, driver 32.0.16.2140, wave 32..=32) Stale reads per reads, `PROBE_RUNS=64`, one group per dispatch. Writer in the high half, reader in the low half: | program | 64 threads | 256 | 1024 | |---|---:|---:|---:| | no lane reads | **64 / 64** | **247 / 256** | **594 / 1024** | | DPP | **64 / 64** | **247 / 256** | **735 / 1024** | | `v_readlane` | **64 / 64** | **221 / 256** | **650 / 1024** | - The same-half pair (5 -> 6) reads correctly in every row; the other direction (5 -> 40) is stale at 256 and 1024 threads (1/256 and 42/1024 with no lane reads). - Every store landed (`unwritten slots 0`), so this is read reordering, not a lost store. - **Emulate does not order a console wave's UAV accesses across its two host halves.** - The group-shared barrier that DPP/`v_readlane` force is `barrier(1 | 8)`: it fences LDS, not device memory, so it does not help. On main the same probe gives the same pattern for the no-lane-read program (w40 -> r5: 64/64, 243/256, 595/1024), so the gap is not Emulate-specific in outcome — only in reach, since Emulate is what translates the wave64 programs on this host. ## Running it ``` PROBE_RUNS=64 cargo test -p victory-shader --lib -- probe_uav_write_then_read_across_halves_emulate -- --ignored --nocapture --test-threads=1 ``` It is `#[ignore]`d because it demonstrates the bug; it should be un-ignored, or its counts asserted, once a fix lands. A fix for #3766 needs to cover this form: a `barrier(2 | ...)` at a group-uniform point, or neonbyte1's meeting/console-flow approach. Credit: the program and instruction words are ColorMeBoom's probe in #3766, ported from neonbyte1's `suggest/uav-order-all-forms`.
Auroraooy commented 2026-11-30 12:38:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Auroraooy on 2026-11-30T12:38:33Z.


Turing data point for this probe, from an RTX 2080 Ti. Same qualitative result as your 3070 Ti, with one difference in how the cross-lane-op forms compare to the no-op form.

Machine: RTX 2080 Ti 11 GB (Turing, SM 6.6 only via Agility SDK 1.620.2, driver 595.79), Core Ultra 7 265K, 96 GB RAM, Windows 10 19045, Rust 1.98.1 MSVC. Head 7e1f056. PROBE_RUNS=64, one group per dispatch, --ignored --test-threads=1.

Getting it to run at all on this box: Host::all_adapters() creates each adapter's device with the inbox D3D12CreateDevice, which reports SM 6.5 on Turing under Win10 and skips every adapter. I routed that call through the Agility factory loader locally (uncommitted, VICTORY_D3D12_DIR → 1.620.2) — the same SM 6.6 gate as #3033. Without it the probe prints skipped: the device supports SM 0x65 only for all three adapters.

Stale reads per reads, writer in the high half, reader in the low half (w40 → r5):

program 64 threads 256 threads 1024 threads
no lane reads 64 / 64 256 / 256 693–768 / 1024
DPP 64 / 64 192 / 256 448 / 1024
v_readlane 64 / 64 192 / 256 448 / 1024

Same-half pair (w5 → r6): 0 stale in all nine rows, both runs. Reverse direction (w5 → r40): 0 / 64, 0 / 256, 64 / 1024 for all three programs. unwritten 0 everywhere, so every store landed — read reordering, not a lost store. Consistent with your conclusion that the group-shared barrier(1 | 8) fences LDS and not device memory.

Two notes that may matter for a fix:

  1. The no-op form is the worst case on Turing, not the cross-lane-op forms: 256/256 at 256 threads and 693–768/1024, versus 192/256 and 448/1024 for DPP and v_readlane. On your 3070 Ti the ordering is the other way round (735 and 650 vs 594 at 1024). Turing at 256 threads is also worse than Ampere there (100% vs 96.5%), so Ampere is not the worst case for the fix to clear.
  2. DXGI exposes this 2080 Ti as two adapters, so the probe ran twice in one process. Every row repeats exactly except the no-op 1024 case (693 vs 768); that is the only run-to-run variance I saw.

Probe log kept locally. Disclosure: run and comment written with GLM (Z.ai) on the machine owner's box, reviewed before posting.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7278722064 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3874#issuecomment-7278722064). Originally posted by [Auroraooy](https://github.com/Auroraooy) on 2026-11-30T12:38:33Z. --- Turing data point for this probe, from an RTX 2080 Ti. Same qualitative result as your 3070 Ti, with one difference in how the cross-lane-op forms compare to the no-op form. **Machine**: RTX 2080 Ti 11 GB (Turing, SM 6.6 only via Agility SDK 1.620.2, driver 595.79), Core Ultra 7 265K, 96 GB RAM, Windows 10 19045, Rust 1.98.1 MSVC. Head `7e1f056`. `PROBE_RUNS=64`, one group per dispatch, `--ignored --test-threads=1`. **Getting it to run at all on this box**: `Host::all_adapters()` creates each adapter's device with the inbox `D3D12CreateDevice`, which reports SM 6.5 on Turing under Win10 and skips every adapter. I routed that call through the Agility factory loader locally (uncommitted, `VICTORY_D3D12_DIR` → 1.620.2) — the same SM 6.6 gate as #3033. Without it the probe prints `skipped: the device supports SM 0x65 only` for all three adapters. Stale reads per reads, writer in the high half, reader in the low half (w40 → r5): | program | 64 threads | 256 threads | 1024 threads | |---|---:|---:|---:| | no lane reads | **64 / 64** | **256 / 256** | **693–768 / 1024** | | DPP | **64 / 64** | **192 / 256** | **448 / 1024** | | `v_readlane` | **64 / 64** | **192 / 256** | **448 / 1024** | Same-half pair (w5 → r6): 0 stale in all nine rows, both runs. Reverse direction (w5 → r40): 0 / 64, 0 / 256, 64 / 1024 for all three programs. `unwritten 0` everywhere, so every store landed — read reordering, not a lost store. Consistent with your conclusion that the group-shared `barrier(1 | 8)` fences LDS and not device memory. Two notes that may matter for a fix: 1. **The no-op form is the worst case on Turing**, not the cross-lane-op forms: 256/256 at 256 threads and 693–768/1024, versus 192/256 and 448/1024 for DPP and `v_readlane`. On your 3070 Ti the ordering is the other way round (735 and 650 vs 594 at 1024). Turing at 256 threads is also worse than Ampere there (100% vs 96.5%), so Ampere is not the worst case for the fix to clear. 2. DXGI exposes this 2080 Ti as two adapters, so the probe ran twice in one process. Every row repeats exactly except the no-op 1024 case (693 vs 768); that is the only run-to-run variance I saw. Probe log kept locally. Disclosure: run and comment written with GLM (Z.ai) on the machine owner's box, reviewed before posting.
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/3874:upstream-pr/3874'
git switch 'upstream-pr/3874'

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/3874'
git switch 'upstream-pr/3874'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3874'
git switch 'upstream-pr/3874'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3874'
git switch 'main'
git merge --squash 'upstream-pr/3874'
git switch 'main'
git merge --ff-only 'upstream-pr/3874'
git switch 'main'
git merge 'upstream-pr/3874'
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
Marvisak/VIctory!3874
No description provided.