Repository navigation
Conversation
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
I read the ordering argument through and it holds. With a meet before every access, a half can be at most one access ahead of the other, and the
Not run here; read from the diff, plus the timing from #505. AI-assisted (Claude Code). |
RTX 4090 (Ada, 32-lane waves) at
|
| run | without the meetings | with them |
|---|---|---|
gpu_split_wave64_lds_follows_instruction_order, spin form (default) |
0 of 20; 50,028 to 51,840 of 65,536 threads wrong | 20 of 20 (both group sizes) |
the same, XCL_WAVE64_SPIN=0 |
0 of 20; 37,152 to 38,208 of 65,536 | 20 of 20 (both group sizes) |
| 256-thread groups only, spin form | 0 of 20; 185,960 to 193,728 of 262,144 | in the rows above |
256-thread groups only, XCL_WAVE64_SPIN=0 |
0 of 20; 189,032 to 195,712 of 262,144 | in the rows above |
filter split_wave64 -- --include-ignored --test-threads=4 (9 tests, one process) |
0 of 20: the two new tests fail, the other 7 pass | 20 of 20 |
Wrong values in the quoted examples: 0 (read before the other half's write) and the overwriting values (3 << 28 | n, 4 << 28 | n). In 2 of the 20 filter runs, two early reads returned 0x1 and 0x9FF, which this program never writes (presumably LDS left by another test in the same process).
GPU time of a 16,384-group dispatch, median of 9 (runner::dispatch_timed, from a local ignored test), round 1 / round 2:
| groups | form | without the meetings | with them |
|---|---|---|---|
| 64 threads | spin | 0.0236 / 0.0236 ms | 0.0563 / 0.0553 ms (2.4×) |
| 64 threads | XCL_WAVE64_SPIN=0 |
0.0205 / 0.0205 ms | 0.0225 / 0.0215 ms |
| 256 threads | spin | 0.0307 / 0.0297 ms | 0.0676 / 0.0676 ms (2.2–2.3×) |
| 256 threads | XCL_WAVE64_SPIN=0 |
0.0307 / 0.0297 ms | 0.0676 / 0.0676 ms |
On this GPU the barrier form avoids the cost only for the 64-thread groups: the 256-thread groups take the same time with and without XCL_WAVE64_SPIN=0, so for this program they pay about 2.3× either way.
Not tested
- A GPU with 64-lane waves,
XCL_SPLIT_WAVE64=1, and Linux / RADV (the Recompiler: split wave64 spin loops poll with a compare-exchange, not an add of 0 (#847) #1244 case above). - Mesh and kernel mode LDS programs on the GPU, a retail title, and release builds (the timings are GPU timestamps only).
- The read-after-read reduction suggested above.
AI use
- Claude Code (Claude Opus 5.5) ran the tests, made the local changes for the "without" column and the timing test, and drafted this comment.
|
Retail run on an RTX 5080 (32-lane waves): Tested
Not tested
AI use
|
|
AMD run with 64-lane waves, which the other reports here don't cover. Updated for head Tested: pass, head
Not tested: AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report. |
|
Thanks all. @teidenzero's matrix (RTX 4090) and @DarkPanda69's RX 9070 XT run (native wave64 and @upipibi, on your three points:
AI use: Claude Code (Claude Opus 5.5) worked through the read-after-read argument and wrote this reply. |
|
Tested this on real hardware (NVIDIA RTX 3060 12 GB, driver
Putting an unconditional |
|
@Rodriguerra thanks, that is a serious result and I'm treating it as one. I've moved this PR to draft until it is understood. A few details would help me reproduce it:
One note on scope: the meetings are only emitted for console wave64 programs in the split form ( What I'll do: our RTX 3080 now gets into world loading, so I'll run AI use: Claude Code (Claude Opus 5.5) helped read the report and write this reply. |
|
RTX 3080 (10 GB, driver 610.88), retail title into the world: Tree:
In all three the GPU sits at 100 % from about 122-126 s, with video memory at the card's 9.9 GB, until the hang or the watchdog: the same GPU-side stall about 35-55 s after So far that is one 3080 against one 3060 with an unknown tree, so I'm keeping this in draft until @Rodriguerra's details are in. Meanwhile I'm testing @upipibi's read-after-read reduction and an Not tested: more than one run per arm; the RTX 3060; Linux/RADV. AI use: Claude Code (Claude Opus 5.5) ran the three runs on my machine through a scripted runner and wrote this comment. |
|
Independent Kernel and Mesh LDS execution validation of Tested — Kernel
All runs:0 ignored, no skips/timeouts. Negative runs exit101 on the output assertion, positives exit0. The control removes only those six calls from the translated HLSL before DXC, preserving the rest of the emitted program and CPU expectations; it does not remove other exchange mechanisms or alter the runtime source. Both selected adapter names and split status print in the logs. Command, each variant in a fresh process: Set Tested — Mesh Each table entry is one fresh-process test running both group sizes. Wrong-record/pixel totals are out of 384/6.
No skips or timeouts. NVIDIA omission controls exit101 on the final output assertion; all other Mesh runs exit0. AMD's Mesh omission controls still pass: this fixture demonstrates correctness on that adapter, but does not detect the omitted-meeting fault there. No inference that AMD never needs these meetings. The 128-thread split case always emits spin, including when Command: Same environment matrix as Kernel above. Final Mesh source identical across all nine reported runs; all 221 source hashes match Windows. Reverse-apply check and Correction to my earlier coordination note: the AMD iGPU does support this native mesh path. Actual adapter-selected execution above replaces that mistaken capability assumption. Windows10 Home19045, Ryzen7 7800X3D, RTX3090 driver591.74, AMD Radeon integrated32.0.21030.2001; Rust1.98.1 MSVC, DXC/dxil1.8.2502.11, Agility1.620.2, debug. SSH Session0. No proprietary inputs. Not tested AI use Complete Kernel + Mesh fixture patch against77a8190 (130 added lines)diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs
index 44a4bb7..93d7cd2 100644
--- a/crates/xcl/src/gpu/recomp/tests.rs
+++ b/crates/xcl/src/gpu/recomp/tests.rs
@@ -7553,3 +7553,133 @@ fn fspx_containers_translate_and_compile() {
println!("FSPX: {ok} / {n} translated and compiled");
assert_eq!(ok, n);
}
+
+/// Local Kernel-mode counterpart of the PR1252 Compute test; run each variant in a fresh process.
+#[test]
+fn gpu_kernel_split_wave64_lds_order_probe() {
+ if !gpu_ready() { return; }
+ let p = lds_order_program();
+ let options = on_gpu(Options { mode: Mode::Kernel, wave64: true, ..Default::default() });
+ let split = options.split_wave64;
+ let mut t = translate(&p, &options).unwrap();
+ assert!(t.complete(), "{:?}", t.unsupported_why);
+ let meets = t.hlsl.matches("xcl_x_meet();").count();
+ assert_eq!(meets, if split { 6 } else { 0 });
+ let omit = std::env::var_os("XCL_PROBE_OMIT_LDS_MEETS").is_some();
+ if omit {
+ assert!(split, "negative control requires split translation");
+ t.hlsl = t.hlsl.replace("xcl_x_meet();", "");
+ }
+ println!("adapter={} split={split} spin={} meets={meets} omit={omit}", runner::adapter().unwrap(),
+ std::env::var("XCL_WAVE64_SPIN").unwrap_or_else(|_| "default".into()));
+ let dxil = super::dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).unwrap();
+ let mut failures = Vec::new();
+ // Tags vary across runs so an earlier dispatch's LDS contents cannot satisfy the oracle.
+ for tag in [0usize, 1, 7, 17, 31, 63, 127, 1023] {
+ let mut st = KernelState::default();
+ st.sgpr[0] = 0x100;
+ st.sgpr[1] = 6;
+ st.sgpr[4] = tag as u32;
+ for lane in 0..64 { st.vgpr[lane][0] = lane as u32; }
+ let mut mem: Vec<u32> = p.chunks_exact(4).map(|b| u32::from_le_bytes(b.try_into().unwrap())).collect();
+ mem.resize((0x100 + (tag + 1) * 64 * 8) / 4, 0);
+ let out = runner::run(&dxil, &st, &mem).unwrap();
+ for lane in 0..64 {
+ let other = (tag * 64 + (lane ^ 32)) as u32;
+ let want = if lane < 32 { [0x1000_0000 | other, 0] } else { [0, 0x2000_0000 | other] };
+ let at = (0x100 + (tag * 64 + lane) * 8) / 4;
+ if out.vgpr[lane][4..6] != want || out.mem[at..at + 2] != want {
+ failures.push(format!("tag={tag} lane={lane} vgpr={:x?} memory={:x?} want={want:x?}",
+ &out.vgpr[lane][4..6], &out.mem[at..at + 2]));
+ }
+ }
+ }
+ println!("dispatches=8 checked_lanes=512 mismatched_lanes={}", failures.len());
+ assert!(failures.is_empty(), "{} wrong lanes: {}", failures.len(), failures[..failures.len().min(4)].join("; "));
+}
+
+/// Local two-pass Mesh execution check for PR1252's LDS ordering, including rendered pixels.
+#[test]
+fn gpu_mesh_split_wave64_lds_order_probe() {
+ if !gpu_ready() || !mesh_ready() { return; }
+ use super::{dxc, mesh_passthrough, MsInterface, MESH_HEADER};
+ let sig = |name: &str, sv, reg, ty| crate::gpu::dxbc::SigElement {
+ name: name.into(), index: 0, system_value: sv, component_type: ty,
+ register: reg, mask: 0xF, rw_mask: 0xF, stream: 0,
+ };
+ let mut wrong_vertices = 0;
+ let mut wrong_pixels = 0;
+ let omit = std::env::var_os("XCL_PROBE_OMIT_LDS_MEETS").is_some();
+ for threads in [64u32, 128] {
+ let shift = threads.trailing_zeros() as u64;
+ let ms = MsInterface { outputs: vec![sig("SV_Position", 1, 0, 3), sig("TEXCOORD", 0, 1, 1)],
+ threads, max_vertices: threads, max_primitives: 1 };
+ let mut code = prog(&[
+ ("S_BFE_U32", "ENC_SOP2", &[("SDST", 6), ("SSRC0", 3), ("SSRC1", 255)], Some(0x40018)),
+ ("V_MBCNT_LO_U32_B32", "ENC_VOP3", &[("VDST", 0), ("SRC0", 193), ("SRC1", 128)], None),
+ ("V_MBCNT_HI_U32_B32", "ENC_VOP3", &[("VDST", 0), ("SRC0", 193), ("SRC1", V)], None),
+ ("V_LSHL_ADD_U32", "ENC_VOP3", &[("VDST", 0), ("SRC0", 6), ("SRC1", 134), ("SRC2", V)], None),
+ ("V_READFIRSTLANE_B32", "ENC_VOP1", &[("VDST", 4), ("SRC0", V + 5)], None),
+ ("S_LSHR_B32", "ENC_SOP2", &[("SDST", 4), ("SSRC0", 4), ("SSRC1", 128 + shift)], None),
+ ("V_MOV_B32", "ENC_VOP1", &[("VDST", 5), ("SRC0", 128)], None), // after saving Mesh v5 group input, seed LDS result as in Kernel
+
+ ("S_MOV_B32", "ENC_SOP1", &[("SDST", 1), ("SSRC0", 128 + shift)], None),
+ ("S_MOV_B32", "ENC_SOP1", &[("SDST", 0), ("SSRC0", 255)], Some(0x2000)),
+ ("S_MOV_B32", "ENC_SOP1", &[("SDST", 124), ("SSRC0", 255)], Some(1 << 12 | threads)),
+ ("S_SENDMSG", "ENC_SOPP", &[("SIMM16", 9)], None),
+ ]);
+ code.truncate(code.len() - 4); // replace END with the PR's LDS program
+ let lds = lds_order_program();
+ code.extend_from_slice(&lds[..lds.len() - 4]);
+ code.extend(prog(&[
+ ("BUFFER_LOAD_DWORDX4", "ENC_MUBUF", &[("VDATA", 10), ("VADDR", 0), ("SRSRC", 4), ("SOFFSET", 128), ("IDXEN", 1)], None),
+ ("V_CVT_F32_U32", "ENC_VOP1", &[("VDST", 20), ("SRC0", 4)], None),
+ ("V_ADD_F32", "ENC_VOP2", &[("VDST", 10), ("SRC0", V + 20), ("VSRC1", 10)], None),
+ ("EXP", "ENC_EXP", &[("TGT", 12), ("EN", 15), ("VSRC0", 10), ("VSRC1", 11), ("VSRC2", 12), ("VSRC3", 13), ("DONE", 1)], None),
+ ("EXP", "ENC_EXP", &[("TGT", 32), ("EN", 3), ("VSRC0", 4), ("VSRC1", 5)], None),
+ ("V_CMPX_EQ_U32", "ENC_VOPC", &[("SRC0", 128), ("VSRC1", 0)], None),
+ ("V_MOV_B32", "ENC_VOP1", &[("VDST", 21), ("SRC0", 255)], Some(1 << 10 | 2 << 20)),
+ ("EXP", "ENC_EXP", &[("TGT", 20), ("EN", 1), ("VSRC0", 21), ("DONE", 1)], None),
+ ]));
+ let options = on_gpu(Options { mode: Mode::Mesh(ms.clone()), wave64: true, ..Default::default() });
+ let mut t = translate(&code, &options).unwrap();
+ assert!(t.complete(), "{:?}", t.unsupported_why);
+ assert_eq!(t.hlsl.matches("xcl_x_meet();").count(), if options.split_wave64 { 6 } else { 0 });
+ let spin = t.hlsl.contains("#define XCL_X_SPIN 1");
+ if omit {
+ assert!(options.split_wave64);
+ t.hlsl = t.hlsl.replace("xcl_x_meet();", "");
+ }
+ println!("adapter={} threads={threads} split={} emitted_spin={spin} omit={omit}", runner::adapter().unwrap(), options.split_wave64);
+ let cs = dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).unwrap();
+ let msb = dxc::compile(&mesh_passthrough(&ms), "main", "ms_6_6", &[]).unwrap();
+ let ps = dxc::compile("struct V { float4 pos : SV_Position; nointerpolation uint4 p0 : TEXCOORD0; }; float4 main(V v) : SV_Target0 { return (v.p0.x & 0xf0000000u) == 0x10000000u ? float4(0,1,0,1) : float4(1,0,0,1); }", "main", "ps_6_6", &[]).unwrap();
+ let mut mem = vec![0u32; 4096];
+ for i in 0..threads as usize {
+ let xy = [(-1.0f32, -1.0f32), (-1.0, 1.0), (0.0, -1.0)][i.min(2)];
+ mem[0x40 + i * 4..0x40 + i * 4 + 4].copy_from_slice(&[f(xy.0), f(xy.1), f(0.0), f(1.0)]);
+ }
+ let mut sg = vec![0u32; 128];
+ sg[16..20].copy_from_slice(&[0x100, 16 << 16, threads, 0]);
+ let (px, records) = runner::mesh_draw(&cs, &msb, &ps, 2, ms.record_dwords(), &sg, &mem, 32, [-1.0; 4]).unwrap();
+ let mut bad = 0;
+ for g in 0..2usize {
+ let r = &records[g * ms.record_dwords()..(g + 1) * ms.record_dwords()];
+ assert_eq!((r[0], r[1]), (threads, 1));
+ assert_eq!(r[MESH_HEADER + threads as usize * ms.vert_dwords()], 1 << 10 | 2 << 20);
+ for lane in 0..threads as usize {
+ let other = (g * threads as usize + (lane ^ 32)) as u32;
+ let want = if lane % 64 < 32 { [0x1000_0000 | other, 0] } else { [0, 0x2000_0000 | other] };
+ let at = MESH_HEADER + lane * ms.vert_dwords() + 4;
+ if r[at..at + 2] != want { bad += 1; }
+ }
+ }
+ let samples = [px[29 * 32 + 3], px[29 * 32 + 19], px[3 * 32 + 29]];
+ let want = [[0.0, 1.0, 0.0, 1.0], [0.0, 1.0, 0.0, 1.0], [-1.0; 4]];
+ let pixels = samples.iter().zip(want).filter(|(a, b)| **a != *b).count();
+ println!("vertices_checked={} wrong_vertices={bad} pixel_samples={samples:?} wrong_pixels={pixels}", threads * 2);
+ wrong_vertices += bad;
+ wrong_pixels += pixels;
+ }
+ assert_eq!((wrong_vertices, wrong_pixels), (0, 0), "LDS order must reach the mesh records and pixels");
+} |
|
Tested exact #1252 at The Windows MSVC release Matched title runs in both modes accepted the scripted A input and reached loading artwork. Spin recorded 2,688 presents and exited through a title null-write path. Barrier mode recorded 2,431 presents and reached the title GPU watchdog. Both had zero storage failures, logged bind timeouts, device removals and kernel GPU faults. The visible milestone stayed at loading. OpenAI Codex with GPT-6.2-Sol high prepared the local build, ran the tests and wrote this report. |
|
Retail numbers for two of the Not tested lines: how many programs of the retail title this touches, and what the per-basic-block tracker you mention as a follow-up saves. Counts only, from the retail 1.0.2.1 pack, Which programs (
Meetings in the split form, static (the 370 wave64 compute and mesh programs with LDS accesses, all fully translated, 4 memory windows):
The median program has 16 accesses. The largest has 417, and the tracker still gives it 405 meetings. So the tracker removes about a third statically, not an order of magnitude. I have no per-frame count, so I cannot say whether it would change the RTX 3060 result. The tracker is about 40 lines in Not tested
AI use
|
The meeting before every LDS access (previous commit) made a heavy-LDS world stall on an RTX 3060 (PR xcl-dev#1252). Two cases need no meeting: - a read right after a read in the same basic block (two reads need no order; the meeting before the run's first read orders it after the other half's earlier writes, and the next write's meeting waits for this half's reads); - an access when an exchange (ballot, readlane, readfirstlane, bpermute, coherent scalar load) lies between it and the block's previous LDS access: the exchange is a meeting. A mask kept in its half (xcl_x_ballot_local) is no exchange. A block's first access, every write / atomic and a read after a write still meet, so for any two accesses of the stream, one a write, the halves meet between them. Em::new takes the block starts (the branch leaders), so no caller can elide across blocks by leaving them out. Meetings: lds_order_program stays at 6 (every access is a write or a read after a write); the new lds_read_run_program (2 writes, 4 reads, 2 writes) goes from 8 to 5, and to 3 with an exchange after the writes and after the reads. split_wave64_meets_once_per_read_run, ..._lds_local_mask_is_no_meeting and ..._lds_meets_at_loop_head check the rule without a GPU (they fail with a local mask counted as a meeting or without the block-start reset); gpu_split_wave64_lds_read_run_follows_instruction_order checks on the GPU that the reads without a meeting see the other half's writes before the run and not those after it (64 / 256-thread groups, with meetings and with exchanges). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A switch to compare a title with and without the split wave64 meetings before LDS accesses (the RTX 3060 report on PR xcl-dev#1252). Default on: the meetings are a correctness fix. Set, it bypasses the shader caches like XCL_WAVE64_SPIN; unset, the HLSL is unchanged. With it at 0 the LDS order tests fail as expected (no meetings; the GPU tests read out of order), which shows the switch takes effect. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Pushed two follow-up commits (description updated with the counts):
RTX 3080, in the world: the head behaves like @Rodriguerra, if you can, one run of your RTX 3060 setup at this head with and without AI use: Claude Code (Claude Opus 5.5) wrote the commits after an Opus review, ran the 3080 runs on my machine and wrote this. |
|
@erickbobd thanks, those counts fill two of the Not tested lines (351 wave64 compute + 5 mesh programs with LDS; 11,127 meetings statically). The head I pushed an hour ago ( AI use: Claude Code (Claude Opus 5.5) compared the two rules and wrote this. |
|
@not-rex the census on
So the exchange rule leaves out 252 more meetings than the tracker (3.6 % of its count), and −39.8 % against one per access in all. Two programs need no LDS meeting at all under it. The largest program, with 417 accesses, goes to 404. Static counts only: nothing on per-frame counts or timing. The bases differ ( AI use: Claude Code (Claude Opus 5.5) ran the census and wrote this comment. |
|
@not-rex A/B of the new head on another NVIDIA card, since you asked for one before taking this out of draft. RTX 3070 Ti 8 GB (driver 621.24), Ryzen 9 7900X, 32 GB, Windows 11 26300. Tree: main c160d86 + #640 + #1428 + #1323 + this PR at 2473e2f (merged cleanly), plus a local 2-line patch so the #1323 report also runs on device removal (in the zip). Env: XCL_PAGE_BUDGET_MB=3072 XCL_PSO_WAIT_MS=50 XCL_ACTIVITY=1 XCL_NETWORK=0 XCL_PRESS_A_AT=25 XCL_RUN_SECONDS=300 XCL_GPU_CULPRIT=1. Title: the retail build from #675, story load.
Both runs hang in the same window as without this PR (my earlier runs on #675: 131 s and 140 s). In both, the #1323 report says Run 1's dump: all 97 warps on the GPU are in one compute program. Its Aftermath hash matches a 121,380 B DXIL in the cache. That is between the sizes I got for the same program without meetings (120,060 B) and with the first form of this PR (123,752 B, 77a8190), so it is very likely the same program with the reduced meetings. In the first form it was also the only hung program (40 and 28 warps). So on this card neither the meetings nor leaving them out change the hang: it happens with or without them. For this title the meetings don't look like the cause, and they don't fix it either. Logs (user name removed) + the local patch: gta6-1252b.zip AI use: Claude Code (Claude Opus 5.5) ran the tests, read the logs and the Aftermath dump, and wrote this; I checked it before posting. |
|
@qcdaark thanks, that's the A/B I was hoping for. With my RTX 3080 runs it makes two NVIDIA cards where the head behaves like AI use: Claude Code (Claude Opus 5.5) wrote this. |
|
One more data point on the RTX 3060 report above: its allocator signature appears on plain AI use: Claude Code (Claude Opus 5.5) ran the run on my machine and wrote this. |
On a 32-lane GPU a console wave64 program runs as two 32-lane halves. The split form orders cross-lane exchanges between the halves but not LDS accesses, so a half could read LDS before the other half's earlier write (or after its later one) landed. The new GPU test gpu_split_wave64_lds_follows_instruction_order (upper half writes, lower half reads, and the reverse; 1,024 groups) failed 60 of 60 runs on an RTX 5070 Ti (26,048-50,688 of 65,536 threads wrong, in the spin form, with XCL_WAVE64_SPIN=0, and under load) and passed 60 of 60 with this change. Those runs were of its first form, groups of one console wave. It now also runs groups of four (256 threads, the counter-paired form): without the meetings 237,824-239,936 of 262,144 threads were wrong there in 5 of 5 runs; with them the split_wave64 tests pass 5 of 5 runs. The halves now meet (xcl_x_meet(), nothing exchanged) before each LDS access in kernel / compute / mesh mode, once the access is known to be translated. The meeting orders instructions, not the lanes of one instruction. Cost: one exchange per LDS instruction on 32-lane GPUs; the test program goes from 1 exchange to 7 (spin form 0.046 -> 0.120 ms for 16,384 groups, barrier form unchanged). Native wave64 HLSL is unchanged. docs/wave64-on-wave32.md states the rule. split_wave64_meets_before_each_lds_access checks the emitted HLSL without a GPU: six meetings for the test program in the split form, none natively, in a wave32 program or for an access that is not translated (GDS). Assisted-by: Claude Code (Claude Fable 5.2)
The meeting before every LDS access (previous commit) made a heavy-LDS world stall on an RTX 3060 (PR xcl-dev#1252). Two cases need no meeting: - a read right after a read in the same basic block (two reads need no order; the meeting before the run's first read orders it after the other half's earlier writes, and the next write's meeting waits for this half's reads); - an access when an exchange (ballot, readlane, readfirstlane, bpermute, coherent scalar load) lies between it and the block's previous LDS access: the exchange is a meeting. A mask kept in its half (xcl_x_ballot_local) is no exchange. A block's first access, every write / atomic and a read after a write still meet, so for any two accesses of the stream, one a write, the halves meet between them. Em::new takes the block starts (the branch leaders), so no caller can elide across blocks by leaving them out. Meetings: lds_order_program stays at 6 (every access is a write or a read after a write); the new lds_read_run_program (2 writes, 4 reads, 2 writes) goes from 8 to 5, and to 3 with an exchange after the writes and after the reads. split_wave64_meets_once_per_read_run, ..._lds_local_mask_is_no_meeting and ..._lds_meets_at_loop_head check the rule without a GPU (they fail with a local mask counted as a meeting or without the block-start reset); gpu_split_wave64_lds_read_run_follows_instruction_order checks on the GPU that the reads without a meeting see the other half's writes before the run and not those after it (64 / 256-thread groups, with meetings and with exchanges). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A switch to compare a title with and without the split wave64 meetings before LDS accesses (the RTX 3060 report on PR xcl-dev#1252). Default on: the meetings are a correctness fix. Set, it bypasses the shader caches like XCL_WAVE64_SPIN; unset, the HLSL is unchanged. With it at 0 the LDS order tests fail as expected (no meetings; the GPU tests read out of order), which shows the switch takes effect. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2473e2f to
0141ee9
Compare
|
Tested Independent native Windows run at clean detached PR #1252 head
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
& 'L:/XclTooling/verify-pr1523-1362129-t3-cf2e05e7/target/debug/build/xcl/97fdf2b9ff8e1482/out/xcl-97fdf2b9ff8e1482.exe' --exact gpu::recomp::tests::gpu_split_wave64_lds_follows_instruction_order --nocapture --test-threads=1
}1 passed, 0 failed, 0 ignored, 0 GPU skips in 0.59 s. Libtest filtered out 1,084 other tests. The fixture and mutex wrapper exited 0, and the executable digest matched before waiting, inside the mutex, and after exit. The HLSL/DXC split-wave64 fixture dispatched 1,024 groups of 64 threads and 1,024 groups of 256 threads. All 327,680 two-word comparisons matched the expected cross-half LDS readback. Not tested Other LDS or read-run fixtures, ordering disabled, native wave64, direct DXIL, the PR base, other adapters, the full test suite, and title smoke runs. AI use T3 Code / Codex (gpt-6.2-sol) verified the revision, ran the checked-in fixture, and wrote this report. |
On GPUs with 32-lane waves only, a console wave64 program runs as two hardware wave32s ("halves"), and nothing ordered their LDS accesses. A console wave runs an instruction in all 64 lanes before the next one, so a lane reads the LDS word another lane wrote an instruction earlier without an
s_barrier. Split, a read could run before the other half's write (it got a stale word) or after that half's later write. The halves now meet before every LDS access. Part of #675 (plan: #675 (comment)).To reproduce on a GPU with 64-lane waves (AMD):
XCL_SPLIT_WAVE64=1forces the split form there, socargo test -p xcl --lib split_wave64runs the same path as on NVIDIA.What is in it
crates/xcl/src/gpu/recomp/emit.rs(17 lines):x64_lds_meet()emitsxcl_x_meet();in the split form in kernel, compute and mesh mode. The DS handler calls it before each LDS access (ds_read*,ds_write*, the ADDTID forms, the 8 / 16-bit and d16 forms, the LDS atomics), once the access is known to be translated: a refused one (GDS, an unknown DS op) gets none. Nothing is exchanged: the meeting waits for the other half's arrival count (spin form) or is a group barrier (XCL_WAVE64_SPIN=0), so each half's earlier instructions are done before the access. Both halves run the same instruction stream, so their exchange counts stay in step. Geometry mode is unchanged.ds_bpermuteandds_swizzledo not touch LDS and are unchanged. Native wave64 and wave32 translations are unchanged.crates/xcl/src/gpu/recomp/tests.rs:split_wave64_meets_before_each_lds_access(no GPU, so CI and a wave64 machine run it): the emitted HLSL of the test program has sixxcl_x_meet();in the split form and none natively, as a wave32 program, or for a GDS access.gpu_split_wave64_lds_follows_instruction_order: a wave64 compute program in groups of one console wave (64 threads) and of four (256 threads, the counter-paired form), 1,024 groups each. Lanes 32..63 write a word each, lanes 0..31 read them and write a second bank, lanes 32..63 read that and overwrite the first bank, lanes 0..31 overwrite the second. The EXEC masks are constants, so no exchange lies between the accesses. The values carry the group, so a word another group left in the LDS does not pass. It runs natively where the GPU has 64-lane waves and skips without a GPU or DXC.docs/wave64-on-wave32.md: a row in the exchange table, hazard 6 (LDS order), and LDS accesses added to the cost paragraph. Hazard 6 also says what the meeting does not do: it orders instructions, not the lanes of one instruction, and geometry mode assumes ES code reads no other lane's item before thes_barrier.Follow-up commits (after the RTX 3060 report below; review asked for them as separate commits)
8a79b8eleaves out meetings that order nothing: a read right after a read in the same basic block, and any access with an exchange (itself a meeting) between it and the block's previous LDS access. Block starts, writes, atomics and reads after writes still meet.Em::newnow takes the block starts, so no caller can elide across blocks by leaving them empty. On a read-heavy test program the meetings go from 8 to 5; on the retail title's 370 wave64 compute and mesh programs with LDS (@erickbobd's census in the comments) from 11,127 to 6,694 statically (−39.8 %).2473e2faddsXCL_WAVE64_LDS_ORDER=0, which leaves the meetings out entirely (default on), so anyone can A/B them; set, it bypasses the translation caches likeXCL_WAVE64_SPIN.v_cmpinto VCC never read whole) is not a meeting, a loop head meets, and a read run with and without an exchange is checked on the GPU in 64- and 256-thread groups. Builds with a meeting wrongly elided fail them.Rebased on
main8f5fca5b(head0141ee9): main moved the GDS check inds()above the ADDTID branch and rewrotewrite_mask; the meeting now sits after main's single GDS check, andx64_met()before the newballot_px_quadmatch. RTX 5070 Ti (Windows Sandbox, GPU-PV):split_wave6414 of 14; full suite 1100 passed, 8 failed, the same 8 that fail onmainthere. The RTX 3080 numbers below are from the head before the rebase (2473e2f).Not covered: the direct RDNA2-to-DXIL path (#1426,
gpu/dxil/lower_mem.rs, opt-in withXCL_DIRECT_DXIL) has its own split form and the same LDS ordering gap; this PR only changes the HLSL path.Tested
RTX 3080,
cargo test --workspace -- --test-threads=4at the head0141ee9(onmain8f5fca5b): 1108 passed, 0 failed, 46 ignored; the SKIPPED lines are main's new lower/lower_dxil GPU agreement tests, the two no-wave64 tests andpso_measurement_compiles_an_exact_synthetic_record.NVIDIA GeForce RTX 3080 10 GB (driver 610.88 / 32.0.16.1088, 32-lane waves), AMD Ryzen 9 5900X, Windows 11 Pro 26200; Rust 1.100.0
stable-x86_64-pc-windows-msvc; tests in the default (debug) profile, smoke runs in release.cargo test --workspace -- --test-threads=4at the head2473e2f: 747 passed, 0 failed, 41 ignored (at77a8190: 743 passed, 0 failed, 41 ignored) (SKIPPED GPU tests:gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_maskandgpu::recomp::tests::gpu_wave32_program_in_wave64_hardware, both "no wave64").RTX 3080, separate runs of each test, the final form of the test with the meetings taken out (same test file,
emit.rsas onmain) and at this commit:gpu_split_wave64_lds_follows_instruction_order, default (spin form)XCL_WAVE64_SPIN=0(barrier form)split_wave64_meets_before_each_lds_access(no GPU)RTX 5070 Ti through GPU-PV in Windows Sandbox (32-lane waves; the guest reports driver 10.0.26100.1150), Rust 1.100.0, debug,
cargo test --workspace --frozen --no-fail-fast -- <filter> --test-threads=4.First form of the GPU test (64-thread groups only) and of the change (the meeting one line earlier in the DS handler), 20 separate runs per variant:
XCL_WAVE64_SPIN=0(barrier form)split_wave64 --include-ignored(the five othergpu_split_wave64_*tests,mesh_split_wave64_formandbench_split_wave64in the same process, 4 threads)Wrong values seen: 0 (read before the other half's write) and the overwriting value (read after its later write).
This commit's tree, filter
split_wave64, 5 separate runs: 8 passed, 0 failed, 1 ignored in each. With the meetings taken out and only the 256-thread groups run: 0 of 5 pass, 237,824 to 239,936 of 262,144 threads wrong, andsplit_wave64_meets_before_each_lds_accessfails (0 meetings, not 6).Whole suite, this commit's tree: 741 passed, 2 failed, 41 ignored; SKIPPED
gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no wave64). The failures arelauncher::tests::console_detection(it readsSystem32\notepad.exe; the sandbox image has none) andhle::d3d12x::fence_x::tests::the_cell_follows_the_fence(left 7, right 9), which did not fail in the run of the first form (741 passed, 1 failed).Cost, same GPU, first form: the test's program (6 LDS accesses in 28 instructions) goes from 1 exchange to 7. GPU time of a 16,384-group dispatch, median of 9, two rounds: 0.046 to 0.120 and 0.123 ms in the spin form (2.6 times), 0.035 to 0.035 and 0.036 ms in the barrier form.
Regression run
RTX 3080,
scripts/smoke.ps1, 300 s each, menus only (fresh data),main8f5fca5b(this PR's base) and then this PR's head0141ee9:In the world (RTX 3080,
main930e8b4+ #1123 + #1254, warm data and caches,XCL_PSO_WAIT_MS=50, A at 30 and 40 s, 400 s; one run each):main77a81902473e2f)XCL_WAVE64_LDS_ORDER=0ListX #101#101GPU queue.Waittimeouts (first)0x887A0006168.5 s+0x23cf683178.4 s0xC0000005+0x2215c35158.5 s0x887A0006160.7 sE_OUTOFMEMORYAll four stop in the same GPU-side stall 35-55 s after
#101(GPU at 100 % until the end), with or without the meetings, so on this card the meetings don't change the world; the RTX 3060 regression report below is not reproduced here.Not tested
XCL_SPLIT_WAVE64=1there (since run by a reviewer on an RX 9070 XT, see the comments).split_wave64filter instead). On the RTX 3080: the run under load and the timing.xcl_x_dead) in a real run. More exchanges mean more places where a pair that is already out of step waits out its 2^20 polls.AI use