Repository navigation
Wave64 console programs on GPUs with 32-lane waves only (NVIDIA) - #67
Conversation
LDS is not zeroed between dispatches, so the counter starts from whatever the previous shader left there; when that was 0xFFFFFFFF the 64 old values are 0xFFFFFFFF, 0, 1, …, 62 – correct, but the sorted comparison expected a run without the wrap and failed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ng wave32 halves NVIDIA's D3D12 wave range is 32..32, so a [WaveSize(64)] compute shader is rejected at PSO creation: wave64 compute programs were refused there (their dispatches skipped every frame), and mesh / ES+GS programs ran as two independent halves only when they had no cross-half operation. Now, when the device cannot run 64-lane waves (the same detection as before, `pso::wave32_only_for_device`), each console wave of a wave64 kernel, compute, mesh or ES+GS program runs as two hardware wave32s of the same thread group that exchange through groupshared memory wherever a value has to be the whole wave's: every mask (ballot), v_readlane / v_readfirstlane, ds_bpermute and GLC scalar loads. Both halves then hold the full 64-bit EXEC / VCC and identical SGPRs and take every branch the same way; DPP, ds_swizzle and v_permlane(x)16 stay inside a half and need nothing. One console wave per group meets at group barriers; several (mesh, compute > 64 threads) meet pairwise through double-buffered slots and arrival counters, bounded so that a desynchronised pair degrades instead of hanging the GPU. Hardware threads take console thread ids in the order their waves arrive: NVIDIA does not form waves from consecutive thread indices for 3-D groups (8 x 8 x 4). GPUs with 64-lane waves get byte-identical HLSL for every native translation the test suite makes. Design, hazards and measured cost: docs/wave64-on-wave32.md. The idea of a groupshared rendezvous kept in the LDS tail, and the finding that NVIDIA rejects [WaveSize(64)], come from PR #33 (ElHombreAlex); the protocol here is new (double-buffered slots, counted arrivals, barriers where they are legal). Tests: the instruction tests run on 32-lane GPUs too (`runner::options`), and the kernel runner fails when the two halves end with different SGPRs; new tests for cross-half masks, lane reads and scalar loads, for four diverging console waves per group in 1-D and 3-D groups, mesh form checks, and an ignored benchmark (`bench_split_wave64`). Co-Authored-By: Claude Opus 5.5 <[email protected]>
… any more `xcl_logical_wave64` (two independent halves, each with only its own mask word) was set by split geometry and split mesh translation, which now use the exchanging split form. It stayed `false` everywhere, so removing its branches from `ballot` / `rla` changes no generated shader's behaviour; the hazard list's doc says what it is still good for. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The split wave64 form needs [WaveSize(32)]; WARP takes neither 32 nor 64, so the instruction tests now skip there (`runner::wave64_programs_supported`) instead of failing at PSO creation, and the two geometry tests that always ran the [WaveSize(32)] form use the same check (`gpu_ready_wave32` is gone). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Overlap with #70, #71 and #72, to make the choice easier for the reviewer. This PR and @gefydev's #70 / #71 / #72 solve the same problem: wave64 console programs on GPUs with 32-lane waves only (NVIDIA). They conflict ( How they differ
Test suite: RTX 5070 Ti, driver 32.0.16.2114. Each column is merged onto current
Merge options
Both sets build and pass together with the other open PRs that touch the same files: |
|
Tested this branch locally on Windows — all 19 dedicated unit tests for Key architectural strengths verified:
Excellent work solving Wave64 semantics for 32-lane architectures. |
…oups The console forms a group's waves from consecutive thread indices; the PC driver need not. Measured on the RX 9070 (RDNA4): an 8 x 8 (x 4) or 16 x 4 group is laid out in 2 x 2 quads (lanes 0, 1, 4, 5, 8, 9 ... hold SV_GroupIndex 0, 1, 2, 3, ...), 1-D groups in order – so every native translation of a 2-D / 3-D console compute program read the wrong lanes with DPP, readlane, ds_bpermute, mbcnt (prefix sums, compaction). #67 handles this for the split form; now the native form does the same: each hardware wave takes the next 32 / 64 console threads as it arrives (a groupshared counter – the top LDS word while the waves take their threads when the program uses all 32 KB), lane l the l-th of them. 1-D groups (and VS, PS, mesh, geometry) keep their HLSL. gpu_split_wave64_waves_diverge (#67) failed natively on AMD for 8 x 8 x 4 and passes now.
…U too RDNA runs both wave sizes, so the NVIDIA path (#67) can be checked on AMD: pipelines (wave32_only_for_device) and the test runner take the split form. With it the workspace tests pass on the RX 9070, retail shader pack tests included.
|
Merged. Checked on an RX 9070 (RDNA4): One thing it found on AMD: |
Conflict with #67 resolved: the in-memory shader cache sits in console_to_dxil_for and its key has split_wave64 (the split and native forms are different DXIL).
The f64 NEG source modifier was emitted as -x and ABS as abs(x). DXIL has no fneg: DXC writes -x as fsub -0.0, x, and IEEE leaves the sign of a NaN result open, so a negated NaN kept its sign on NVIDIA (v_frexp_mant_f64 with NEG on 0x7FF8000000000001). The hardware modifiers only flip or clear the sign bit; they are now that, on the high dword. Cherry-picked from #72 (ec446ec) without #71, which #67 superseded; the test gates on gpu_ready (#67: wave64 programs run split on 32-lane GPUs).
Conflict with #67 resolved: main's split-aware LDS slot after the address read stays; the addtid forms also keep clear of the split wave64 exchange (XCL_X_LDS_TOP).
In the split wave64 form (#67) every mask write exchanges the two wave32 halves' ballots. A mask whose readers take only the reading lane's own bit (v_cndmask_b32's selector, the carry-in of v_add_co_ci / v_sub(rev)_co_ci) needs no exchange: xcl_x_ballot_local gives the half's own word. x64_masks.rs finds them with a backward liveness pass over the SGPRs. A register is whole-live when some path may read its whole value before it is written again. The rules follow the emitter, not only the operand tables: s_cmov*, s_addk, s_mulk, s_bitset*, s_movreld and SDWA compares into their SDST are not overwrites; s_movrels reads every register from its base; SDWA scalar sources and SMEM register offsets are reads; EXEC, indirect jumps, the kernel runner's end and loop exits through LOOP_GUARD count as whole reads (loop ranges from the translator's loop_ranges, now shared). Masks into NULL or constant false are never exchanged. Geometry mode keeps its exchanges. XCL_X64_ALL_MASKS=1 exchanges every mask, for comparison. bench_split_wave64 now counts each iteration's exchanges and times GPU work only (runner::dispatch_timed: timestamps, median of 9; before, the wall time of a whole dispatch with pipeline creation and copies). RTX 3090, all masks (3 runs) vs default (5 runs), split / wave32: - mask only: 1.64-1.68x -> 1.04-1.11x (one console wave per group), 3.90-4.14x -> 1.07-1.16x (four, counter-paired) - with a v_readfirstlane: 1.99-2.02x -> 1.74-1.81x, 6.45-6.64x -> 4.09-4.34x The benchmark's mask is exactly the kind the pass keeps local: it shows the exchange gone, not how much real shaders gain. Tests: 16 for the analysis, gpu_split_wave64_lane_local_masks, gpu_split_wave64_masks_read_whole_after_partial_writes (one kernel per rule; the halves' SGPRs differ without it) and gpu_split_wave64_local_and_exchanged_masks_in_diverging_waves (counter-paired, waves on different paths). Workspace, release, RTX 3090: 459 passed, 0 failed; XCL_WAVE64_SPIN=1: 224 passed. Not checked: real compute shaders (Minecraft's 273 wave64 programs as compute have 38 mask writes, all local), AMD. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pelineX) are UAV barriers FlushGpuCacheRangeX and FlushShaderCacheRangeX of the newer list layout were answered with nothing. They are how a title orders a pass behind the one that wrote what it reads: a retail title calls them thousands of times a minute, and its compute passes (the ones that write indirect arguments and the ones that read them) had no order there. FlushPipelineX (xcl-dev#67, newer layout xcl-dev#69) as well; at xcl-dev#69 a newer-layout title's call ran Write32BitValueBottomOfPipeX with the flags as the address. The PC has no ranges of caches: a UAV barrier for all resources, on direct and compute lists. Test: cache_flushes_are_uav_barriers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Wave64 console programs on GPUs with 32-lane waves only (NVIDIA)
NVIDIA's D3D12 wave range is 32..32, so
[WaveSize(64)]shaders are rejected: wave64 compute pipelines were refused (their dispatches skipped every frame) and mesh / ES+GS programs ran as independent halves without cross-half operations (#14, #39). (An earlier version of this text guessed that skipped compute work caused Minecraft's flicker on NVIDIA. It doesn't: Minecraft dispatches no compute work at all. The flicker was lost descriptor heaps, fixed in #84.)On such a GPU (same detection,
pso::wave32_only_for_device) each console wave of a wave64 kernel / compute / mesh / ES+GS program now runs as two hardware wave32s of one thread group that exchange through groupshared wherever a value must be whole-wave: masks,v_readlane/v_readfirstlane,ds_bpermute, GLC scalar loads. Both halves hold identical EXEC / VCC / SGPRs and take the same branches, so the recompiler's uniform-branch assumption still holds; DPP / swizzle / permlane stay within a half. One console wave per group meets at group barriers; several meet pairwise through double-buffered slots and arrival counters (bounded: a fault degrades the output, never hangs). Hardware waves take console thread ids as they arrive, because NVIDIA does not form waves from consecutiveSV_GroupIndexfor 3-D groups (8×8×4). Design, hazards, cost:docs/wave64-on-wave32.md.SKIPPED …: no wave64lines: 39 on main, 2 here. The two left:gpu_wave32_program_in_wave64_hardware, which needs 64-lane hardware, and the native-wave64 half ofgpu_geometry_wave32_prefix_count_over_a_mask(its split half runs). The runner checks that both halves end with the same SGPRs;XCL_WAVE64_SPIN=1(counter variant everywhere) passes too. New tests: cross-half ops, four diverging console waves per group in 1-D / 3-D groups, mesh form;bench_split_wave64(ignored).bench_split_wave64, worst case, one mask exchange per 8 instructions): 1.3× with one console wave per group, ~5× with four (waiting waves keep issuing). Real shaders do far more work per mask. Next step: no exchange for masks used only lane by lane (v_cmp+v_cndmask).ds_add_rtntest now allows the old values to wrap around 0xFFFFFFFF.[WaveSize(64)]finding come from WIP: Experimental FidelityFX Xbox GPU compatibility — Wave64 emulation and NVIDIA support #33 (@ElHombreAlex). The protocol here is new (double-buffered slots, arrival counters, barriers where legal). Expand bounded GPU compatibility coverage #35's mesh lowering is separate and untouched.The UAV-barrier and
v_fract_f32fixes found during this work are in a separate PR: #68.Not checked: retail shaders (no shader pack on this machine). Minecraft exercises none of it (0 compute dispatches, VS / PS only); with this PR (and #84, #86) its menu runs at 60 fps without flicker and a world loads.
🤖 Generated with Claude Code