Skip to content

Lane masks and whole-wave sections of wave64 programs on 32-lane hosts - #99

Open
Castyan wants to merge 51 commits into
DexNom:mainfrom
Castyan:native-0x218-lane-masks
Open

Castyan wants to merge 51 commits into
DexNom:mainfrom
Castyan:native-0x218-lane-masks

Conversation

@Castyan

@Castyan Castyan commented Nov 26, 2026 •

Copy link
Copy Markdown

Stacked on #98 (0x218, itself on #64 and #61). The changes to review are the 8 commits after 60ff2e8.

What

Wave64 programs on 32-lane hosts: lane masks and whole-wave sections that were refused, or computed wrongly.

  • 1745c11, 66347fb EXEC set to constant lanes (s_bfm_b64 exec, 32, 0, halves moved apart with s_mov_b32 exec_lo/exec_hi, s_bitreplicate_b64_b32, s_pack_*, s_movk_i32, s_brev_b32) is taken as that constant mask. An execution test runs 8 cases against the console's 64-lane result.
  • 898fc6d Bug fix: a lane read inside a whole-wave section is no longer taken as each lane's own value. v_readlane_b32 s14, v1, 3 with v1 = t + 1 gave each thread t + 1 where the console gives 4. This bug predates Run wave64 compute programs in a paired form on 32-lane hosts (port of fxceless#854, stacked on #61) #64. Such a read is now refused instead of computing a wrong value.
  • f60719a A lane of a reduction read after EXEC is restored is taken.
  • 76ad683 SCC of a mask operation read as a number (src_scc, s_cselect, a carry after s_and_b64 s, vcc, exec) is "some lane of the console wave". It is exact in the paired form, or where the result is held in the lanes running there. Otherwise it stays refused.
  • 14c63a5 The sections of a block are simulated in order, so a section can read a lane of the one before it (the 0x218 reductions come two by two).
  • 9e0cd49 A section with no restore ends at the first EXEC write the simulation does not follow (m128 leaves its section for lane 0 alone).
  • 8b8f401 VCC on entry to a compute wave is read as 0, as the SGPRs above the hardware inputs already are. In run4 m159, m160 and m162 it only reaches a mask on the execz edge, where s_orn2 s, vcc, exec with EXEC 0 sets every bit whatever VCC holds. Its test runs that shape for 32- and 64-lane console waves against the console's result.

Results

