Tests: check scalar ALU results and SCC on the GPU against the ISA #615
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/620"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by acaracargo on 2026-11-24T02:35:21Z.
About 80 SALU instructions are translated in
emit.rsbut never run in a GPU test. This adds one test for 46 of them, each on edge values (sign, carry and overflow boundaries, shift counts past 31 / 63, all-ones and all-zero inputs). It compares the destination and SCC with a small model of the RDNA2 pseudo-code (salu_reference). For instructions that do not write SCC, it checks that SCC keeps both of its earlier values. Test only, no runtime change.A search of open and closed PRs for "scalar", "SALU", "SCC" and the opcode names found no overlapping coverage. #445, #519, #545 and #590 cover VALU instructions only.
What is in it
crates/xcl/src/gpu/recomp/tests.rs:SaluCase,salu_referenceandgpu_scalar_alu_results_and_scc, 68 cases in programs of 30. s[0:5] hold the operands and the destination, and s[8..97] hold each result and its SCC.Tested
x86_64-pc-windows-msvc; DXC 1.9.2602.17 from the Windows SDK; debug.cargo test --workspace -- --test-threads=4on0e158e4: 685 passed, 0 failed, 41 ignored. Onmain9ce2070: 684 / 0 / 41.gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware(no wave64).s_ff0_i32_b32scanning the wrong bits, ands_pack_hh_b32_b16writing SCC.Regression run
Not tested
AI use
Imported from ivall/xcl. Originally posted by MesshM on 2026-11-24T02:46:37Z.
Test run of
0e158e4bedb6314e5f8ba5b9490d8171e2d8fe40on AMD RDNA4; the PR was tested on NVIDIA only. I merged it onto currentmain3db536elocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 687 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 647 passed, 0 failed, 21 ignoredSKIPPED;gpu_scalar_alu_results_and_sccpasses.Review: I spot-checked
salu_referenceagainst the RDNA2 pseudo-code: SCC = result ≠ 0 fors_abs,s_absdiff,s_bcnt0,s_wqmand thenand/nor/xnor/orn2/andn2cases; no SCC write fors_bfm,s_brev,s_sext,s_mul_hi,s_pack_*;s_bitcmp0/1test bitS1[4:0];s_ff0gives −1 with no zero bit;s_pack_hhis{S1[31:16], S0[31:16]}. All match. I did not check every one of the 46 opcodes.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
Imported from ivall/xcl. Originally posted by caua-an on 2026-11-24T02:47:29Z.
Tested: Clean head
0e158e4bedb6314e5f8ba5b9490d8171e2d8fe40; Windows 11 Home build 26200, Core Ultra 9 185H, Rust 1.100.0 MSVC x64, debug build,XCL_REQUIRE_GPU=1. Intel Arc integrated graphics driver 32.0.101.8860; RTX 4070 Laptop driver 616.92.cargo test --offline --locked -p xcl --lib gpu_scalar_alu_results_and_scc -- --test-threads=1 --nocapture: 1 passed, 0 failed, 0 ignored, no skips with each ofXCL_ADAPTER=intelandXCL_ADAPTER=nvidia. DXC 1.9.2602.17 was loaded.Not tested: Full workspace suite, release builds, retail titles, or game-data samples (
XCL_SAMPLE_*unset).AI use: OpenCode with GPT-6.2 Sol ran the tests and drafted this report.
Imported from ivall/xcl. Originally posted by 4usphs on 2026-11-24T09:35:23Z.
Measured on RDNA2 hardware, for the two points under Not tested: console-generation hardware instead of the ISA text, and
s_min/s_maxSCC on equal operands.Method. The Radeon iGPU of a Ryzen 7 9800X3D (
gfx1036, RDNA2), Windows 11 Pro 26200, display driver 32.0.21045.29003, AMD OpenCL3652.0 (PAL,LC). Each case is one inline-assembly block in an OpenCL C kernel (the #518 / #772 method):s_cmp_eq_u32 0, 0|1sets SCC, the instruction runs on SGPR operands with the destination preset to the case'sd, ands_cselect_b32 1, 0reads SCC back. All cases run 6 times, 3 in wave32 and 3 in wave64, with identical output. The reference is a line-by-line Python port ofsalu_referencefrom this PR.Result.
gpu_scalar_alu_results_and_sccmatch the hardware, results and SCC, including SCC kept by the instructions that do not write it.s_min/s_maxon equal operands: SCC = 0, whatever SCC was before. This holds fors_min_i32,s_max_i32,s_min_u32ands_max_u32, each with 5 values (5,0,-3,0x80000000,0xFFFFFFFF) and SCC 0 and 1 before (40 cases). That is the strict</>thatemit.rsuses (lines 1262–1265 onmain077ce40) and this test's reference. Non-ties in both orders (16 cases) give SCC = 1 exactly when S0 is the one selected. So the cases left out by the comment aboveS_MIN_U32could be added with SCC = 0.For comparison, the same probe on an RX 9070 XT (
gfx1201, RDNA4, OpenCL3686.0) gives the same results. The exception iss_ff0_i32_b32, which RDNA4's assembler refuses (removed there), so 66 of the 68 cases ran on it.Not tested: the console itself (
gfx1036is a desktop RDNA2 APU of the same generation), RDNA1, this PR's D3D12 test on this GPU.Kernel shape (one case)
AI use: Claude Code (Claude Opus 5.5) wrote the OpenCL probes and the port of the reference, ran them on my PC and wrote this comment. I have not reviewed the code.
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-25T06:36:59Z.
Empirical test report (
0e158e4b)Hardware / environment
0e158e4bedb6314e5f8ba5b9490d8171e2d8fe40, verified on a clean detached checkout.Commands and results
cargo test -p xcl --lib --no-runexited 0 in 1m 03s outside the Arc lock. Cargo built the library test executable and emitted one deprecation warning forAtomicU32::fetch_update. This command only compiled the tests.Bypass. The variables identify the Arc lock script and the executable emitted by Cargo.^SKIPPEDcount).Observed behavior
The test compared the GPU destination register values and scalar condition code (SCC) against the test's RDNA2 ISA reference for 68 cases across 48 opcodes. All comparisons matched, including cases for arithmetic carry and overflow, masked shift counts, and SCC preservation. The wrapper acquired and released the Arc lock.
Not tested
Full GPU workspace suite and game smoke runs were omitted.
AI use
Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr620-focused.log and published.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T12:46:00Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: 1038 passed, 1 failed in one parallel run; the failing test passes on a single-threaded rerun (1039/0). Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.Thanks!
Imported from ivall/xcl. Originally posted by afpruivo on 2026-11-28T12:05:15Z.
Test report on RTX 3090:
gpu_scalar_alu_results_and_sccpasses, on the PR's head and merged onto currentmain.Tested
0e158e4b:cargo test -p xcl --lib gpu_scalar -- --test-threads=4: 3 passed, 0 failed.maine429936c(no conflicts; local merge80607879):cargo test -p xcl --lib gpu_scalar_alu: 1 passed.cargo test --workspace --no-fail-fast -- --test-threads=4: 2127 passed, 10 failed, 48 ignored. Lib: 1996 passed, 6 failed, 28 ignored.maine429936con this card, so none comes from this PR:split::tests::dispatch_chain_{oversized_loop_matches_whole,wave32_live_loops,wave64_live_loops_and_exchange},gpu_heap_flat_reads_match_guarded_and_root_output,gpu_compute_mode_dispatch_abi,gpu_float_cas_uses_ieee_equalityandtest_title_runs_and_game_folder_is_untouchedfail on every run.incomplete_discovered_corpus_blocks_headless_title_entryandtwo_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobsare flaky on both trees. Across three runs of the pair,mainfailed in one run and the merged tree failed in all three.d3d12SDKLayers.dll), andheap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).Review. I checked
salu_referenceagainst the RDNA2 ISA guide (PDF, §12.1 SOP2 and §12.2 SOPK):D.u = (S0.u > S1.u) ? S0.u : S1.u; SCC = (S0.u > S1.u), a strict compare, so equal operands give SCC = 0, and min follows the same pattern with<. That matchessalu_referenceas written, so tie cases (5, 5) could be added if you want them.Not tested: AMD, and wave64 hardware. I only reviewed the scalar part; this card can't cover wave64-only paths.
AI use: Claude Code (Claude Opus 5.5) ran the tests, checked the reference against the guide and drafted this. I checked it before posting.
Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T02:57:41Z.
merge-check claim
head:
0e158e4bedImported from ivall/xcl. Originally posted by relativespace2K on 2026-11-30T03:03:17Z.
merge-check
base:
53e85fb1head:
0e158e4bedmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2789 passed, 6 failed, 49 ignored; failing: gpu::dxil::compact_tests::gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form, gpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk, hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline, ram_budget::tests::windows_takes_a_working_set_maximum_and_lifts_it, and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (in
--test gpu_two_pass_cache_e2e, so 5 failing tests give 6 failures). The same five fail on base53e85fb1alone (2788 passed, 6 failed, 49 ignored there), so none comes from this PR; its new GPU test passed here and is not among the SKIPPED lines, so it really ran on the RX 6800 XT. 13 SKIPPED lines, all environmental: no D3D12 debug layer / d3d12SDKLayers.dll, no heap windows, no GPU_UPLOAD, per-lane f16/f32 forms refused.review: no blocking finding; one file, every line read. The reference is written in the test from the ISA's pseudo-code rather than borrowed from the translator, which is what makes it a check and not an echo:
salu_referencecomputes result and SCC per instruction,w32keeps the untouched upper half of a 64-bit destination, and every case carries the SCC going in so an instruction that does not write SCC is checked for leaving it alone. The cases pick the edges that matter (sign, carry,0x8000_0000, shift counts past 31 and 63, all-ones, all-zero) and SCC is read back into a register withS_CSELECT_B32, so the assertion covers the flag and not only the value. Ties are deliberately left out ofS_MIN_*/S_MAX_*with a comment saying the ISA does not define which operand a tie selects, which is the right call for a test that must not encode a guess. No duplicate: #1576, #1057 and #1206 are the other GPU op coverage PRs and none of them runs these SALU instructions.performance: none: tests only.
verdict: safe to merge
hardware / tool and model: AMD Radeon RX 6800 XT 16 GB (RDNA2, wave64), driver 32.0.21045.29003; Ryzen 5 5600, 32 GB RAM; Windows 10 IoT Enterprise LTSC 2024, 10.0.26100 build 26100.9974; Rust 1.100.0; DXC 1.9.2602.17; debug build. DeepSeek Harness coding agent, model DeepSeek V4.1 Flash.
Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T03:03:29Z.
merge-check
base:
53e85fb124head:
0e158e4bedmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2793 passed, 1 failed, 49 ignored; SKIPPED: 30 (22 no wave64, 3 per-lane #1426 refused, 2 no heap windows, 2 no xgameruntime.dll, 1 cannot disable the driver cache 0x887A002D); failing: hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline (also fails on base
53e85fb1alone)review: none (read the full +206/-0 diff in crates/xcl/src/gpu/recomp/tests.rs: test-only addition covering 46 SALU instructions across 68 edge cases against salu_reference, checking both destination registers (including upper-half preservation for 32-bit writes) and SCC preservation/updates; gpu_scalar_alu_results_and_scc passed on RTX 4070 SUPER; no duplicates found; not tested: AMD/native wave64 or s_min/s_max equal-operand ties)
performance: none (test-only PR, no runtime changes)
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 4070 SUPER (32.0.16.2140), AMD Ryzen 7 7800X3D, Windows 11 Pro 26300, rustc 1.100.0, debug / Antigravity (Gemini 4 Hydrogen)
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:49:25Z.
Triage (#1607) – head
0e158e4No open or merged PR tests these SALU opcodes against the ISA. #2091 runs many of the same opcodes, but compares the direct DXIL backend with the HLSL one rather than with a reference, so it is a different test.
No problems found in the diff: the reference results and SCC rules in
salu_referencematch the RDNA2 pseudo-code for each opcode (signed overflow for S_ADDK_I32 / S_SUB_I32, carry for S_LSHL*_ADD_U32, SCC kept for opcodes that do not write it), and ties for min/max are avoided as the comment says.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.