Submitting thread: pass a fence wait whose signal stands behind sent flights (VICTORY_FENCE_AHEAD, off) #2009

Closed
github-bot wants to merge 5 commits from github-bot/gh-2009 into main AGit
Owner

@⁠binarycleric on GitHub · 2026-11-29 07:07 UTC · original
up/fence-ahead → main · +419 −35 · 3 files · 5 commits · closed without merging

Stacked on #2008: please merge that one first. Until then this PR also shows its three commits.

What it changes

Why

With the relay, a queue's fence signal goes behind its flights in the air and is set only when they land, after the
card has run them and their results are copied back. Until then another queue's wait for that fence holds its next part:
it can't go, and it can't be joined to the part before it.

What

With VICTORY_FENCE_AHEAD=1, the wait is met (at the head of its queue, or when taken along) by a signal of that fence,
to that value or higher, that stands in the line of flights (host::late_signalled). It is off by default; nothing
changes without the switch. Why this is equivalent:

  • Every host submission goes to the one direct queue in the order it is sent, and the card runs them in that order.
  • A signal is put in that line only once everything its queue was given before it has been sent, so the part behind
    the wait runs on the card after the work the signal is behind, which is what the wait asks of the card. It is the
    argument already made for a memory value a flight writes (late_met_known).
  • What preparing that part reads on the CPU of what those flights write is kept as for any part sent behind flights
    (late_blocked, the card steps, the title bytes under their writes).
  • The title sees the fence reach the value only when the flights land, never earlier, so its CPU waits and reads are
    unchanged.
  • A signal taken out of the line to be landed is no longer seen, so the wait stands until the fence is set. A higher
    value or another fence still stands.

The submitting thread's line, and its VICTORY_AB phase line, count the waits passed this way.

How it was tested

  • GPU and profile: RTX 5070 Ti 16 GB, Ryzen 9 7900X; Series X profile, 1440p native, DLSS off, frame generation off; ray-tracing passes left out (no structure builder); unit tests only so far
  • Before: a part whose fence wait stands behind flights already sent ends the joining
  • After: with VICTORY_FENCE_AHEAD=1 such a part is taken along. It's off by default, so nothing changes until it's turned on. Not yet measured in play: in #2008's counts, joining never stopped at "a fence not reached" in the release runs we have, so the gain in this game is unproven
  • cargo test passed for the crates it touches: yes. Rebased onto main e1f2eb60: cargo test --release -p victory-gpu --lib, 592 passed, 0 failed, 44 ignored

Tests

  • a_fence_signalled_behind_flights_sent_is_passed_and_no_other: such a wait goes, and is taken along, without the
    fence set; a wait for a higher value or for another fence still stands; the title's fence values don't move until set.
  • a_wait_is_met_behind_flights_only_by_its_fences_signal (host): a signal in the flights' line meets only its own
    fence's waits, at its value or below.
  • parts_taken_along_keep_the_order_and_the_fences_of_parts_done_alone: the same work across two queues that wait
    for each other's fences, with a drain and a present between, done part by part and with parts taken along. Each queue's
    order is the same, a part behind a cross-queue wait comes after the part the signal is behind, nothing is joined
    across the present, and the drain ends with everything before it done and its fences set.

Numbers

None yet. The A/B play run (VICTORY_FENCE_AHEAD on/off under the same load) hasn't come in, so there's no
measured gain. In the release runs we have (#2008's table), joining never stopped at "a fence not reached", so this can
only matter for fence waits at the head of a queue; its counter says how many are passed. This stays off by default
until a run shows a gain.

Not covered

  • The two-queue plan (VICTORY_ASYNC_QUEUE=plan) doesn't order such a pass; it would need a wait for the other queue's
    flight, as value_passed gives memory values.
  • The argument depends on submissions reaching the card in the order they are sent; a sender thread off the
    submitting thread would have to keep that.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1758 and #1849 (both change what the submitting thread does with parts that wait; neither passes a fence wait behind sent flights).
**@⁠binarycleric** on GitHub · 2026-11-29 07:07 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2009) `up/fence-ahead` → `main` · +419 −35 · 3 files · 5 commits · closed without merging **Stacked on #2008: please merge that one first. Until then this PR also shows its three commits.** ## What it changes #### Why With the relay, a queue's fence signal goes behind its flights in the air and is set only when they land, after the card has run them and their results are copied back. Until then another queue's wait for that fence holds its next part: it can't go, and it can't be joined to the part before it. #### What With VICTORY_FENCE_AHEAD=1, the wait is met (at the head of its queue, or when taken along) by a signal of that fence, to that value or higher, that stands in the line of flights (`host::late_signalled`). It is off by default; nothing changes without the switch. Why this is equivalent: - Every host submission goes to the one direct queue in the order it is sent, and the card runs them in that order. - A signal is put in that line only once everything its queue was given before it has been sent, so the part behind the wait runs on the card after the work the signal is behind, which is what the wait asks of the card. It is the argument already made for a memory value a flight writes (`late_met_known`). - What preparing that part reads on the CPU of what those flights write is kept as for any part sent behind flights (`late_blocked`, the card steps, the title bytes under their writes). - The title sees the fence reach the value only when the flights land, never earlier, so its CPU waits and reads are unchanged. - A signal taken out of the line to be landed is no longer seen, so the wait stands until the fence is set. A higher value or another fence still stands. The submitting thread's line, and its VICTORY_AB phase line, count the waits passed this way. ## How it was tested - GPU and profile: RTX 5070 Ti 16 GB, Ryzen 9 7900X; Series X profile, 1440p native, DLSS off, frame generation off; ray-tracing passes left out (no structure builder); unit tests only so far - Before: a part whose fence wait stands behind flights already sent ends the joining - After: with `VICTORY_FENCE_AHEAD=1` such a part is taken along. It's off by default, so nothing changes until it's turned on. Not yet measured in play: in #2008's counts, joining never stopped at "a fence not reached" in the release runs we have, so the gain in this game is unproven - `cargo test` passed for the crates it touches: yes. Rebased onto main e1f2eb60: `cargo test --release -p victory-gpu --lib`, 592 passed, 0 failed, 44 ignored #### Tests - `a_fence_signalled_behind_flights_sent_is_passed_and_no_other`: such a wait goes, and is taken along, without the fence set; a wait for a higher value or for another fence still stands; the title's fence values don't move until set. - `a_wait_is_met_behind_flights_only_by_its_fences_signal` (host): a signal in the flights' line meets only its own fence's waits, at its value or below. - `parts_taken_along_keep_the_order_and_the_fences_of_parts_done_alone`: the same work across two queues that wait for each other's fences, with a drain and a present between, done part by part and with parts taken along. Each queue's order is the same, a part behind a cross-queue wait comes after the part the signal is behind, nothing is joined across the present, and the drain ends with everything before it done and its fences set. #### Numbers None yet. **The A/B play run (VICTORY_FENCE_AHEAD on/off under the same load) hasn't come in**, so there's no measured gain. In the release runs we have (#2008's table), joining never stopped at "a fence not reached", so this can only matter for fence waits at the head of a queue; its counter says how many are passed. This stays off by default until a run shows a gain. #### Not covered - The two-queue plan (VICTORY_ASYNC_QUEUE=plan) doesn't order such a pass; it would need a wait for the other queue's flight, as `value_passed` gives memory values. - The argument depends on submissions reaching the card in the order they are sent; a sender thread off the submitting thread would have to keep that. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1758 and #1849 (both change what the submitting thread does with parts that wait; neither passes a fence wait behind sent flights).
Every submission, or group of parts prepared as one, now ends with one
reason: nothing of its queue behind it yet, lists still being translated,
a memory value not met, a fence not reached, a present, the parts' cap
(VICTORY_JOIN_PARTS), the lists' cap (VICTORY_JOIN_LISTS), title memory
written on the CPU for the next part, a CPU read of what the parts before
write, or off. The 5-second line of the submitting thread gets a second
line with the split per frame; the counts add up to the submissions
prepared separately.

`joinable` says which of its two rules refused (`Unjoinable`), and
`Work::take_along` gives the reason back with what it refused. Nothing is
joined or refused differently.
With VICTORY_AB turning switches on and off while the title runs, each
phase now ends with a line of the submitting thread's own: presents, and
per frame the thread's working time, submissions, those prepared
separately, those joined to the one before, the title's waits at presents,
and why parts were not joined. The phase's first second is left out, as
the phase's frame times leave it out. That gives both sides of a joining
switch under the same load in one run.
Named in VICTORY_AB, it raises the parts' cap to 32 (where joining is on)
and the lists' cap to 1024 in the phases it is on, so one run measures
what the caps cost, and what larger joins cost, under the same load. A
release build takes larger caps from VICTORY_JOIN_PARTS and
VICTORY_JOIN_LISTS as before; nothing changes without VICTORY_AB.
The same work, across two queues that wait for each other's fences, with a
drain and a present between, is done once part by part and once with parts
taken along. Each queue's order comes out the same, a part behind a wait
for the other queue's signal comes after the part that signal is behind,
nothing is joined across the present, and everything given before the
drain is done, with its fences set, when the drain ends.
A queue's wait for a fence stood until the fence was set. With the relay,
a queue's signal goes behind its flights in the air and is set only when
they land, after the card has run them and their results are copied back.
Meanwhile the waiting queue's next part could not go, and could not be
joined to the part before it either ("a fence not reached").

With the switch, the wait is met, at the head of its queue or when taken
along, by a signal of that fence to that value or more that stands in the
line of flights. Why that is equivalent:
- Every host submission goes to the one direct queue (two_queues is a plan
  only) in the order it is sent, and the card runs them in that order.
- A signal is put in that line only once everything its queue was given
  before it has been sent. So the part behind the wait runs on the card
  after the work the signal is behind, which is what the wait asks of the
  card. This is the argument already made for a memory value a flight
  writes (late_met_known).
- What preparing that part reads on the CPU of what those flights write is
  kept as for any part sent behind flights: late_blocked, the steps done on
  the card, the title bytes under their writes.
- The title still sees the fence reach the value when the flights land,
  never earlier, so its own CPU waits and reads are unchanged.
- A signal taken out of the line to be landed is not seen, so the wait
  stands until the fence is set, as before. A wait for a higher value, or
  another fence, still stands.

Not covered: the two-queue plan (VICTORY_ASYNC_QUEUE=plan) does not order
such a pass; it would need a wait for the other queue's flight, as
value_passed gives memory values. And the argument depends on submissions
reaching the card in the order they are sent, which a sender thread must
keep.

The submitting thread's line counts the waits passed so.
Tests: such a wait goes and is taken along without the fence set, while a
higher value or another fence still stands. A signal in the flights' line
meets only its own fence's waits, at its value or below.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 07:10:44 +00:00
github-bot closed this pull request 2026-11-29 07:16:17 +00:00

Pull request closed

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!2009
No description provided.