Replay of two sets of 200 captured 0x218 descriptions on the RTX 5060 (programs reaching a hardware pipeline, dump-218 / dump-218-run4). Each change was measured on the tree it was developed on (the old #64 head), with no program lost: 898fc6d and f60719a together +2 / +3, 76ad683 +17 / +9, 14c63a5 +3 / +3, 9e0cd49 +1 / +1, 8b8f401 +0 / +3 (m159, m160, m162).

Checks (RTX 5060, at 8b8f401)

cargo clippy --workspace --all-targets --locked -- -D warnings, with and without --all-features: clean. cargo test --workspace --locked: 748 passed, 0 failed, 11 ignored.

🤖 Generated with Claude Code

Castyan and others added 30 commits November 25, 2026 19:29
…to combined-preload-pops

# Conflicts:
#	Setup-DexNomRuntime.ps1
#	apps/victory/src/play_launcher.rs
#	apps/victory/src/translate.rs
#	crates/victory-gpu/src/descriptor/host.rs
#	crates/victory-gpu/src/host.rs
#	crates/victory-gpu/src/pipeline/make.rs
#	crates/victory-hle/src/modules/d3d12x.rs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…wn lanes

Three wave64 compute shaders (a 512-thread prefix over per-wave totals) were
refused on 32-lane hosts: inside a loop only one console wave's lanes run,
v_readfirstlane copies a running sum built from scalars and LDS alone. Two
host waves cannot exchange there (no group barrier inside the loop), but every
lane holds the same sum, so each host wave's own first lane is exact.

scalar_built() finds such VGPR values (VALU results and LDS reads of them,
phis at loop headers or where every predecessor runs on all lanes; guards
allowed), and remembers which a guarded write made: those are only taken by a
read that is itself inside a branch.

Fixes 9fc111d3be79364f, 77360df21e12ea43 and 39321a95223001ed on the
RTX 5060; their pipelines are now created.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…change loop

Compute 7f61193d2c0e5f22 was refused by CreateComputePipelineState with
E_OUTOFMEMORY on the RTX 5060 and on WARP alike, although its DXIL validates.
Bisecting the console code down to one instruction: ds_add_rtn_u32 of
(0 - x) on group-shared memory. Host compilers turn atomicrmw add of a
negation into atomicrmw sub, which DXIL has no group-shared form of, and
refuse the pipeline; ds_sub_u32 (atomicrmw sub) fails the same way.

Both are now a load and a cmpxchg loop on old - x (lds_subtract); other
atomics keep their atomicrmw. A test runs ds_add of 0 - 1 and ds_sub of
0 - 1 over 32 threads and checks LDS on the card (32 and 96).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Port of DexNom#40 (notquiteog), unchanged. A console wave64 compute
program that no other form takes off 64-lane waves is refused by a 32-lane
host and every dispatch of it is dropped; the exact wave-wide form is tried
last, only for those. VICTORY_WAVE_WIDE=0 keeps the old refusal.

On the RTX 5060 this creates 22 of the 31 compute pipelines the title's
preload left refused for requiring WaveSize(64). The 9 left: 7 run groups of
several console waves (128 to 1024 threads), which the wave-wide form does
not take, and 2 are ray-tracing BVH builder programs (28918b7150a7aad5,
caa78b8ca62bc3d6) whose waves exchange across halves.

Co-Authored-By: notquiteog <notquiteog@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
warp_a_title_buffer_in_place_shows_its_bytes_at_its_offset decommitted
half of its allocation right after dropping the buffer placed over it.
The pages of a heap opened on private memory stay locked until the
runtime has destroyed the heap, and WARP may do that a moment after the
last reference goes: under the load of the whole victory-gpu suite the
decommit was sometimes refused (ERROR_INVALID_PARAMETER) and the test
failed, or the run ended in an access violation. About 2 runs in 15
failed this way, already on a65db62.

The test now retries the decommit for two seconds at most, drops its
command queue before releasing the allocation, and checks that the
release succeeds. 40 runs of the library in a row now pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test binary's random access violations were d3d10warp.dll's own. Every
test that asks for the software adapter gets the same device (one per
adapter in a process), and two of them compiling and running compute
shaders at once crash its shader compiler: in JITBaseVariable::OptimizeCopy
as a ComputePipelineShaderJIT is torn down, under ExecuteCommandLists of
the indirect tests' harness, or in Task_CompileShader on its own worker
threads. Every stack caught under cdb had two or more indirect::tests::warp_*
tests inside it at once. They take turns now, with the in-place tests that
open the same adapter: under cdb, 50 of 588 runs of all tests crashed
before, none of 240 after; 150 plain runs passed.

frame's tick test tries again when a busy PC wakes a wait late.

Ported from avatarmanz/VIctory-7900XTX 160d222 (its WARP turn and frame
parts; its write watch change is left out here).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…f fxceless#854)

Port of 26600c6 from fxceless/victory-fork#854 by PiloteCode ("wave64
programs in a paired form on 32-lane hosts, mesh programs over 32 KiB
linked with their pixel program, and more"). Each console wave runs as
one host wave of 32 lanes, each thread two console lanes (n and n + 32),
with every per-lane branch taken by the whole wave and EXEC as each
lane's guard. It is tried after every other form for a wave64 compute
program the host refuses (VICTORY_WAVE_PAIRS=0 turns it off).

On the 31 wave64 compute containers from the RTX 5060 preload, 29 get a
pipeline (22 before): 02384a60fda6f2d0, 1d434307d981352a,
22338086ea4c5364, 2da4beb386509b77, 3b02415f67c6b0d8, 6832a9da15c2e584
and 6b82bc7d22016cb5 now take the paired form; the other 22 are
unchanged.

Adapted to this branch:
- Kept from this branch: scalar_built() and the v_readfirstlane own-lane
  read, lds_subtract() with Module::negated() (the PR's own LDS
  subtraction loop is left out), the wave-wide last resort from
  DexNom#40 (now inside emit_forms), the POPS translation from pops.rs,
  the structured view record count / picked address / puddle texture
  size paths and scalar UINT views (moved into descriptor_data.rs next
  to the PR's unused-descriptor path, which now only runs where this
  branch refused).
- Left out: the PR's second POPS implementation (ir::without_pops_wait,
  Shader::ordered and its test), which would have run beside pops.rs.
