Tests: wait for the last deferred CPU write #1337

Closed
ebarr24 wants to merge 1 commit from upstream-pr/1347 into main
ebarr24 commented 2026-11-24 15:04:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ebarr24 on 2026-11-24T15:04:31Z.


The deferred CPU-write test can observe the first dword before the worker stores the second. This is the intermittent failure reported in #546. The test now waits for the final store before reading both results.

What is in it

  • In cpu_writes.rs's test module, wait for the last immediate dword with an acquire load, then check the first. Keep the atomic destination alive if the test times out while the worker is still queued.
  • This keeps the two-dword immediate-write case covered. The runtime and the separate 64-bit write work in #317 are outside this change.

Tested

  • Windows 11 build 26200.9711, Ryzen 7 3700X, RTX 3080 driver 32.0.16.1692, Rust 1.100.0 Windows GNU, DXC 1.9.2609.5, debug build.
  • scripts/test.ps1 with XCL_ADAPTER=3080 and XCL_REQUIRE_GPU=mesh on both base 930e8b4 and head 5ec0cf4. Each run reported 751 passed, 0 failed, and 41 ignored. Two native-wave64 tests returned early and are included in the reported passes.
  • On 5ec0cf4, 32 fresh libtest processes each passed both cpu_writes::tests cases with --test-threads=2.
  • An earlier controlled scheduling check at cb868b2 held the second store briefly. The original polling order observed a zero second word in all three runs. Waiting for the final store passed all three runs with the same delay. The test in this PR uses the regular worker.

Regression run

The diff is confined to one unit test in a runtime file and qualifies for maintainer review under the test-only label.

Not tested

  • Retail smoke or sample inputs, the D3D12 debug layer, native wave64, and other adapter vendors.

AI use

  • Codex (GPT-6, exact variant unavailable) inspected the test, wrote the patch, ran the comparisons, and drafted this description.
