gpu(send): use AVX2 non-temporal streaming stores for writeback uploads #2811

Open
Nosheboo wants to merge 1 commit from upstream-pr/2811 into main
Nosheboo commented 2026-11-29 17:37:08 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by Nosheboo on 2026-11-29T17:37:08Z.


Motivation

On upstream 55d06914, baseline gameplay profiling shows frame_times median 43.7–44.5 ms with the submitter spending 41.5–43.6 ms/frame, including 1.5–1.6 ms/frame in sending upload copies. When writeback upload buffers (VICTORY_SEND_WB=1) sit in system memory (!on_card()), standard copy_nonoverlapping pollutes CPU L3 cache for write-once upload traffic.

Changes

  • Adds AVX2 non-temporal streaming upload copies (stream_copy_avx2, copy_upload, stream_fence) for copies >= 4096 bytes (STREAM_COPY_MIN_BYTES) into writeback, off-card upload allocations in crates/victory-gpu/src/host/send.rs.
  • Applies 32-byte run_align only when streaming is active so non-streaming/small/on-card paths keep existing alignment and copy behavior.
  • Issues one _mm_sfence() per sequential or parallel copy wave only when at least one non-temporal stream copy actually ran.
  • Integrates cleanly with upstream #2509 (parallel_copy_work), retaining both parallel_copy_threshold_requires_multiple_tasks and stream_copy_handles_unaligned_dst_src_and_tails.

Attribution

Ported from FoxHound v0.8.1: readmet3xt-lab/foxhound commit 6c67166d (PR #36, author Dilim0n, GPL-3.0-or-later). Commit trailers and in-file doc comments retain attribution to Dilim0n and readmet3xt-lab.

Verification

  • Rebased cleanly onto upstream/main (41adb551): git diff --check upstream/main..HEAD clean; trailers intact (Co-authored-by: Dilim0n, Co-authored-by: readmet3xt-lab).
  • cargo clippy -p victory-gpu --no-deps --all-targets --locked and --all-features with -W clippy::undocumented_unsafe_blocks: 0 warnings in crates/victory-gpu/src/host/send.rs (pre-existing workspace -D warnings errors on upstream/main live outside this PR).
  • cargo test -p victory-gpu --lib --locked host::send:: -- --test-threads=1 -> 4 passed; 0 failed; 1 ignored (ignored: scatter_updates_selected_words_and_keeps_the_rest, requires adapter + helper shader compiler).

Council review

Rounds: 4

Delegate Round 1 Round 2 Round 3 Round 4 (Rebase)
Concurrency & Safety Auditor (gpt-6-luna, xhigh) 9/10 9/10 9/10 10/10
Performance & Modernization Architect (gpt-6-luna, xhigh) 8/10 8/10 9/10 9/10
Upstream PR Hygiene & Test Critic (gpt-6-luna, xhigh) 8/10 8/10 9/10 10/10

Created in T3 Code (reviewed by Council: 3× gpt-6-luna on xhigh).

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5553310026 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2811). Originally posted by [Nosheboo](https://github.com/Nosheboo) on 2026-11-29T17:37:08Z. --- ## Motivation On upstream `55d06914`, baseline gameplay profiling shows `frame_times` median `43.7–44.5 ms` with the submitter spending `41.5–43.6 ms/frame`, including `1.5–1.6 ms/frame` in `sending` upload copies. When writeback upload buffers (`VICTORY_SEND_WB=1`) sit in system memory (`!on_card()`), standard `copy_nonoverlapping` pollutes CPU L3 cache for write-once upload traffic. ## Changes - Adds AVX2 non-temporal streaming upload copies (`stream_copy_avx2`, `copy_upload`, `stream_fence`) for copies `>= 4096` bytes (`STREAM_COPY_MIN_BYTES`) into writeback, off-card upload allocations in `crates/victory-gpu/src/host/send.rs`. - Applies 32-byte `run_align` only when streaming is active so non-streaming/small/on-card paths keep existing alignment and copy behavior. - Issues one `_mm_sfence()` per sequential or parallel copy wave only when at least one non-temporal stream copy actually ran. - Integrates cleanly with upstream `#2509` (`parallel_copy_work`), retaining both `parallel_copy_threshold_requires_multiple_tasks` and `stream_copy_handles_unaligned_dst_src_and_tails`. ## Attribution Ported from **FoxHound v0.8.1**: [`readmet3xt-lab/foxhound`](https://github.com/readmet3xt-lab/foxhound) commit `6c67166d` (PR #36, author `Dilim0n`, `GPL-3.0-or-later`). Commit trailers and in-file doc comments retain attribution to `Dilim0n` and `readmet3xt-lab`. ## Verification - Rebased cleanly onto `upstream/main` (`41adb551`): `git diff --check upstream/main..HEAD` clean; trailers intact (`Co-authored-by: Dilim0n`, `Co-authored-by: readmet3xt-lab`). - `cargo clippy -p victory-gpu --no-deps --all-targets --locked` and `--all-features` with `-W clippy::undocumented_unsafe_blocks`: `0` warnings in `crates/victory-gpu/src/host/send.rs` (pre-existing workspace `-D warnings` errors on `upstream/main` live outside this PR). - `cargo test -p victory-gpu --lib --locked host::send:: -- --test-threads=1` -> `4 passed; 0 failed; 1 ignored` (ignored: `scatter_updates_selected_words_and_keeps_the_rest`, requires adapter + helper shader compiler). ## Council review Rounds: 4 | Delegate | Round 1 | Round 2 | Round 3 | Round 4 (Rebase) | | --- | --- | --- | --- | --- | | Concurrency & Safety Auditor (`gpt-6-luna`, `xhigh`) | 9/10 | 9/10 | 9/10 | 10/10 | | Performance & Modernization Architect (`gpt-6-luna`, `xhigh`) | 8/10 | 8/10 | 9/10 | 9/10 | | Upstream PR Hygiene & Test Critic (`gpt-6-luna`, `xhigh`) | 8/10 | 8/10 | 9/10 | 10/10 | Created in T3 Code (reviewed by Council: 3× gpt-6-luna on xhigh).
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/2811:upstream-pr/2811'
git switch 'upstream-pr/2811'

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/2811'
git switch 'upstream-pr/2811'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2811'
git switch 'upstream-pr/2811'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2811'
git switch 'main'
git merge --squash 'upstream-pr/2811'
git switch 'main'
git merge --ff-only 'upstream-pr/2811'
git switch 'main'
git merge 'upstream-pr/2811'
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!2811
No description provided.