gpu: parallelize batch clamp reads and add single-group atomic fast path #5059

Open
danielibabet wants to merge 1 commit from upstream-pr/5059 into main
danielibabet commented 2026-12-01 18:43:02 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by danielibabet on 2026-12-01T18:43:02Z.


Summary

  • Optimize the batched indirect argument clamping compute pass (crates/victory-gpu/src/indirect/batch.rs):
    • Load count, this thread's job, and the current budget together at shader entry instead of issuing serialized dependent loads (jobs.Load(0) -> jobs.Load4 -> budget.InterlockedOr(0, 0, ...) -> InterlockedCompareExchange).
    • When count <= 64 (a single thread group, so no other group races for the budget) and all jobs fit within BUDGET - seen, charge the budget with one non-CAS budget.InterlockedAdd(0, total, ...) instead of InterlockedOr + CAS loop.
    • Fall back to the existing InterlockedOr + InterlockedCompareExchange path when count > 64 or when any job exceeds the remaining budget.

Verification

  • cargo test --locked -p victory-gpu --lib -j 16 -- indirect::: 37 passed, 0 failed, 11 ignored (including host_list_batches, warp_batch_clamps_as_the_clamp_of_one_does, warp_batch_charges_every_execution, warp_batch_saturates_budget_when_rest_is_enabled).
  • cargo clippy --workspace --all-targets --locked -j 16 (default & --all-features, ignoring pre-existing origin/main lints in host/{font,menu,panel}.rs): passed.
  • cargo xtask policy: asset policy: 464 files ok.
<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5592177995 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/5059). Originally posted by [danielibabet](https://github.com/danielibabet) on 2026-12-01T18:43:02Z. --- ## Summary - Optimize the batched indirect argument clamping compute pass (`crates/victory-gpu/src/indirect/batch.rs`): - Load `count`, this thread's `job`, and the current `budget` together at shader entry instead of issuing serialized dependent loads (`jobs.Load(0)` -> `jobs.Load4` -> `budget.InterlockedOr(0, 0, ...)` -> `InterlockedCompareExchange`). - When `count <= 64` (a single thread group, so no other group races for the budget) and all jobs fit within `BUDGET - seen`, charge the budget with one non-CAS `budget.InterlockedAdd(0, total, ...)` instead of `InterlockedOr` + CAS loop. - Fall back to the existing `InterlockedOr` + `InterlockedCompareExchange` path when `count > 64` or when any job exceeds the remaining budget. ## Verification - `cargo test --locked -p victory-gpu --lib -j 16 -- indirect::`: 37 passed, 0 failed, 11 ignored (including `host_list_batches`, `warp_batch_clamps_as_the_clamp_of_one_does`, `warp_batch_charges_every_execution`, `warp_batch_saturates_budget_when_rest_is_enabled`). - `cargo clippy --workspace --all-targets --locked -j 16` (default & `--all-features`, ignoring pre-existing `origin/main` lints in `host/{font,menu,panel}.rs`): passed. - `cargo xtask policy`: `asset policy: 464 files ok`.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/5059:upstream-pr/5059'
git switch 'upstream-pr/5059'

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 'upstream-pr/5059'
git switch 'upstream-pr/5059'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/5059'
git switch 'upstream-pr/5059'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/5059'
git switch 'main'
git merge --squash 'upstream-pr/5059'
git switch 'main'
git merge --ff-only 'upstream-pr/5059'
git switch 'main'
git merge 'upstream-pr/5059'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
trustno1-coder/VIctory-NVIDIA!5059
No description provided.