D3D12.X: publish CPU writes only after GPU completion #3104
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3104"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by Prime1997 on 2026-11-28T07:01:08Z.
CPU-side bottom-of-pipe writes wait for confirmed producer completion on
nvidia-dev; the former ten-second fallback could publish a GPU readback before its copy ran. This update also identifies stalled producers in the existing warnings, so waits from different queues and submissions can be distinguished.Rebased onto main (2026-11-28).
nvidia-devwas merged intomainby #3203, so this PR now targetsmainand its branch was rebased ontomain765b2c5bfff6754e8c9886a73e188a86aca3c64c: heade89fbfe27682b44fd5801229b42d97c270ab7060(wasace812c15a246a51f196f3a69907d7fbee529d8a).mainhad added completion receipts (after_with_completion),forget_queueandnative_queue_signaltocpu_writes.rs, so both commits are ported by hand. This PR's worker (poll, hold, never publish on a timeout) now also sendsmain's receipt once a submission's stores are made; a removed producer drops the receipt's sender, so a waiter returns instead of blocking; the producer mark goes throughnative_queue_signal.main's receipt-based versions ofwrites_land_after_the_queueandreadback_u64_lands_after_the_queueare kept. That port needs a review. On the rebased head, on the same RTX 3060 Ti PC, debug profile:cargo check -p xcl --all-targetsexited 0, andcargo test -p xcl --lib -- --test-threads=4 a_ready_suffix_never_overtakes_an_unconfirmed_cpu_write device_removal_never_publishes_or_releases_cpu_writes failed_producer_signal_retains_inflight_cpu_write_resources failed_worker_send_retains_inflight_cpu_write_resources gpu_readback_is_not_published_after_an_uncompleted_ten_second_wait pending_cpu_writes_preserve_suffix_without_blocking_other_fences pending_cpu_writes_retain_resources_until_confirmed_completion writes_land_after_the_queue cpu_write completiongave 44 passed, 0 failed, 0 ignored, no SKIPPED. The whole suite and the paired title runs have not been rerun on this head; every other result below is from the earlier head. The rebase and its conflict resolution were done with Claude Code.What is in it
ace812c15a246a51f196f3a69907d7fbee529d8a: log the existing queue number, owned fence identity and accepted Signal mark. Polling, warning frequency, publication and resource lifetime are unchanged.Tested
ace812c15a246a51f196f3a69907d7fbee529d8a.d50f6656fb50b7927a2279d4c78b24222be3da54:cargo build --locked --release -p xcl --target-dir <isolated-target>exited 0 in 228.576s, with 9 warnings. This includes the change but is not a standalone build/test of this PR head.54225f58with only the new GPU regression: 0 passed, 1 failed, 0 ignored, 1,806 filtered, no SKIPPED messages; it published zero while the producer was gated. Prior repair head34e64a69261d9304f30a57886d0feda5ebd6daa6: 12 passed, 0 failed, 0 ignored, 1,801 filtered, no SKIPPED messages.cargo test --locked -p xcl --lib --target-dir <isolated-target> --no-run, then thehle::d3d12x::cpu_writes::tests::filter with--nocapture --test-threads=1. The before-fix run selectedgpu_readback_is_not_published_after_an_uncompleted_ten_second_waitwith--exact. Recorded patch hashes tie the prior source to its test receipt; the interrupted initial build is not counted.2d90bc180d718afc796d8ae490f6ecbe9dc5823band prior combined candidate5d0833553c68d2afa327c913cd9a22f17ec6f45ewere listed as pending in the previous description. Those pending entries are not converted into passes here.Regression run
Pending paired clean-head main/PR title runs. No smoke result is claimed. Draft while required validation remains incomplete.
Not tested
AI use
Codex (GPT-6) reviewed the source and related PRs, implemented and tested the historical repair, added the diagnostics and prepared this update. Historical tests are explicitly separated from pending current-head validation.
Optional temporary Discord for coordinating contributor work, testing and comparing results: https://discord.gg/6B4TykyC4W
Imported from ivall/xcl. Originally posted by pickles976 on 2026-11-28T07:53:27Z.
Focused CPU-only Wine verification of exact head
2d90bc180d718afc796d8ae490f6ecbe9dc5823b(nvidia-dev base54225f5884a94cd23b7aab3f703a7c975070aa77), with no source edits.Tested: six existing ownership/completion-policy fixtures, 6 passed / 0 failed / 0 ignored, fresh
Compiling xcl .../xcl-pr3104/crates/xclprovenance, build34.17s / tests0.00s / guarded command34.88s. Filters:pending_cpu_writes,a_ready_suffix_never_overtakes_an_unconfirmed_cpu_write,device_removal_never_publishes_or_releases_cpu_writes,failed_producer_signal_retains_inflight_cpu_write_resources,failed_worker_send_retains_inflight_cpu_write_resources. Command prefix:cargo test --locked --target x86_64-pc-windows-msvc -p xcl --lib --, followed by those filters and--nocapture --test-threads=1.These exercise generic pending queues, synthetic completion values and drop/publication ownership. They confirm no early publication/release in those models, per-fence independence, ordered suffixes and failure-path retention. They do not invoke the real queue Signal/GetCompletedValue worker or execute GPU commands.
Not tested: the eleven-second real GPU regression, GPU destruction/device-removal behavior, native Windows, full suite, title startup, RAM/frame time, or matched parent. Our Linux/Wine title previously published two writes after a ten-second
fence0/wanted1fallback and later reached its Game-Init watchdog. Removing that unsafe publication is relevant correctness work; it does not make the stuck producer complete. GPU trials are currently parked after a separately captured driver timeout. Retaining unconfirmed resources is safer than recycling them but is not a memory-saving claim.Additional caller-level coverage suggestion: the new lock orders Signal plus enqueue. The outer
real.rs:9324–9333still performs native Execute, several accounting/readback steps, thencpu_writes_after;execute_with_waits_on's no-wait path calls this without a queue-wide lock. [INFERENCE] concurrent submitters could execute A then B but enqueue B before A if A pauses after native Execute. The passing queue-model tests do not cover that boundary. A deterministic two-submitter fixture pausing at that point would establish whether CPU write order tracks native submission order; this is not a reproduced GPU failure or a demonstrated new regression. The kickoff path atlist_x.rs:3930–3946has the same split boundary.Environment: i7-13620H /16GiB, Linux6.17, Wine11, Rust1.98.1. RTX4060Laptop8GiB present but not initialized by these tests; idle sampled GPU133MiB, minimum availableRAM8812.6MiB/disk14.603GiB. External9GiB/512MiB scope and global safety guards unchanged. Evidence
.compat-runtime/logs/verify-xcl3104-cpu-completion-20261128T074934Z/contains provenance, log/results and resource samples. No assets/dumps published.AI-assisted source review, execution and report: omp / OpenAI GPT-6 Astra.
28 Nov follow-up: real CPU publication worker reproduces the submit/enqueue gap
Same production head
2d90bc180d718afc796d8ae490f6ecbe9dc5823b; only the local ignored regression below was added. Fresh intended-worktree compilation 33.68 s. Windows-MSVC/Wine 11 CPU/mock-COM test: 0 passed, 1 failed, 0.06 s, with:This is more than the earlier generic queue model: it runs
list_x::execute_with_waits_on, productioncpu_writes::after, Signal/job registration, the actual channel worker,real::fence_completed,publish_ready, and production atomic writes into committed PAGE_READWRITE memory. The queue/fence COM objects and completion are mocks. It does not invoke the completeq_execute_command_listswrapper or submit GPU commands.Deterministic schedule: A's mock native Execute returns, then A pauses immediately before
after; B executes and registers its writes; the actual worker publishes B's0x22; A resumes/registers and the worker overwrites it with A's older0x11. Both mocked fences complete, with no timeout or device-removal path. The production ordinary-submit and Kickoff paths separate native Execute fromafterthis way; the outerPcCallguard records timing, not a held submission mutex. The PR's signal/enqueue lock preserves registration order, but registration order can differ from native submission order.Suggested owner correction: establish one per-queue ordering boundary covering native submission and its completion/job registration across all submit paths. Prepare bookkeeping before that boundary where possible; do not place CPU/GPU waits under the global FENCES lock. Keep the existing pending/removed/failed-signal lifetime protections. Retain an actual-worker concurrency regression, then validate real controlled pending-fence execution when the hardware test environment is cleared.
No matched parent, title-crash attribution, real GPU ordering certification, or RAM/FPS claim. The first fixture attempt stopped at its static destination's writable-memory precondition; the next had a fixture index type error. Neither was a production result. The final committed-memory probe above reached the asserted consumer-visible overwrite. Its registration is removed and memory is released after both publications; a deadline failure retains an outstanding destination rather than creating a use-after-free.
Command:
Evidence:
verify-xcl3104-submit-order-worker-20261128T081347Z/. No adapter initialized; sampled GPU stayed at idle 133 MiB. Available RAM minimum 8,881 MiB; all external limits unchanged.Complete local regression (inside cpu_writes.rs tests module)
Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-28T08:26:10Z.
Ran the CPU-write completion tests at
2d90bc18on an NVIDIA Blackwell desktop part:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
All twelve tests pass at the updated head, including the gated eight-byte GPU-copy regression. The PR description says this exact head had not been individually retested and that the combined validation is pending; this run covers the focused test group only. The thread has an RTX 3060 Ti run and a CPU-only Wine check, but no 5070 Ti.
Not tested: the full workspace suite, a paired smoke run, a retail title, release profile, AMD and Intel GPUs, native wave64 hosts, Wine, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-28T12:56:05Z.
Re-ran the CPU-write completion tests at
ace812c1after the head moved from2d90bc18; this is a new response in the same thread, not an edit of my earlier report:Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.
All 12 tests pass at the new head, which adds diagnostics for stalled CPU-write producers. Same count as at
2d90bc18. The thread has an RTX 3060 Ti run and a CPU-only Wine check, but no desktop 5070 Ti.Not tested: a retail title, a paired smoke run, the full workspace suite, release profile, AMD and Intel GPUs, native wave64 hosts, Wine, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T00:05:22Z.
I tested the rebased single-worker scheduler at
e89fbfe27682b44fd5801229b42d97c270ab7060on an RTX 5070 (616.92). Independent publication and same-queue FIFO passed. Two GPU-ordered queues writing the same ordinary CPU word produced a stale final value in 5/5 rounds.The worker can retire up to 64 jobs for one ready fence per sweep. A later queue can already be GPU-ready while an earlier queue still has CPU stores left to publish. Both local completion checks can therefore be true even when their final overlapping stores land in the opposite order. This covers an ordinary Immediate destination, outside the registered monotonic sync-cell policy in #2439. It also complements the independent-queue delay reported on #3035.
The test invoked the production scheduler with native queue signals/waits and bounded receipt observations. It measures completion order and final CPU values; guest command recording and retail behavior were outside the fixture. I have not proposed another scheduler PR.
AI use: OpenAI Codex built the test-only fixture, ran all five rounds and drafted this report.
Reverse host-order control, same head and adapter: B submitted its wait and overlapping store before A submitted any of its 256 jobs or its signal. GPU order was still A then B. In 5/5 additional rounds the disjoint queue progressed, the A-only FIFO control finished at 256, and the shared word also ended at 256 instead of 0xbbccdd11. Retiring overlapping stores in host arrival order would therefore also give the wrong answer in this case. The worker needs the queue dependency through CPU publication, including a wait whose signal is submitted later.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-29T04:21:25Z.
One publication path remains outside the current #3104 tests at head
e89fbfe: an ordinary deferred CPU write followed by a title queue Signal on the same queue. Both ordinary Signal and SignalX forward the native Signal immediately, while the worker's CPU stores can land later. A title waiting for that fence on the CPU could therefore observe completion and read the old word. The completed-value mirror's contract says the writes have landed before its value is published. The existing two-queue report tests a different ordering. This gap also exists on current main; it is not a regression introduced by this PR.For a bounded correction, consider a per-queue publication fence: after the producer's GPU mark is queued, put a native GPU Wait for the worker's publication value before forwarding a title Signal. The worker advances that value only after its stores. The queue Wait returns to the submitting CPU immediately, so a title can still issue a host wait without deadlocking the submitter. A failed producer mark, failed wait insertion or removal must not publish the title signal. The separate internal Wait64 signal route also needs a check; a failure/cycle-break signal cannot certify CPU publication.
A deterministic regression could pause the worker immediately before an ordinary CPU store, issue the title Signal, and drive the queue through its earlier GPU work. Until the worker is released, require the title fence's completed value and event to stay below the signaled value; afterward require the event, value and word to agree. This is a source-traced ordering concern, not a reproduced test failure or an exercised fix. AI use: Codex (GPT-6.2 Sol) checked the paths and wrote this report; Codex (GPT-6.2 Astra) independently traced the publication ordering.
Imported from ivall/xcl. Originally posted by vasanex on 2026-11-29T04:23:21Z.
How this was run: the suite ran once on the 11 of your PRs that build on this base, merged together (#3047 #3048 #3049 #3091 #3092 #3103 #3104 #3105 #3107 #3123 #3125; a local tree, only #3125 needed a resolution in README and the
sparse.rstest module); the base alone gave 2608 passed, 0 failed, 49 ignored with the same 27SKIPPEDlines (21 no wave64, 3 refused per-lane f16/f32 forms, 2 heap windows opt-in, 1 driver cache needs Developer Mode). This PR alone was merged onto the base, built (cargo build --workspace, then release), its modules' lib tests run (debug), and smoke-run once for 60 s (scripts/smoke.ps1, retail title, front end,XCL_PREPARE=0). The smoke numbers are for my local merged tree, not a clean-head block for the description. Load runs: 150 s, the save loaded with A presses,XCL_PREPARE=0, after one warm-up, one run per arm; on this 10 GB card main is over the video memory budget while loading, and presents stop after 94-125 s in every arm.AI use: Claude Code (Claude Opus 5.5 and Claude Fable 5.2) ran the builds, tests and title runs, reviewed the diff and wrote this; the code points cited were checked against the merged tree.
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-29T22:44:21Z.
Review: COMMENTED
Critical review of current head
e89fbfe2. The old ten-second timeout could publish an unfinished GPU readback; the new worker waits for a confirmed fence value and keeps independent producer queues progressing. I found no source-level blocker in the ordering policy. Please verify the operational failure path: after a failedSignalor device removal, the retained job and its readback buffer must not be published, and any completion receipt must terminate rather than leave a title thread waiting indefinitely. The new synthetic tests cover much of this; a device-backed failure test would close the gap. No local Windows run.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:41:32Z.
Review (head
e89fbfe2, diff read, not a merge-check; draft withPR descriptionand CI red, so not built or run):completion.wait()(list_x.rs~3725, ~5418) is a barerecv()(cpu_writes.rs~306), and the worker neither sends nor drops it while the producer is pending; main's 10 s fallback used to bound this. If a split chunk is held on the GPU by work the same title thread submits only after ExecuteCommandLists returns, the title now hangs for good with nostop_for_unresolved_waitreport, where main stalls 10 s and carries on. Bound it, or route it into the existing stop path.recv_timeout(2ms), ~125), so up to ~2 ms more before each write lands, ~500 wake-ups/s while writes are pending, and it keeps polling after device removal. Not measured.queue_idnow runs on every submission (a mutex and a lookup in a list that only grows; the id is stale when a queue address is reused); one warning per held submission can flood the log; the new GPU test adds 11 s to every suite run and its "no hardware device" skip still runs on WARP.late_release::tests::a_pipeline_xcl_lets_go_is_released_by_the_threadfailed (late_release.rs:490) and the test process then crashed (0xc0000005); I didn't find that failure in other recent runs, so worth checking whether the new 11 s gated-queue test is involved. No smoke blocks; AI use leaves out Claude Code (and its model) for the rebase; Tested names the old headace812c.Fine: sending under the signal lock keeps writes from two submitters in order, no stale event can publish early, removed producers release their waiters, resources stay held when a signal or send fails, each queue keeps its order without waiting on others, and the new GPU test fails on main.
AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T17:06:25Z.
Test report (not a merge-check: draft,
PR descriptionred)base:
b2b1f109d2head:
e89fbfe276merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2909 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: not repeated here; my review of this same head is at https://github.com/xcl-dev/xcl/pull/3104#issuecomment-7302035791, and its findings stand. This run adds what reading couldn't: whether the change merges, builds and passes the whole suite on current main.
performance: no smoke run.
assessment: merges, builds and passes the whole suite on current main (0 failed, its new tests included); the findings in my review stand (it also overlaps #3035 on the same CPU-write worker loop)
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.