Skip to content

Tests: wait for the last deferred CPU write - #1347

Open
ebarr24 wants to merge 1 commit into
xcl-dev:mainfrom
ebarr24:tests/cpu-writes-last-dword
Open

ebarr24 wants to merge 1 commit into
xcl-dev:mainfrom
ebarr24:tests/cpu-writes-last-dword

Conversation

@ebarr24

@ebarr24 ebarr24 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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 D3D12.X: honour OS QPC timestamp flags and atomic 64-bit CPU writes (#103) #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.

The worker publishes immediate dwords one at a time. Wait for the last release store before reading the first word, and keep the atomic destination alive if the test times out.

Assisted-by: Codex (GPT-6)
@futurepro62

futurepro62 commented Nov 24, 2026 •

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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 Linux: docs/linux.md, scripts/linux and Wine start-up checks for vkd3d-proton and DXVK (#154, #241) #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

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, ~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

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants