Repository navigation
D3D12.X: serialize real::init against concurrent device creation - #1
Draft
RandomGithub12309 wants to merge 1 commit into
Draft
RandomGithub12309 wants to merge 1 commit into
RandomGithub12309 wants to merge 1 commit into
Conversation
real::init previously checked device_raw().is_null() without a lock, allowing concurrent threads (such as parallel GPU tests) to enter device creation and open_uma/sparse::init simultaneously before DEVICE was published. Add a double-checked static Mutex guard around initialization in real::init() and a 4-thread concurrent_init_returns_consistent_adapter test. Assisted-by: Antigravity (Gemini 4 Neon)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Serialize
real::init()with double-checked locking so concurrent threads callingreal::init()cannot race pastdevice_raw().is_null(), create competing D3D12 devices, and re-runopen_uma/sparse::initsimultaneously.(Parked as a draft PR on
RandomGithub12309/xclwhile#667and#674are in review upstream; rebase ontoivall/xcl:mainand run the full workspace test suite +scripts/smoke.ps1before opening upstream.)What is in it
crates/xcl/src/hle/d3d12x/real.rs: add astatic INIT: Mutex<()>guard insidereal::init()and re-checkdevice_raw().is_null()under the lock; add unit testhle::d3d12x::real::init_tests::concurrent_init_returns_consistent_adapterspawning 4 synchronized threads callinginit().Tested
32.0.16.2114), Intel Core Ultra 7 255HX (20 cores), Windows 11 Build 26300,rustc 1.100.0 (0ef1bc386 2026-11-09)stable-x86_64-pc-windows-msvc(debug).cargo test -p xcl --lib hle::d3d12x::real::init_tests -- --nocapture:1 passed, 0 failed, 0 ignored(0 skipped;UMA import checkran once across all 4 threads).Regression run
mainbaselinedd2ae9aalready captured on this machine; runcargo test --workspace -- --test-threads=4andscripts/smoke.ps1before submitting upstream toivall/xcl).Not tested
cargo test --workspaceandscripts/smoke.ps1on this standalone branch (deferred until ready to open upstream), AMD/Intel GPUs, Wine/Linux.AI use