Skip to content

f64_diff: match single-thread --oracle hw exec_lo and zero output VGPRs - #6403

Open
Alpaca-exe wants to merge 1 commit into
ItsNotRexed:mainfrom
Alpaca-exe:f64-diff-hw-exec-mask
Open

Alpaca-exe wants to merge 1 commit into
ItsNotRexed:mainfrom
Alpaca-exe:f64-diff-hw-exec-mask

Conversation

@Alpaca-exe

Copy link
Copy Markdown
Contributor

Fixes lucas-lachaud's finding in #6214 (claim).

Problem

tools/f64_diff.py runs --oracle hw as a single-thread hw_oracle.asm.Kernel(..., threads=1) where hardware exec_lo starts at 1, while ref_program() initialized active = M32 (0xffffffff, 32 lanes). On v_cmpx_*_f64 and v_cmpx_class_f64, every matching case therefore produced 0xffffffff in the reference vs 1 on AMD hardware (exec_lo & M32 == 1).

In addition, hw_kernel() did not zero v8..v11 before executing the test body, whereas ref_program() initializes VGPRs to 0 on read. During shrink(), reducing down to [] stored uninitialized v8..v11 on hardware instead of [0, 0, 0, 0], letting shrink() collapse a false v_cmpx_* mismatch to an empty minimal program.

Fix

  • tools/f64_diff.py:
    • Add init_exec=M32 to ref_program() so --oracle hw passes init_exec=1 (threads=1) while 32-lane translator/Vulkan runs keep M32.
    • Prepend v_mov_b32 v{8..11}, 0 in hw_kernel() so uninitialized output VGPRs match ref_program() and empty shrink trials return zero.
  • tests/test_f64_diff.py:
    • Pass init_exec = fd.M32 if kernel.threads >= 32 else (1 << kernel.threads) - 1 in FakeHW.run() so the fake hardware oracle matches threads=1.
    • Add test_hw_oracle_v_cmpx_matches_single_thread_exec_mask and test_hw_kernel_zeroes_output_vgprs_and_shrink_stays_nonempty.

Verification (Windows 11, Python 3.11)

  • python -m compileall -q tools/f64_diff.py tests/test_f64_diff.py: exit 0
  • python -I tools/f64_diff.py --self-test: 10/10 reference invariants + planted mismatch OK
  • python -I tests/test_f64_diff.py -v: 31/31 tests OK (FakeHW mocked oracle for --oracle hw; not run on a physical hw_oracle_drm Linux launcher)
  • python -I scripts/check_no_game_data.py: exit 0
  • python -I tests/test_text_write_line_endings.py: 3 OK
  • python -I tests/test_tool_startup.py: 2 OK
  • python -I tests/test_tool_stdout_encoding.py: 4 OK
  • git diff --check: clean

AI-assisted; no game data.

@TreXito

TreXito commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Overlap note: the EXEC half of this fix is already in #4536 (open, FUZZ-55, iurysf). Its commit 1599b382 adds ref_program(..., lane_mask=M32) and HW_LANE_MASK = 0x1, passed for --oracle hw. The v8..v11 zeroing in hw_kernel() is not in #4536, so that part is new here.

The two PRs conflict in 3 hunks: ref_program's signature, its run_one call, and FakeHW.run() in tests/test_f64_diff.py. #6443 (mine) is stacked on #4536 and conflicts in the same places. Whichever of #4536 and #6403 lands second needs a small rebase. I'll rebase #6443 either way.

Checked with git merge-tree against e3f645f9, 5c81e056 (#4536) and 38b75c9f (#6443). AI-assisted (Claude Code).

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