- The ray-tracing structure builder's programs (a spilled user-data
  table, as victory-gpu classifies them) are refused by the paired form:
  forcing them onto 32-lane hosts hung NVIDIA GPUs in Marvisak#2711.
  28918b7150a7aad5 and caa78b8ca62bc3d6 stay refused.
- The new modules are classified in lib.rs; a test that expected the
  parked mask to be opaque when built alone checks only the shared build;
  the descriptor size test fills the record-count root word the runtime
  fills.

Co-Authored-By: Pilote Production <75377040+PiloteCode@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The two BVH builder programs (28918b7150a7aad5, caa78b8ca62bc3d6) were
the last wave64 compute programs refused on 32-lane hosts. They exchange
across the console wave's halves, which the per-half form got wrong and
which hung NVIDIA cards (Marvisak#2711). The paired form keeps
both halves in one host wave, so the refusal is dropped: all 31 wave64
compute containers from the RTX 5060 preload now get a pipeline.

The builder still runs only when victory-gpu allows it
(VICTORY_BVH_BUILDER=1 or VICTORY_RAY_TRACING=1) and every one of its
pipelines has a host pipeline; by default its dispatches stay dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e method 0x218)

The title calls device method 0x218 at start for every variant of its
small compute programs (mip generation of texture arrays), handing over
a 0x60-byte description: the root signature, then (address, size) pairs
of the program's registers, its code and its resource table. Until now
the call failed with a null output and the title went without these
pipelines.

The program is now read from the description (registers, console
resource table, code without its s_code_end padding) and wrapped in a
container of its own, which is translated and cached as the title's
containers are. Descriptions that cannot be read still fail with
E_NOTIMPL and a null output. Method 0x1c8 (native graphics pipelines)
stays refused: it needs the draw's render-target formats.

The descriptor tracer also folds s_bfm_b32 and a 64-bit s_mov of a
literal (zero extended), the two instructions these programs use to
build their fixed sampler; without them the sampler's origin was lost
and the pipeline refused.

On the five 0x218 captures from the RTX 5060, all five now get a
hardware pipeline and are created by the runtime.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 0x218 commit cut the note on device method 0x1c8 down to one line
and dropped its `shortcut:` marker, which is how the repository lists
what is not implemented. It also put native_build.rs in the middle of
the sorted list of sources outside the translation, with a comment that
did not say why it is outside. The note and its marker are back, and
the entry now sits at the end of the list with the reason: native_build
only writes containers, which are hashed like any other.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Descriptions captured in game showed three misreadings in the decoder of
programs handed to device method 0x218:

