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

Open
github-bot wants to merge 1 commit from github-bot/gh-2811 into main AGit
Owner

@⁠Nosheboo on GitHub · 2026-11-29 17:37 UTC · original
Nosheboo:port/foxhound-send-avx2-stream → main · +140 −4 · 1 files · 1 commits · open

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).

**@⁠Nosheboo** on GitHub · 2026-11-29 17:37 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2811) `Nosheboo:port/foxhound-send-avx2-stream` → `main` · +140 −4 · 1 files · 1 commits · open ## 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).
Ports the non-temporal AVX2 upload path from readmet3xt-lab/foxhound commit 6c67166d (PR #36, by Dilim0n, GPL-3.0-or-later), aligning streaming runs to 32 bytes when writeback upload buffers are off-card and issuing an sfence once per parallel/sequential copy wave.

Co-authored-by: Dilim0n <[email protected]>
Co-authored-by: readmet3xt-lab <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 17:39:10 +00:00
github-bot force-pushed github-bot/gh-2811 from 4f50ece588 to 18447cca37 2026-11-29 23:15:49 +00:00 Compare
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host/send.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2811/head:github-bot/gh-2811'
git switch 'github-bot/gh-2811'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2811'
git switch 'github-bot/gh-2811'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2811'
git switch 'github-bot/gh-2811'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2811'
git switch 'main'
git merge --squash 'github-bot/gh-2811'
git switch 'main'
git merge --ff-only 'github-bot/gh-2811'
git switch 'main'
git merge 'github-bot/gh-2811'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

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