Repository navigation
Conversation
Serialize native CPU Signal calls and cached completion publication per fence, and add a barrier-controlled two-caller regression. Register the WARP fixture in PR smoke tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…w-58fd6315 # Conflicts: # CMakePresets.json
KelboLive
left a comment
There was a problem hiding this comment.
LGTM — correct fix for CPU fence signal rewinds.
Patches fence_signal to read GetCompletedValue() after a successful desktop Signal and publish the actual desktop observation atomically via InterlockedExchange64 on the fence_lock, instead of blindly setting the cached word to the requested value. fence_completed_value also acquires the fence_lock for a consistent read. Concurrent signal test (128 pairs) validates the fix.
The documented queued-rewind limitation is useful context and correctly excluded from passing tests.
Ready to land.
KelboLive
left a comment
There was a problem hiding this comment.
LGTM — correct fix for CPU fence signal rewinds.
Patches fence_signal to read GetCompletedValue() after a successful desktop Signal and publish the actual desktop observation atomically via InterlockedExchange64 on the fence_lock, instead of blindly setting the cached word to the requested value. fence_completed_value also acquires the fence_lock for a consistent read. Concurrent signal test (128 pairs) validates the fix.
The documented queued-rewind limitation is useful context and correctly excluded from passing tests.
Ready to land.
Leyukaka
left a comment
There was a problem hiding this comment.
Diff review of ac685174, by reading only; nothing built or run. Against the two requests in the #3279 review: the serialization is done, and the two-caller test is not yet a controlled regression of the interleaving described there.
Lock (src/startup_stubs/d3d12_xs_device.cpp):
- After
wrap(), both writers ofcompletedholdfence_lockexclusively:fence_reached(:234-241) andfence_signal(:4682-4688).fence_completed_valuereads under the shared lock (:4694-4696).wrap()memsets the wrapper, so the lock starts zeroed, which isSRWLOCK_INIT. - Under
fence_lock,fence_signalonly calls the desktopSignalandGetCompletedValue, andfence_reachedcalls nothing.fence_signalno longer callsfence_reached, so the SRW lock is not re-entered. Thefence_reachedcall sites (:1978, :1987, :4758) take no other lock around the call, and the DirectStorage worker releases its queue mutex beforerun_entryreachessignal_fence(xcrdapi.cpp:1586). I found no lock-order problem.
Test (tests/startup_fence_values.cpp:107-131):
- The barrier only lines up the two thread starts. Nothing holds caller A between the desktop
Signal/GetCompletedValueand itsInterlockedExchange64. - Without the lock (the
a5a92ea1code), a mismatch needs A's exchange to land after B's whole Signal, read and publish. A's window is a few instructions, so the loop would likely pass there too. - The loop should fail on main's atomic maximum: values 1 and 2 alternate, so once the word is 2, any pair that ends with native 1 mismatches.
- A controlled version needs a test-only hook that pauses
fence_signalafter the desktop calls, in the style of the existingx2w_d3d12_fail_wrapsexport. The test can then run A (value 1) to the pause, start B (value 2), give B a bounded time, release A, join both, and check word == method == native == 2. Without the lock B finishes during the pause and A then publishes 1 over it; with the lock B waits for A, so the test must not wait for B before releasing A.
Other:
CMakePresets.json: onlystartup_fence_valuesadded to theprbuild targets andstartup_fence_values_warpto theprtest filter.- No test reaches the failed-
Signalside of theSUCCEEDED(hr)check; the doc says a failed desktop signal was not induced. git merge-tree --write-tree origin/main ac685174on212d4b5f: clean, rc 0.
lukaslw-lab
left a comment
There was a problem hiding this comment.
Reviewed ac685174 by reading the diff; not built or run. Adding two points to the review above.
- No longer merges into current main:
git merge-tree --write-treeagainst46226004conflicts inCMakePresets.json(theprbuild targets and test filter);d3d12_xs_device.cppmerges cleanly. GitHub shows the PR as not mergeable. fence_completed_value(d3d12_xs_device.cpp:4692-4697) takesfence_lockshared only to readcompleted. That word is written only byInterlockedExchange64/InterlockedCompareExchange64, an aligned 64-bit read is atomic on x64, and the title reads the same word without the lock through the slot 12 address. The lock does not change which values slot 8 can return; a plain read (or a comment on why the lock is needed) would keep slot 8 lock-free.
|
I reviewed Please rebase. MUST
SHOULD NIT AI-assisted. |
Change
Replacement for #3279: serialize each fence's native CPU
Signal, desktop completion observation, and cached-word publication with a per-fence SRW lock. The source-built fixture covers the 9 → 2 → 0 → 7 rewind sequence and 128 barrier-started two-caller signal pairs. The PR smoke-test filter includesstartup_fence_values_warp. Current upstreammainat24fcd0b5742abb2fcaba8066093d70829df956a3was merged with normal history (merge commit95613c4f5); the original PR remains open and unchanged.Verification
& .\tools\dev.ps1; cmake --preset dev; cmake --build --preset dev --target startup_fence_values startup_queue_wait --parallel 4; ctest --preset dev --no-tests=error -V -R '^startup_(fence_values|queue_wait)_warp$'— passed 2/2 on Microsoft Basic Render Driver (WARP), D3D12 debug layer enabled.ctest --preset pr --no-tests=error -N -R '^startup_fence_values_warp$'— selected the fence WARP test (1 test).python -B tests/docs_links_check.py— passed; checked 156 Markdown files and 674 links.The full PR test suite and a post-merge hardware run were not run. CMake reported that Python-driven CTest registrations were disabled because
out/pe-env/Scripts/python.exeis absent.Evidence and follow-up
The fixture is source-built and compares the shim's completion method and address with its desktop fence. See the experiment note. It does not establish full-title startup. Queued rewinds and mixed CPU/queue producer ordering remain separate, unresolved behavior; no claim is made for those cases.
Checklist
AI-assisted.