- The user-data dword and the stride were swapped. The byte in the
  packed word is the user-data dword: every entry of root slot k names
  dword 4 + k, inside the program's COMPUTE_PGM_RSRC2 user-SGPR count.
  The u32 before it is the stride (0x10 or 0x20 for structured buffer
  SRVs, 4 for images, as in the title's own containers). With the swap,
  the CBV of every accepted mip-generation program named user-data
  dword 0 instead of the table in dword 4. A root parameter that names
  user data the program does not have is now refused.
- The header count is not always that of the 0x41 entries (11 for 12
  seen), so the entries are told apart by their tag.
- Root type 0 is root constants, read as values from the user SGPRs
  (`v_mul_f32 v7, s5, v7`). They are now a root parameter of size/4
  SGPRs, with no used resource.
- The thread-group depth is the low half of its word; the high half
  holds something else (0x10 seen with 32 x 1 x 1 groups).

In game, 0x218 now makes over 2048 pipelines and turns down 32 to 63
descriptions (before: about 512 made, over 1024 turned down). Of eight
descriptions captured in game, all now decode and four reach a hardware
pipeline; the four others stop at translator limits (a descriptor
changed after loading, an address with two computed terms). The five
earlier captures still pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A description the decoder turns down used to be logged with a count
only, and one whose blocks could not be read was not logged at all.
The warning now gives the reason (which block, or the decoder's error)
and the description's twelve words.

With VICTORY_DUMP_NATIVE=<folder>, a description turned down is saved
there with the blocks it names, four of each reason and 200 in all, as
slot218-<n>-desc-<address>.bin and slot218-<n>-dNN-<address>-<size>.bin
with the reason beside them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Root type 1 in a console resource table is a root descriptor: a 64-bit
buffer address in two user SGPRs. The title's programs that use one (a
root SRV t1 in user data 7 and 8, the next slot at 9) build a buffer
descriptor around s7:s8 and load through it, so it becomes a root
parameter of two SGPRs and a used resource, as the title's containers
give one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The flags' bit 5, which says 32 lanes in the title's containers, is
clear in every description captured from device method 0x218, so every
such program was taken as 64 lanes. The ones whose depth word has 0x10
in its high half are 32-lane programs: they move exec_lo alone, keep
scalars in vcc_hi and use VGPRs up to the 32-lane count of
COMPUTE_PGM_RSRC1 exactly (v143 of 18 granules in slot218-m005, v127
of 16 in m008, v40 of 6 in m007, beyond the 64-lane count). The others
move the whole exec and stay within the 64-lane count (v23 of 6 in
m002, v31 of 8 in run1-m004).

As 64 lanes, a v_cmp writing s[15:16] overwrote the first dword of a
descriptor in s[16:19] (m008 at 0x2f8, "a descriptor changed after
loading"), and the VGPR count was half the program's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Castyan and others added 21 commits November 26, 2026 20:28
The 0x218 programs read structured buffers by byte through a descriptor
the code rewrites after loading it: the stride cleared in dword 1
(s_and_b32 by 0xc000ffff), the record count in dword 2 multiplied by
the stride (s_mul_i32 by s_max_u32 of s_bfe_u32 of dword 1, 14 bits at
16, and 1), OOB_SELECT raw in dword 3 (s_or_b32 of 0x30000000, after
an s_and_b32 by 0xcfffffff). The tracker refused it as "a descriptor
changed after loading".

The memory and its size in bytes are the loaded descriptor's, and the
host's buffer views are raw already, so the tracker now takes the
rewritten descriptor as the load's. An access that reads it by index
or format is refused: with stride 0 the index adds nothing, where the
load's descriptor would scale it.

slot218-m005, m006 and m008 now get past these descriptors; with m007
they stop at "an address with two computed terms": a descriptor loaded
from s[10:11] plus s9 << 5, user SGPRs the resource table names no root
parameter for (a heap and its index, as far as the code shows).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…late

The resource table of a 0x218 description names only some of the user
SGPRs a program reads: slot218-m007 loads a descriptor from s[10:11]
plus s9 << 5, where the table has entries for user-data dwords 4 to 6
alone. Word 0 of the description is the root signature, one of ours,
which keeps its serialized form; what s7 to s10 hold is in it.

With VICTORY_DUMP_NATIVE, every saved description now has that
serialized form beside it, as slot218-<n>-root.bin, and a description
whose program decodes but does not translate is saved too, its reason
being the translator's ("translation: GFX10 code at ..."). Such
descriptions were not saved before, so no capture showed what the
translator turns down. Root signatures are told from other objects by
their function table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The resource table of a 0x218 description names only some of the user
SGPRs a program reads (slot218-m007: entries for user-data dwords 4 to
6, a descriptor loaded from s[10:11] plus s9 << 5), and the translator
refused what it could not trace. The decoder now reads the root
signature the description names (an RTS0 part, alone or in a
container) and adds the parameters the table leaves out.

Every captured table places the parameters from user-data dword 4 on,
in order, a table taking one dword, root constants their count and a
root CBV two (slot 0 at 4 even when unnamed; a root CBV at 7 and 8, the
constants after it at 9), so the others are placed the same way and
only those. Nothing is guessed: the program is refused, with the reason,
when the table places a parameter elsewhere, when a parameter is cut by
the end of the program's user SGPRs, when user SGPRs are left past the
parameters (where a directly indexed heap would be: no capture places
one), for a root SRV or UAV (no table places one) and when the
signature cannot be read. Without a signature the table's layout is
used alone, as before.

The captures hold no root signature yet, so they replay as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The two merged branches disagreed on root SRVs: the resource table
decoder reads one (root type 1, kind SRV, a 64-bit address in user data
7 and 8 that the program builds a buffer descriptor around), while the
root signature reader refused every root SRV as one no capture places.
In game, where a signature comes with every description, a program the
table describes in full would then have been turned down.

A root SRV in the signature is now a root descriptor of two dwords, as
a root CBV, and is taken when the table places it itself. One the
signature names and the table leaves out is still refused, as is every
root UAV: what they are read as is not known.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
73d8513 refused every 0x218 program with user SGPRs left past its root
parameters, where a directly indexed heap would be. A game run with
ed45fe9 captured 200 descriptions with their root signatures: 196 end
their parameters exactly at their user-SGPR count, and the 4 with one
more have CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED in their signature but never
read that SGPR. The refusal only cost pipelines: over 1024 descriptions
were turned down in that run, against 32 to 63 before 73d8513.

Those SGPRs are now left unnamed. A program that reads one is still
refused, by the translator ("a hardware SGPR input"), so nothing is
placed there by guess. All 200 captured descriptions now decode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9eac44a read the root constants entry's byte as their size in bytes.
Against the 200 root signatures captured with their descriptions, that
byte is 4 whatever the count: 1, 2, 3 or 4 constants in the signature
(30 descriptions with 4, 6 with 2, 2 with 1, 1 with 3, all with byte 4).
Programs with more than one constant read SGPRs nothing named and were
refused ("a hardware SGPR input"), 35 of the 200 captures.

The table alone now gives the first constant, and the signature gives
the count of those it names, refused if they run past the program's
user SGPRs. Of the 200 captures, the hardware SGPR refusals are gone
and 11 reach a hardware pipeline (2 before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 0x218 programs read SCC as a number through operand 253, src_scc:
s_mov_b32 sN, src_scc (283 times in the 37 captures refused for it),
s_add_u32, s_and_b32, s_or_b32, s_mul_i32, s_sub_i32, and VALU
v_mov_b32, v_add_nc_u32 or v_lshl_add_u32. The IR already records the
read of SCC for that operand, but the lowering refused it as "a special
operand (vccz, execz, scc, lds_direct)".

It is now the SCC bit, 0 or 1. A test runs s_mov_b32, s_add_u32 and
v_mov_b32 of src_scc after s_cmp_lg_u32 on the card and on WARP. Of the
200 descriptions captured in game, the special operand refusals are
gone and 17 reach a hardware pipeline (11 before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Four scalar operations the 0x218 programs use were refused by name:
s_pack_ll_b32_b16 (7 of the 200 captures), s_pack_hh_b32_b16 (4),
s_bitreplicate_b64_b32 (6) and s_bfm_b64 (1). s_pack_lh_b32_b16 comes
with the other two packs.

- s_pack_ll/lh/hh: the low or high half of src0 in the low half, the
  low or high half of src1 in the high half.
- s_bfm_b64: src0[5:0] ones shifted up by src1[5:0], in 64 bits.
- s_bitreplicate_b64_b32: each bit i of src0 in bits 2i and 2i + 1.

None of them writes SCC. A test runs each on the card and on WARP and
reads both halves of the 64-bit ones. Of the 200 captures, those
refusals are gone and 24 reach a hardware pipeline (17 before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Port of fxceless/victory-fork#146 (67f7ff0) by davi713albano-coder.

image_store packs the channels its dmask enables into consecutive VGPRs
(16-bit halves with d16), in channel order, and writes 0 to the others.
DXIL's typed textureStore writes all four channels, and the host format
drops those past its width, so the disabled ones are written as 0.0.
A store with dmask 0 writes nothing.

Before, only dmask 0xF was taken, and the 0x218 programs' partial
stores were refused ("an image store of some channels", 60 of the 200
descriptions captured in game). Of those 200, 64 now reach a hardware
pipeline (24 before).

The channel order and the zeroed channels follow AMD's MIMG description
as the PR and other RDNA2 translators read it; the test checks this
lowering (10 masks, sparse and d16 ones included) on the host, not the
console's hardware. Adapted here: the test's HostShader takes the two
fields this tree adds.

Co-Authored-By: Castyan <120135015+Castyan@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
buffer_store_format_x, _xy, _xyz and _d16_x by index were refused ("a
typed buffer store of some channels or at an offset", 19 of the 200
descriptions captured in game: 14 d16_x, 3 x, 2 xy, none at an offset).
They now write the channels they give first and 0 to the others, as
image_store writes the channels its dmask leaves out: a typed UAV store
writes all four channels and the host format drops those past its
width. A store at an offset is still refused, with its own message.

A test stores 1 to 4 channels and d16_x by index into a typed RGBA16F
buffer on the card and on WARP and reads all four back. Of the 200
captures, 78 now reach a hardware pipeline (64 before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v_ldexp_f32 (src0 * 2^src1, src1 a signed integer) was refused by name
in 10 of the 200 descriptions captured in game. It is now three
multiplies by powers of two that each have a normal float form
(exponents -126 to 127), the exponent first clamped to -378..381: that
covers every exponent that can take a float to or from zero, a denormal
or infinity, and each product is exact until the last, which rounds as
a single ldexp would.

A test runs it on the card and on WARP against f64 references, past
both ends of the range (a result below the normal range may be flushed
to zero). Of the 200 captures, 88 now reach a hardware pipeline (78
before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The second game run's captures (200 descriptions with their signatures,
including those that do not translate) show where a directly indexed
heap goes. Every program with CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED in its
signature has one user SGPR more than its root parameters take (61),
every one with both heap flags two (43), and no other program has any.
The first is the view heap: those programs add an offset to it, load a
buffer descriptor there (s_load_dwordx4) and read its stride. They were
refused as "an address with two computed terms" or "an address not from
a root parameter".

The view heap is now a ResourceHeap parameter in the dword past the
root parameters, then the sampler heap a SamplerHeap one, when the
program's user SGPRs are exactly that many more; otherwise they stay
unnamed, as before. The translator already reads descriptors from a
ResourceHeap parameter at an index it computes.

Of those 200 captures, the "two computed terms" refusals are gone; the
programs now stop further on, mostly at "an address with an untracked
high half" (44). The 200 earlier captures replay as before (88 reach a
hardware pipeline).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 0x218 programs that read their view heap add an index to the
heap's dword and make the high half with the carry of that sum read as
a number: s_add_u32 s40, s10, s18 then s_add_u32 s41, 0, src_scc. The
tracker took a carry into the high half only as s_addc_u32 x, 0, and
refused these as "an address with an untracked high half" (44 of the
second run's 200 captures).

s_add_u32 of x and src_scc is now x plus the carry, as s_addc_u32 x, 0
is (the same shortcut: offsets below 4 GB). A test tracks such a heap
address. Of the second run's 200 captures, 23 now reach a hardware
pipeline (5 before); the first run's 200 replay as before (88).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Before a reduction over LDS or a write by a few lanes, the 0x218
programs set EXEC to fixed lanes: s_bfm_b64 exec, 32, 0 (lanes 0-31),
s_mov_b32 exec_lo, 17 with s_mov_b32 exec_hi, 17 (halves written
apart), s_mov_b32 exec_lo alone after s_mov_b64 exec, -1, and
s_bitreplicate_b64_b32 exec, lit. The structurisation does not follow
these instructions and took the pair as an opaque mask named by its low
dword; lowering then had no number for that dword (EXEC writes are not
lowered as data), asked for its ballot, whose lane bits are the same
opaque mask: "a lane mask whose lanes depend on its own value". Had the
low dword had a number, the opaque mask would have given lanes 32-63
the low half's bits where the halves are written apart.

A mask register pair whose two dwords are each written from constants
alone (s_mov_b32 of an integer inline constant or a literal, s_mov_b64
of an integer inline constant, s_bfm_b64 and s_bitreplicate_b64_b32 of
such 32-bit operands, through scalar moves) is now that constant, both
dwords of it (Atom::Constant), which lowering already tests lane by
lane against the console lane. Anything else stays opaque.

A test sets EXEC those four ways, stores under each and stores EXEC
copied as data, in one console wave of 64: on the RTX 5060 the form
emit chooses for 32-lane waves and the paired form store what the
console's 64 lanes do (WARP's 4-lane waves take neither form).

Replay at 77845b8 -> now (programs reaching a hardware pipeline):
dump-218 23/200 -> 67/200, dump-218-run4 88/200 -> 133/200, none of
those that passed lost. "depend on its own value" goes from 40 + 41 to
1 + 1 (s_pack_ll_b32_b16 exec_lo, 1, 1), "holding lanes elsewhere read
as data" from 10 + 13 to 3 + 6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 0x218 programs still refused with "a lane mask whose lanes depend
on its own value" or "a lane mask holding lanes elsewhere read as data"
set EXEC from constants with instructions the constant mask did not
follow: s_pack_ll_b32_b16 on exec_lo and exec_hi (8 programs),
s_movk_i32 exec_lo (1) and s_brev_b32 exec_lo (2). The pair stayed an
opaque mask. s_pack_lh/hh_b32_b16, not seen in the captures, are the
same few lines and are taken too.

A dword written by s_movk_i32 (its 16-bit immediate, sign-extended),
s_brev_b32 of a constant, or s_pack_ll/lh/hh_b32_b16 of two constants
is now that constant, so such an EXEC pair is an Atom::Constant like
those of the previous commit. Anything else stays opaque.

The test of the previous commit now sets EXEC eight ways, one after
another from s_mov_b64 exec, -1, among them s_pack_ll/lh/hh_b32_b16,
s_movk_i32 with a negative immediate and s_brev_b32 on exec_hi, and
stores under each: on the RTX 5060 the form emit chooses for 32-lane
waves and the paired form store what the console's 64 lanes do. Without
this change it fails ("a constant EXEC taken as an opaque mask").

Replay at 9d793f0 -> now (programs reaching a hardware pipeline):
dump-218 67/200 -> 71/200, dump-218-run4 133/200 -> 140/200, none of
those that passed lost (nor any that passed at 77845b8). "depend on its
own value" goes from 1 + 1 to 0, "holding lanes elsewhere read as data"
from 3 + 6 to 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Inside a whole-wave section, the simulation knows a vector value written
before the section only as each lane's own value. v_readlane_b32 of a
constant lane of such a value took that symbol as is, so the scalar it
reads became the value of every lane's own v, not of the lane read:
v_readlane_b32 s14, v1, 3 with v1 = t + 1 gave each thread t + 1 where
the console gives 4. Such a read is now unknown to the simulation, and
a value made from it leaving the section is refused as a step the
simulation does not follow.

A test reads lane 3 of t + 1 inside a section and stores it from every
thread: on the RTX 5060 the form emit chooses for 32-lane waves stored
1, 2, ..., 64 without this change; with it, no form takes the program.

Replay at 669079e -> now (programs reaching a hardware pipeline):
dump-218 71/200 -> 71/200, dump-218-run4 140/200 -> 140/200, none lost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 0x218 wave64 reductions add lane 0's half to every lane inside the
whole-wave section, so that only lanes 32-63 hold the whole result, and
read lane 63 with v_readlane_b32 after restoring EXEC (and in m133 after
an s_and_saveexec): past the section's end, which the simulation does
not reach. The value the section leaves differs from lane to lane and
has no shape: "a whole-wave section step the simulation does not
follow".

A lane read does not depend on EXEC, and the value it reads is the SSA
value the section wrote. The block's v_readlane_b32 of a constant lane
past the restore, up to the next section, that read a vector value the
section writes are now simulated with it; where the lane read has a
shape (the reduction over every lane), lowering takes it there, in the
same block. Anything else is lowered as before.

A test sums t + 1 over the threads below 40 as the title does, reads
lane 63 after the restore and an s_and_saveexec to the threads below
20, which store it: on the RTX 5060 the form emit chooses for 32-lane
waves and the paired form store the console's 820. Without this change
it is refused ("a whole-wave section step the simulation does not
follow").

Replay at 9335ddf -> now (programs reaching a hardware pipeline):
dump-218 71/200 -> 73/200 (m111, m112), dump-218-run4 140/200 ->
143/200 (m079, m080, m133), none lost (nor any that passed at 77845b8).
m053 and m085 stay refused: their lane 63 is read inside the next
section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 0x218 wave64 programs AND a compare with EXEC (s_and_b64 s, vcc,
exec) and read the SCC it sets as a number: src_scc as an operand
(m020 at 0x100, s_add_u32 s16, src_scc, s16; m008, m127), s_cselect
(m017 at 0x18c) or a carry. On the console that SCC is "some lane of
the 64 has its bit". Lowering gave every value a mask operation writes,
SCC included, as missing, so these programs stopped with "a lane mask
read as data" at the first effect downstream.

Such an SCC is now read through scc_some, which already answered it
for SCC joined with a scalar test: in the paired form the host wave
asks both lanes of each thread; elsewhere only where the result is
held in the lanes running there (new Structured::scc_active: its bit
implies EXEC where it is written, so lanes elsewhere add nothing), two
host waves exchanging their answers where every lane runs that block.
A result with lanes outside EXEC (s_not_b64 inside a branch) stays
refused outside the paired form. Such a read now makes a program keep
the console's lanes (reads_mask_as_data), as a mask read as a number
does.

Two tests on one console wave of 64 threads: SCC of five masks (upper
half alone, none, lower half alone, ...) read by s_cselect_b32, src_scc
and s_addc_u32, and the SCC of s_not_b64 inside a branch, whose set
lanes are all elsewhere. On the RTX 5060 the form emit chooses for
32-lane waves and the paired form store what the console's 64 lanes
give (no 64-lane device here: neither WARP nor the card takes
WaveSize(64)). Without this change both are refused ("a lane mask read
as data").

Replay at 6dbdf24 -> now (programs reaching a hardware pipeline):
dump-218 103/200 -> 120/200 (m017 m020 m022 m034 m056 m078 m095 m133
m136 m137 m165 m180 m181 m182 m184 m198 m199), dump-218-run4 165/200
-> 174/200 (m025 m032 m035 m054 m092 m093 m095 m177 m179), none lost.
m008/m009 (run4 m014/m016), refused before as "an opaque lane mask",
now stop at "a constant buffer's descriptor read as data"; m065/m066
(run4 m044/m045) at "a first-lane read where not every lane runs".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Replay at 6dbdf24 -> now (programs reaching a hardware pipeline):
dump-218 103/200 -> 120/200, dump-218-run4 165/200 -> 174/200, none lost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 0x218 wave64 reductions come two by two in one block: the second
whole-wave section starts right after the first restores EXEC, and its
first step is the v_readlane_b32 of lane 63 of the first one's sum
(m092 at 0x130-0x134: s_or_saveexec_b64 s[14:15], -1, then
v_readlane_b32 s12, v23, 63). That read is inside the next section,
whose simulation knew the first section's result only as each lane's
own value, which a lane read may not take (9335ddf): "a whole-wave
section step the simulation does not follow".

The sections of a block are now simulated in order, each from the
lanes' values the earlier ones left: a lane read does not depend on
EXEC, and those values are the block's own SSA values, which nothing
between the sections changes. A section's shapes stay those of the
values it writes itself.

A test sums t + 1 over the threads below 40 as the title does and reads
lane 63 as the first step of the next section; on the RTX 5060 the form
emit chooses for 32-lane waves and the paired form store the console's
820. Without this change it is refused ("a whole-wave section step the
simulation does not follow").

Replay at 6dbdf24 -> now (programs reaching a hardware pipeline):
dump-218 103/200 -> 106/200 (m092, m126, m167), dump-218-run4 165/200
-> 168/200 (m053, m126, m135), none lost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0x218 m128 leaves its second whole-wave section with `s_mov_b64 exec,
s[12:13]` (lane 0 alone, which stores the result) and never restores
the saved EXEC. With no restore the section had no end, and the program
was refused. Such a section now ends at the first EXEC write that is not
a constant s_mov: the code after it is lowered under that EXEC as
anywhere else.

Replay at 824290d -> now: dump-218 106/200 -> 107/200 (m128),
dump-218-run4 168/200 -> 169/200 (m085), none lost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
run4 0x218 m159, m160 and m162 (0xe8-0x15c) read VCC on the execz edge
of a v_cmpx skip, before any write: `s_orn2 s20, vcc, exec` with EXEC 0,
then `s_not` and EXEC set to the result. There VCC cannot change what any
lane does, but lowering had no value for it and refused the program
("a hardware SGPR input"). VCC is now 0 on entry, as the SGPRs above the
hardware inputs already are.

A test runs that shape for 32- and 64-lane console waves on the RTX 5060
(the form emit chooses for 32-lane hosts, and the paired form) against
the console's result for seven (s0, s1) pairs.

Replay at d61b0da -> now: dump-218 103/200 -> 103/200, dump-218-run4
165/200 -> 168/200 (m159, m160, m162), none lost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants