[pr-tests][shaders] Folded 2-D group test holds ONE_AT_A_TIME while it reads DARNER_THREAD_TICKET #386

Open
ElGibbone wants to merge 1 commit from elgibbone/thread-ticket-lock into main AGit
First-time contributor

What it changes

  • The problem on main: read from the code only (found in the review of #314). wave64_tests::the_console_threads_of_a_two_dimensional_group_are_each_given_once sets DARNER_THREAD_TICKET to "0" for a while and removes it, holding ONE_AT_A_TIME. folded_tests::two_dimensional_groups_of_several_host_waves_give_every_console_thread_once lowers a wave32 program in a 32 x 2 group at host width 32, which reaches ticket_on() (crates/darner-shader/src/emit/lower.rs:1653-1656), without that lock. If the two run at the same time, the folded test's shader can be lowered without the thread ticket, and on a host that fills 2-D groups from 16 x 2 tiles (NVIDIA, as the comment there says) its check fails. I have not seen it fail; this is from reading the code.

The folded test now holds ONE_AT_A_TIME around lower::lower and drops it before run, which takes the lock itself (taking it for the whole test would deadlock, as std::sync::Mutex is not re-entrant). Test code only.

How it was tested

  • Tested revision: de2713a
  • Commands and results (Windows 11 Home 26300, Ryzen 7 7800X3D, RTX 4070 Ti driver 621.47, Rust 1.98.1 MSVC):
    • cargo clippy --workspace --all-targets --locked -- -D warnings: clean
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean
    • cargo xtask policy: 555 files ok
    • cargo test --locked -p darner-shader --lib emit::folded_tests: 20 passed, 0 failed (the changed test passes and does not hang)
    • cargo test --locked -p darner-shader --lib emit::wave64_tests: the_console_threads_of_a_two_dimensional_group_are_each_given_once passed; I stopped the module run before its slowest GPU tests finished, none had failed
  • Changes a default: no
  • Gates run on that revision: the two clippy gates and cargo xtask policy; cargo test on the darner-shader test modules involved only, not --workspace (a workspace run on #314's branch, whose darner-shader is main's, is reported there).
  • Gameplay: not relevant (test code only).
  • Shader wave sizes tested, when relevant: the folded test is wave32 at host width 32; the wave64 test at host width 32.
  • Hardware dependence: the race can only change the result on a host that fills 2-D groups from tiles; tested on an RTX 4070 Ti.
  • Coverage gaps: the race itself was not reproduced.

Checklist

  • I ran this change in the game, or say below why it can't be (docs, tests only). Not run in the game: test code only.
  • This PR contains one change based on main.
  • The diff follows docs/asset-policy.md.
  • I recorded this PR's dependencies below.
    • Depends on: none

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches.
  • Related PRs: #314 (its review found this). #312 also changes crates/darner-shader/src/emit/folded_tests.rs; the two merge without a conflict (git merge-tree against its head c55f1ac).
  • Replaces or overlaps: none found (searched issues and pull requests for THREAD_TICKET, ONE_AT_A_TIME and the test's name)
## What it changes - The problem on main: read from the code only (found in the review of #314). `wave64_tests::the_console_threads_of_a_two_dimensional_group_are_each_given_once` sets `DARNER_THREAD_TICKET` to `"0"` for a while and removes it, holding `ONE_AT_A_TIME`. `folded_tests::two_dimensional_groups_of_several_host_waves_give_every_console_thread_once` lowers a wave32 program in a 32 x 2 group at host width 32, which reaches `ticket_on()` (`crates/darner-shader/src/emit/lower.rs:1653-1656`), without that lock. If the two run at the same time, the folded test's shader can be lowered without the thread ticket, and on a host that fills 2-D groups from 16 x 2 tiles (NVIDIA, as the comment there says) its check fails. I have not seen it fail; this is from reading the code. The folded test now holds `ONE_AT_A_TIME` around `lower::lower` and drops it before `run`, which takes the lock itself (taking it for the whole test would deadlock, as `std::sync::Mutex` is not re-entrant). Test code only. ## How it was tested - Tested revision: de2713a - Commands and results (Windows 11 Home 26300, Ryzen 7 7800X3D, RTX 4070 Ti driver 621.47, Rust 1.98.1 MSVC): - `cargo clippy --workspace --all-targets --locked -- -D warnings`: clean - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: clean - `cargo xtask policy`: 555 files ok - `cargo test --locked -p darner-shader --lib emit::folded_tests`: 20 passed, 0 failed (the changed test passes and does not hang) - `cargo test --locked -p darner-shader --lib emit::wave64_tests`: `the_console_threads_of_a_two_dimensional_group_are_each_given_once` passed; I stopped the module run before its slowest GPU tests finished, none had failed - Changes a default: no - Gates run on that revision: the two clippy gates and `cargo xtask policy`; `cargo test` on the darner-shader test modules involved only, not `--workspace` (a workspace run on #314's branch, whose darner-shader is `main`'s, is reported there). - Gameplay: not relevant (test code only). - Shader wave sizes tested, when relevant: the folded test is wave32 at host width 32; the wave64 test at host width 32. - Hardware dependence: the race can only change the result on a host that fills 2-D groups from tiles; tested on an RTX 4070 Ti. - Coverage gaps: the race itself was not reproduced. ## Checklist - [ ] I ran this change in the game, or say below why it can't be (docs, tests only). Not run in the game: test code only. - [x] This PR contains one change based on `main`. - [x] The diff follows `docs/asset-policy.md`. - [x] I recorded this PR's dependencies below. - Depends on: none ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. - Related PRs: #314 (its review found this). #312 also changes `crates/darner-shader/src/emit/folded_tests.rs`; the two merge without a conflict (`git merge-tree` against its head `c55f1ac`). - Replaces or overlaps: none found (searched issues and pull requests for `THREAD_TICKET`, `ONE_AT_A_TIME` and the test's name)
two_dimensional_groups_of_several_host_waves_give_every_console_thread_once
lowers a wave32 program in a 32 x 2 group at host width 32, which reaches
ticket_on() and so reads DARNER_THREAD_TICKET. A wave64 test sets that
variable to "0" for a while, holding ONE_AT_A_TIME; this test read it
without the lock, so it could be lowered without the thread ticket. The
lock is held only around lower(): run() takes it itself.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/386/head:elgibbone/thread-ticket-lock'
git switch 'elgibbone/thread-ticket-lock'

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.

git switch 'main'
git merge --no-ff 'elgibbone/thread-ticket-lock'
git switch 'elgibbone/thread-ticket-lock'
git rebase 'main'
git switch 'main'
git merge --ff-only 'elgibbone/thread-ticket-lock'
git switch 'elgibbone/thread-ticket-lock'
git rebase 'main'
git switch 'main'
git merge --no-ff 'elgibbone/thread-ticket-lock'
git switch 'main'
git merge --squash 'elgibbone/thread-ticket-lock'
git switch 'main'
git merge --ff-only 'elgibbone/thread-ticket-lock'
git switch 'main'
git merge 'elgibbone/thread-ticket-lock'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
TrustNo1/Darner!386
No description provided.