<!-- greyfinch-sync:ivall/xcl:issue:5474727970 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1347). Originally posted by [ebarr24](https://github.com/ebarr24) on 2026-11-24T15:04:31Z. --- The deferred CPU-write test can observe the first dword before the worker stores the second. This is the intermittent failure reported in #546. The test now waits for the final store before reading both results. **What is in it** - In `cpu_writes.rs`'s test module, wait for the last immediate dword with an acquire load, then check the first. Keep the atomic destination alive if the test times out while the worker is still queued. - This keeps the two-dword immediate-write case covered. The runtime and the separate 64-bit write work in #317 are outside this change. **Tested** - Windows 11 build 26200.9711, Ryzen 7 3700X, RTX 3080 driver 32.0.16.1692, Rust 1.100.0 Windows GNU, DXC 1.9.2609.5, debug build. - `scripts/test.ps1` with `XCL_ADAPTER=3080` and `XCL_REQUIRE_GPU=mesh` on both base `930e8b4` and head `5ec0cf4`. Each run reported 751 passed, 0 failed, and 41 ignored. Two native-wave64 tests returned early and are included in the reported passes. - On `5ec0cf4`, 32 fresh libtest processes each passed both `cpu_writes::tests` cases with `--test-threads=2`. - An earlier controlled scheduling check at `cb868b2` held the second store briefly. The original polling order observed a zero second word in all three runs. Waiting for the final store passed all three runs with the same delay. The test in this PR uses the regular worker. **Regression run** The diff is confined to one unit test in a runtime file and qualifies for maintainer review under the `test-only` label. **Not tested** - Retail smoke or sample inputs, the D3D12 debug layer, native wave64, and other adapter vendors. **AI use** - Codex (GPT-6, exact variant unavailable) inspected the test, wrote the patch, ran the comparisons, and drafted this description.
futurepro62 commented 2026-11-24 16:07:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T15:17:36Z.


Full-suite run, since this PR has no test report yet. Tested exact head 5ec0cf4 (on its base 930e8b4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 751 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • No new #[test] functions in the diff.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 751 passed, 0 failed, 41 ignored, no skips.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:ivall/xcl:comment:7135780322 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1347#issuecomment-7135780322). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-24T15:17:36Z. --- Full-suite run, since this PR has no test report yet. Tested exact head `5ec0cf4` (on its base `930e8b4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed. - `cargo build --workspace`, then `XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4`: **751 passed, 0 failed, 41 ignored**. SKIPPED (no wave64): `gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu_wave32_program_in_wave64_hardware`. - No new `#[test]` functions in the diff. - Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, `XCL_ADAPTER=radeon`), `cargo test --workspace -- --test-threads=4`: **751 passed, 0 failed, 41 ignored**, no skips. **Not tested** - a release build, a game (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
JoaoPauluu commented 2026-11-24 16:07:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by JoaoPauluu on 2026-11-24T15:33:32Z.


Under Wine on Linux, with an x86_64-pc-windows-gnu build, the changed test fails every time at its new writable check, where main passes.

Tested

  • RTX 3060 12 GB (NVIDIA 620.70.06), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from #257. Release, cross-built for x86_64-pc-windows-gnu (mingw-w64 GCC 16.2.0). 5ec0cf4 as it is and main 930e8b4, no uncommitted changes. The lib test binary runs under Wine.
  • cpu_writes tests (readback_u64_lands_after_the_queue, writes_land_after_the_queue, and title_textures::…gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes, which the filter also matches), 20 runs each, --test-threads=1:
    • main 930e8b4: 20 of 20 ok.
    • this PR: 0 of 20 ok. Every run fails at cpu_writes.rs:185, assertion failed: writable(va, std::mem::size_of_val(&WORDS)).
  • Why, from a temporary local print of VirtualQuery for WORDS, reverted afterwards: state 0x1000 (MEM_COMMIT), protect 0x8 (PAGE_WRITECOPY), alloc_protect 0x80, type 0x1000000 (MEM_IMAGE). The static lands in the image's .bss (0x140a6d000), a page nothing has written yet, and writable() accepts only PAGE_READWRITE / PAGE_EXECUTE_READWRITE.
  • Windows also reports an image's data pages as PAGE_WRITECOPY until they are first written. So this may not be Wine-specific. Whether it shows up there probably depends on whether something else has already written that page (the MSVC and GNU layouts differ). I have not run it on Windows.

Not tested

  • native Windows, the MSVC target; the rest of the suite on this head.

AI use

  • Claude Code (Claude Opus 5.5) built both commits, ran the tests, made and reverted the diagnostic print, and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
<!-- greyfinch-sync:ivall/xcl:comment:7136229844 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1347#issuecomment-7136229844). Originally posted by [JoaoPauluu](https://github.com/JoaoPauluu) on 2026-11-24T15:33:32Z. --- Under Wine on Linux, with an `x86_64-pc-windows-gnu` build, the changed test fails every time at its new `writable` check, where `main` passes. **Tested** - RTX 3060 12 GB (NVIDIA 620.70.06), i5-10400F, 16 GB, CachyOS (kernel 7.3.3), Proton Experimental 11.0-20261112 with the patched vkd3d-proton 3.1 from #257. Release, cross-built for `x86_64-pc-windows-gnu` (mingw-w64 GCC 16.2.0). `5ec0cf4` as it is and `main` `930e8b4`, no uncommitted changes. The lib test binary runs under Wine. - `cpu_writes` tests (`readback_u64_lands_after_the_queue`, `writes_land_after_the_queue`, and `title_textures::…gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes`, which the filter also matches), 20 runs each, `--test-threads=1`: - `main` `930e8b4`: 20 of 20 ok. - this PR: 0 of 20 ok. Every run fails at `cpu_writes.rs:185`, `assertion failed: writable(va, std::mem::size_of_val(&WORDS))`. - Why, from a temporary local print of `VirtualQuery` for `WORDS`, reverted afterwards: `state 0x1000` (`MEM_COMMIT`), `protect 0x8` (`PAGE_WRITECOPY`), `alloc_protect 0x80`, `type 0x1000000` (`MEM_IMAGE`). The static lands in the image's `.bss` (`0x140a6d000`), a page nothing has written yet, and `writable()` accepts only `PAGE_READWRITE` / `PAGE_EXECUTE_READWRITE`. - Windows also reports an image's data pages as `PAGE_WRITECOPY` until they are first written. So this may not be Wine-specific. Whether it shows up there probably depends on whether something else has already written that page (the MSVC and GNU layouts differ). I have not run it on Windows. **Not tested** - native Windows, the MSVC target; the rest of the suite on this head. **AI use** - Claude Code (Claude Opus 5.5) built both commits, ran the tests, made and reverted the diagnostic print, and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.
DavidM1911 commented 2026-11-24 17:06:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T16:17:55Z.


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

  • cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored. (One run showed a single flaky failure / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7137434855 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1347#issuecomment-7137434855). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T16:17:55Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~21 ignored. (One run showed a single flaky failure / 0xc0000005 abort under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
Toons29 commented 2026-11-25 04:10:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T03:25:14Z.


Regression run of 5ec0cf4a on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 5ec0cf4a9a690d46f4097c7e54cb13a86e74049a
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1629 (PresentX 1629)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14815 MB

Against the limits in CONTRIBUTING.md: 101 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7151897438 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1347#issuecomment-7151897438). Originally posted by [Toons29](https://github.com/Toons29) on 2026-11-25T03:25:14Z. --- Regression run of `5ec0cf4a` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `4178e888`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: 5ec0cf4a9a690d46f4097c7e54cb13a86e74049a gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1629 (PresentX 1629) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14815 MB ``` Against the limits in CONTRIBUTING.md: 101 % of `main`'s frames, 100 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; I checked the blocks before posting.
sage-sage commented 2026-11-26 17:53:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by sage-sage on 2026-11-26T17:53:36Z.


Test report: the race this PR fixes is real on current main, but the new test fails when it runs alone. Merged onto current main b49be18 (clean merge, 083a1b54 locally).

Tested

  • RTX 4080 SUPER (driver 621.40), Ryzen 5 7600X, Windows 11 26H2 build 26300.10075, rustc 1.100.0 MSVC, debug build
  • cargo test --workspace -- --test-threads=4: 1435 passed, 0 failed, 47 ignored, 29 SKIPPED lines (the same as main here)
  • main's version of the test failed once in about 900 whole-lib runs at --test-threads=12 (left: [7, 9], right: [7, 9]: the second dword landed between the compare and the print). With a 20 ms sleep put between the worker's two stores (local only), main's test fails every time (left: [7, 0]), as the description says.
  • cargo test -p xcl --lib writes_land_after_the_queue (the test alone, or cpu_writes alone): fails 4 of 4 runs at assert!(writable(va, std::mem::size_of_val(&WORDS))). WORDS is a static in the image's .data, and until something writes to its page, VirtualQuery reports PAGE_WRITECOPY (0x8), which writable does not accept. In a local probe the page read 0x8 before a store to WORDS[0] and 0x4 after, and with that store the test passed. In the whole suite it passes because another static on that page has been written first.

A destination that stays alive without being in .data (for example Box::leak(Box::new([const { AtomicU32::new(0) }; 2]))) or a store to WORDS before the check would avoid it; I have not tried either beyond the probe above.

Not tested

  • AMD / Intel; no game.

Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7199814662 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1347#issuecomment-7199814662). Originally posted by [sage-sage](https://github.com/sage-sage) on 2026-11-26T17:53:36Z. --- **Test report: the race this PR fixes is real on current `main`, but the new test fails when it runs alone.** Merged onto current `main` `b49be18` (clean merge, `083a1b54` locally). **Tested** - RTX 4080 SUPER (driver 621.40), Ryzen 5 7600X, Windows 11 26H2 build 26300.10075, rustc 1.100.0 MSVC, debug build - `cargo test --workspace -- --test-threads=4`: 1435 passed, 0 failed, 47 ignored, 29 SKIPPED lines (the same as `main` here) - `main`'s version of the test failed once in about 900 whole-lib runs at `--test-threads=12` (`left: [7, 9]`, `right: [7, 9]`: the second dword landed between the compare and the print). With a 20 ms sleep put between the worker's two stores (local only), `main`'s test fails every time (`left: [7, 0]`), as the description says. - **`cargo test -p xcl --lib writes_land_after_the_queue` (the test alone, or `cpu_writes` alone): fails 4 of 4 runs** at `assert!(writable(va, std::mem::size_of_val(&WORDS)))`. `WORDS` is a static in the image's `.data`, and until something writes to its page, `VirtualQuery` reports `PAGE_WRITECOPY` (`0x8`), which `writable` does not accept. In a local probe the page read `0x8` before a store to `WORDS[0]` and `0x4` after, and with that store the test passed. In the whole suite it passes because another static on that page has been written first. A destination that stays alive without being in `.data` (for example `Box::leak(Box::new([const { AtomicU32::new(0) }; 2]))`) or a store to `WORDS` before the check would avoid it; I have not tried either beyond the probe above. **Not tested** - AMD / Intel; no game. Claude Code (Claude Opus 5.5) ran the tests and wrote this report.
Foniass commented 2026-12-01 05:30:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:30:05Z.


Triage (#1607) – head 5ec0cf4

The race in cpu_writes::tests::writes_land_after_the_queue (waiting for word 0 then checking word 1) is gone on main: commit 342ba2d ("D3D12.X: order waits after deferred CPU writes") changed the test to after_with_completion(...) and completion.wait() before comparing both words.
Recommendation: close (superseded by main commit 342ba2d).

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:7301835940 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1347#issuecomment-7301835940). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:30:05Z. --- **Triage (#1607)** – head 5ec0cf4 The race in `cpu_writes::tests::writes_land_after_the_queue` (waiting for word 0 then checking word 1) is gone on main: commit 342ba2d ("D3D12.X: order waits after deferred CPU writes") changed the test to `after_with_completion(...)` and `completion.wait()` before comparing both words. Recommendation: close (superseded by main commit 342ba2d). AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
throny commented 2026-12-01 12:44:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:44:31Z.


Closing as superseded: this change is already on main (342ba2dd). main cpu_writes.rs writes_land_after_the_queue waits on after_with_completion(...).wait() so the polling race is gone; commit 342ba2d exists

Two independent checks found this: Foniass's close list on #1607 and ours against current main. If something here is still missing on main, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

<!-- greyfinch-sync:ivall/xcl:comment:7311579096 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1347#issuecomment-7311579096). Originally posted by [throny](https://github.com/throny) on 2026-12-01T12:44:31Z. --- Closing as superseded: this change is already on `main` (342ba2dd). main cpu_writes.rs writes_land_after_the_queue waits on after_with_completion(...).wait() so the polling race is gone; commit 342ba2d exists Two independent checks found this: Foniass's close list on #1607 and ours against current `main`. If something here is still missing on `main`, say so and reopen it, or ask and I will. AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

Pull request closed

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!1337
No description provided.