Repository navigation
Shader tests: run the VALU GPU tests one at a time (cargo test hangs now and then) - #433
Conversation
`cargo test` now and then never finishes: the seven emit::valu_tests that run on the hardware adapter and on WARP start together on the test threads, none of their dispatches completes, and the test binary keeps one core busy until it is killed (the waits spin on the fence). Any other GPU test running at that moment is stuck with them. On an RTX 5070 with a Radeon iGPU, `valu_tests` alone in a loop on main d2a4bae: 3 of 30 runs hang. With `run_cases` behind a process-wide lock: 0 of 60, and the seven tests take under 7 s. The lock is poison-tolerant, so one failing test does not fail the rest. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Verified
The change itself is test-only and does not affect the library suite. A machine with an SM 6.6 device should confirm that the previously intermittent hang is gone. |
|
Tested Environment: Windows 11 Pro build 26300, AMD Ryzen 7 5700X, 16 GB, NVIDIA GeForce RTX 3060 12 GB (driver 610.88), no iGPU (one hardware adapter), Rust 1.98.1 Loop, same method as the description (test binary with the
So I could not reproduce the hang on Cost: the seven tests one at a time take 5.5–6.4 s against 2.45–2.70 s in parallel (5 runs each), which matches "under 7 s". Other checks on this PR:
Not tested: a machine with two adapters; no game data used. AI-assisted (Claude Code) ran the checks and drafted this comment. |
|
Thank you, that is the check this needed, and it limits what I can claim: on a machine with one hardware adapter the hang does not happen on Your point about the second adapter made me split the test by backend here (RTX 5070 plus a Radeon iGPU; the seven tests use only the default adapter, the RTX 5070, and WARP). A local switch, not in the PR, makes
So on this machine:
I have put your result and this table into the description. No game data used. AI-assisted. |
|
Ran your split here (RTX 3060, single adapter, same environment as above), with the same kind of local switch in
So on this machine:
No game data used. AI-assisted (Claude Code). |
|
Thank you for running the split. That gives the PR one thing it can claim on more than my machine, and one it cannot:
I have added your table to the description and said so there. No game data used. AI-assisted. |
mercuryVM
left a comment
There was a problem hiding this comment.
Tested 1106f43 on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (264 passed, 0 failed).
Data point for the "not universal" section. Earlier today, a full cargo test --workspace on our fork's main, without this PR, hung in victory-shader --lib. Six emit::valu_tests (bfe_signed_and_unsigned_match_rdna2, both v_fract_*_never_returns_one, v_med3_f32_matches_rdna2_with_nan, both v_sin_and_v_cos_*) sat at "running for over 60 seconds" for more than 10 minutes until I killed the process. The same crate with --test-threads=1 passed in about 5 s. So the overlap hang also shows up on an RTX 5070 machine, not only on one with a second adapter.
That said, it does not reproduce reliably here:
- Without this PR, 5 standalone parallel runs of
cargo test -p victory-shader --liball passed in about 2.5 s. - With it, 5 runs all passed in about 5 s. The extra time is these seven tests now running one after another.
This PR alone did not change any result I measured, but it removes the overlap that the hang I saw needed. The change is test-only and the lock tolerates poisoning, so it is safe to take.
AI-assisted (Claude Code).
…one at a time (cargo test hangs now and then) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@mercuryVM thank you for the review, and for the data point: six of these tests stuck for more than 10 minutes in a full AI-assisted (Claude Code). |
|
A second machine with your layout (one NVIDIA card plus a Radeon iGPU): the hang reproduces on Machine. RTX 5080 (driver 610.88), the default adapter, plus the AMD Radeon iGPU of a Ryzen 7 9800X3D (driver 32.0.21042.62). Windows 11 Pro 26200, Rust 1.98.1, debug. Whole
Your split (
That is the case you had seen only on your machine (1 of 40 there, 0 of 40 on fromthemoonx's single-adapter RTX 3060). Here it is 6 of 40, with the seven tests on the RTX 5080 alone, and none with this PR. Both machines with a hang have a Radeon iGPU next to the NVIDIA card, which fits your guess about the second adapter. I can't take the iGPU out to test that directly. So on a second machine: the WARP-only crashes are #181's (fixed for every WARP user by #244), and the hang does not need WARP. #244 alone still hung 3 times in 60 here; this PR alone, and the two together, never did. AI use: Claude Code (Claude Opus 5.5) ran the loops and drafted this comment; the counts come from the runs above. |
|
@Lyrnc thank you, that is the confirmation this PR was missing: the hang on the hardware adapter alone, on a second machine, with a before-and-after count (6 of 40 against 0 of 40, and 8 of 60 against 0 of 60 for the whole lib suite). Your rate on The description now cites your numbers and says the hang has been seen on three machines, repeatedly on the two that have a Radeon iGPU next to the NVIDIA card. I have left the second-adapter idea as untested, since neither of us can remove the iGPU; if anyone has a discrete NVIDIA card in a system with the iGPU disabled in firmware, the 40-run Nothing changed in the code; head is still |
|
Another data point: RTX 5060 Ti, the only adapter in the machine (no iGPU), Windows 11, NVIDIA driver 32.0.16.1088, debug build of Test binary run in a loop, 45–60 s limit per run (a good run takes about 3 s):
The #244 runs hung more often while other builds and tests were loading the CPU, so load seems to make it likelier. Where it stops. In a local build I wrote a line to a file before and after each step of The fence polling isn't the cause. I replaced both So running the seven tests one at a time is the fix here too. The runtime in |
|
@lameloball2813-ui thank you, this settles two things the description had open, and both are now in it with a link to your comment.
So the fix stays what it is, one test at a time, and the cause stays in the test harness's use of one device from seven threads. I agree the runtime is a different case, though I have not checked that claim against Head unchanged ( |
The four tests of emit/waterfall_tests.rs each dispatch on the hardware adapter and on WARP. Started together from the test threads, the test binary sometimes died of an access violation (0xC0000005) before any of them finished: 7 of 24 runs of `cargo test -p victory-shader waterfall_tests` on the integration machine (RTX 5070; 6 of the first 12, 1 of 12 later, with less else running on the PC), 3 of 8 on WARP alone, 1 of 10 with the DXIL validator left out. With `--test-threads=1` they pass. They now take a lock around their dispatches, as Marvisak#433 does for the VALU tests: 0 of 36 runs died. Which call faults was not found (no debugger on the machine). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Resolves the conflict at the end of valu_tests.rs (both sides added tests) and moves Marvisak#433's ONE_AT_A_TIME lock to module scope so run_dwords takes it too. Adds the offset test @aziaconsal2026 posted on the pull request: vector and scalar byte offsets add to the immediate one, and neighbouring dwords stay untouched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Shader tests: run the VALU GPU tests one at a time (cargo test hangs now and then)
…tests Shader tests: run the VALU GPU tests one at a time (cargo test hangs now and then)
What
cargo testnow and then never finishes. The sevenemit::valu_teststhat run on the hardware adapter and on WARP start together on the test threads, none of their dispatches completes, and the test binary keeps one core busy until it is killed (the waits spin on the fence). Any other GPU test running at that moment is stuck with them.run_cases, which all seven go through, now takes a process-wide lock, so they use the GPU one at a time. The lock is poison-tolerant, so one failing test does not fail the others. Five lines, tests only.This is not #181's crash, which #244 fixes by serialising WARP operations. A hang was seen on #244 too and put down as probably separate; the numbers below agree. The two changes compose: #244 covers every WARP user, this one keeps these seven tests from overlapping on the hardware adapter as well.
Not verified
I do not know the cause inside the driver or the D3D12 runtime, only that the hang needs these tests to overlap. The tester above traced where it stops: in every hang all seven tests had created their pipeline and were inside their first dispatch, stopped at different calls (
CreateCommandQueue,Close, afterSignal, after the fence wait), so it looks like the device stalling when several threads use it at once (D3D12 gives every test the same device for an adapter), not one call deadlocking. Replacing the fence polling with an event did not help there (6 of 120 hung).It is not universal. A second machine with an NVIDIA card and a Radeon iGPU (RTX 5080) reproduces it more often than mine and confirms the fix: the whole
victory-shaderlib suite hung in 8 of 60 runs onmainand 0 of 60 with this PR; with the seven tests on the RTX 5080 alone, 6 of 40 against 0 of 40. (#244 alone hung in 3 of 60 there, as it did here.) Elsewhere it is rare or absent. A run on a machine with one hardware adapter (RTX 3060, no iGPU) saw no hang onmainin 30 runs, so there the fix is unconfirmed and only shown harmless. A reviewer on an RTX 5070 machine did see it once without this change: a fullcargo test --workspacein which six of these tests sat for more than 10 minutes, and then 5 of 5 standalone runs passed, with and without the lock. My machine has a second adapter (a Radeon iGPU), which the seven tests do not use.Tested
Windows 11, NVIDIA RTX 5070 with an AMD Radeon iGPU, debug,
d2a4bae. The workspace build of thevictory-shadertest binary, run in a loop withvalu_testsas the filter and a 45 s limit per run (a good run takes about 3 s):maind2a4bae7f95b87Split by backend with a local switch (not in the PR), 40 runs each:
valu_testsfiltermainSo the hang does not need WARP, and with the seven tests one at a time they do not overlap on WARP either.
The same split on a machine with one hardware adapter (RTX 3060), 40 runs each:
valu_testsfiltermainSo the WARP-only crash and its removal are confirmed on a second machine. The hardware-adapter hang has been seen on three machines: mine, the RTX 5080 machine above (which has its own before-and-after counts), and once on the reviewer's RTX 5070. Not on the RTX 3060. A second adapter is not needed: a machine whose only adapter is an RTX 5060 Ti hangs too (2 of 90
valu_testsruns and 3 of 52 whole-lib runs onmain, 0 of 120 with this PR), more often under CPU load.--skip valu_tests: 0 of 14 hung (on a branch with more GPU tests thanmain), so nothing else in the suite does this here.cargo test --workspace: 264 passed, 0 failed, 4 ignored. The seven tests take under 7 s one at a time.AI-assisted; no game assets were used.
🤖 Generated with Claude Code