tools: cndmask_hw_probe measures v_cndmask_b32's abs/neg source modifiers natively (TOOL-CNDMASK-HW-PROBE) #1784

Open
github-bot wants to merge 1 commit from github-bot/gh-1784 into main AGit
Owner

@⁠mcpeacebir-lang on GitHub · 2026-11-25 12:06 UTC · original
mcpeacebir-lang:claude/cndmask-hw-probe → main · +562 −1 · 3 files · 1 commits · open

Claimed in the coordination issue as: TOOL-CNDMASK-HW-PROBE (#1608)

What and why

The "v_cndmask_b32 source modifiers" row of docs/design.md said the translator's rule was "Not measured on hardware for this instruction". The rule is that VOP3 abs/neg on v_cndmask_b32 are sign-bit moves (Gen.src_u_sign_mods), so a signalling NaN stays signalling and a denormal is not flushed. I measured it on an RX 7800 XT for HW-CNDMASK-SIGN-MODS in #1608 (#1608), with a script outside the repository. This turns that run into a tool, so the row can cite it and someone with a gfx103x card can measure RDNA2 with one command.

tools/cndmask_hw_probe.py runs v_cndmask_b32_e64 through tools/hw_oracle. Each kernel runs one lane.

  • 15 words: ±0, denormals, ±1.0/2.0, max normal, ±inf, quiet and signalling NaNs with payloads. They are the same kinds of words as tests/semantic/test_cndmask_sign_mods.py.
  • Each word goes through v, -v, |v| and -|v|, as the selected src0 and as the selected src1.
  • One kernel per wave size × MODE: ieee 0/1 × denorm32 0/3, in wave32 and wave64.
  • Every result is classed as a sign-bit move, a quieted sNaN, a flushed denormal or other.
  • Each kernel also stores two float ops as controls, so a run shows its MODE was really in effect:
    • v_add_f32(+min denormal, 0), which is flushed exactly when denorm32 = 0;
    • v_mul_f32(sNaN, 1.0), which is quieted exactly when ieee = 1.

Exit codes:

  • 0: every result is a sign-bit move and every control shows its mode.
  • 1: otherwise, or the report cannot be written.
  • 2: harness or CLI error.
  • 77: no oracle, or a GPU that cannot set the IEEE mode (not gfx10/gfx11, or gfx1170 and later).

--waves, --json and --self-test follow ds_permute_probe.py and dpp_hw_probe.py (#1773).

The row in docs/design.md now gives the RDNA3 result and says RDNA2 is not measured. It keeps the two arguments the rule rested on before: the v_cmp_class_f32 measurement and LLVM's foldFreeOpFromSelect.

No translator change. New files plus one row of docs/design.md.

Tested

  • python -I tests/test_cndmask_hw_probe.py: 20 tests, 19 OK and 1 skipped (the llvm-mc check). With LEONIDA_AMD_CLANG set to the clang from rocm-sdk-core==10.0.0 (AMD LLVM 23.0.0git), all 20 are OK. The llvm-mc check assembles every kernel body for gfx1030 (GFX10 spelling) and gfx1101, in wave32 and wave64.
  • python -I tools/cndmask_hw_probe.py --self-test: OK.
  • On the GPU, on main 0d80bc5df:
    $ python -I tools/cndmask_hw_probe.py --json report.json
    device: gfx1101
    wave32 ieee=0 denorm32=0: 120/120 sign-bit moves; controls: denorm_add 0x00000000; snan_mul 0x7f800001
    wave32 ieee=0 denorm32=3: 120/120 sign-bit moves; controls: denorm_add 0x00000001; snan_mul 0x7f800001
    wave32 ieee=1 denorm32=0: 120/120 sign-bit moves; controls: denorm_add 0x00000000; snan_mul 0x7fc00001
    wave32 ieee=1 denorm32=3: 120/120 sign-bit moves; controls: denorm_add 0x00000001; snan_mul 0x7fc00001
    wave64 ieee=0 denorm32=0: 120/120 sign-bit moves; controls: denorm_add 0x00000000; snan_mul 0x7f800001
    wave64 ieee=0 denorm32=3: 120/120 sign-bit moves; controls: denorm_add 0x00000001; snan_mul 0x7f800001
    wave64 ieee=1 denorm32=0: 120/120 sign-bit moves; controls: denorm_add 0x00000000; snan_mul 0x7fc00001
    wave64 ieee=1 denorm32=3: 120/120 sign-bit moves; controls: denorm_add 0x00000001; snan_mul 0x7fc00001
    result: every source modifier is a sign-bit move, every MODE shown
    
  • Checks on the changed files:
    • scripts/check_no_game_data.py: clean.
    • compileall and git diff --check: clean.
    • tests/test_ci_registration.py, tests/test_text_write_line_endings.py and every tests/test_docs_*.py: OK.
  • test_runner_calls_all_tests.py, test_tool_stdout_encoding.py and test_runtime_paths.py are red on main already (#1673). None of their failures names these files.

Not run: RDNA2 itself (no gfx103x card here), which is what the tool is for. Nothing in the translator suite changes.

GPUs tested: AMD Radeon RX 7800 XT (gfx1101, RDNA3), AMD driver 32.0.32029.2010, Windows 11, through tools/hw_oracle (amdhip64_7.dll, AMD clang from rocm-sdk-core==10.0.0).

AI-assisted: yes (Claude Code, Claude Opus 5.5)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change; the existing row gains its hardware measurement)

🤖 Generated with Claude Code

**@⁠mcpeacebir-lang** on GitHub · 2026-11-25 12:06 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1784) `mcpeacebir-lang:claude/cndmask-hw-probe` → `main` · +562 −1 · 3 files · 1 commits · open Claimed in the coordination issue as: TOOL-CNDMASK-HW-PROBE (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why The "`v_cndmask_b32` source modifiers" row of `docs/design.md` said the translator's rule was "Not measured on hardware for this instruction". The rule is that VOP3 `abs`/`neg` on `v_cndmask_b32` are sign-bit moves (`Gen.src_u_sign_mods`), so a signalling NaN stays signalling and a denormal is not flushed. I measured it on an RX 7800 XT for HW-CNDMASK-SIGN-MODS in #1608 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608), with a script outside the repository. This turns that run into a tool, so the row can cite it and someone with a gfx103x card can measure RDNA2 with one command. `tools/cndmask_hw_probe.py` runs `v_cndmask_b32_e64` through `tools/hw_oracle`. Each kernel runs one lane. - 15 words: ±0, denormals, ±1.0/2.0, max normal, ±inf, quiet and signalling NaNs with payloads. They are the same kinds of words as `tests/semantic/test_cndmask_sign_mods.py`. - Each word goes through `v`, `-v`, `|v|` and `-|v|`, as the selected src0 and as the selected src1. - One kernel per wave size × MODE: `ieee` 0/1 × `denorm32` 0/3, in wave32 and wave64. - Every result is classed as a sign-bit move, a quieted sNaN, a flushed denormal or other. - Each kernel also stores two float ops as controls, so a run shows its MODE was really in effect: - `v_add_f32(+min denormal, 0)`, which is flushed exactly when `denorm32 = 0`; - `v_mul_f32(sNaN, 1.0)`, which is quieted exactly when `ieee = 1`. Exit codes: - 0: every result is a sign-bit move and every control shows its mode. - 1: otherwise, or the report cannot be written. - 2: harness or CLI error. - 77: no oracle, or a GPU that cannot set the IEEE mode (not gfx10/gfx11, or gfx1170 and later). `--waves`, `--json` and `--self-test` follow `ds_permute_probe.py` and `dpp_hw_probe.py` (#1773). The row in `docs/design.md` now gives the RDNA3 result and says RDNA2 is not measured. It keeps the two arguments the rule rested on before: the `v_cmp_class_f32` measurement and LLVM's `foldFreeOpFromSelect`. No translator change. New files plus one row of `docs/design.md`. ### Tested - `python -I tests/test_cndmask_hw_probe.py`: 20 tests, 19 OK and 1 skipped (the llvm-mc check). With `LEONIDA_AMD_CLANG` set to the clang from `rocm-sdk-core==10.0.0` (AMD LLVM 23.0.0git), all 20 are OK. The llvm-mc check assembles every kernel body for gfx1030 (GFX10 spelling) and gfx1101, in wave32 and wave64. - `python -I tools/cndmask_hw_probe.py --self-test`: OK. - On the GPU, on `main` `0d80bc5df`: ``` $ python -I tools/cndmask_hw_probe.py --json report.json device: gfx1101 wave32 ieee=0 denorm32=0: 120/120 sign-bit moves; controls: denorm_add 0x00000000; snan_mul 0x7f800001 wave32 ieee=0 denorm32=3: 120/120 sign-bit moves; controls: denorm_add 0x00000001; snan_mul 0x7f800001 wave32 ieee=1 denorm32=0: 120/120 sign-bit moves; controls: denorm_add 0x00000000; snan_mul 0x7fc00001 wave32 ieee=1 denorm32=3: 120/120 sign-bit moves; controls: denorm_add 0x00000001; snan_mul 0x7fc00001 wave64 ieee=0 denorm32=0: 120/120 sign-bit moves; controls: denorm_add 0x00000000; snan_mul 0x7f800001 wave64 ieee=0 denorm32=3: 120/120 sign-bit moves; controls: denorm_add 0x00000001; snan_mul 0x7f800001 wave64 ieee=1 denorm32=0: 120/120 sign-bit moves; controls: denorm_add 0x00000000; snan_mul 0x7fc00001 wave64 ieee=1 denorm32=3: 120/120 sign-bit moves; controls: denorm_add 0x00000001; snan_mul 0x7fc00001 result: every source modifier is a sign-bit move, every MODE shown ``` - Checks on the changed files: - `scripts/check_no_game_data.py`: clean. - `compileall` and `git diff --check`: clean. - `tests/test_ci_registration.py`, `tests/test_text_write_line_endings.py` and every `tests/test_docs_*.py`: OK. - `test_runner_calls_all_tests.py`, `test_tool_stdout_encoding.py` and `test_runtime_paths.py` are red on `main` already (#1673). None of their failures names these files. Not run: RDNA2 itself (no gfx103x card here), which is what the tool is for. Nothing in the translator suite changes. GPUs tested: AMD Radeon RX 7800 XT (gfx1101, RDNA3), AMD driver 32.0.32029.2010, Windows 11, through `tools/hw_oracle` (`amdhip64_7.dll`, AMD clang from `rocm-sdk-core==10.0.0`). AI-assisted: yes (Claude Code, Claude Opus 5.5) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change; the existing row gains its hardware measurement) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The "v_cndmask_b32 source modifiers" row of docs/design.md said the rule
(sign-bit moves, Gen.src_u_sign_mods) was not measured on hardware for this
instruction. tools/cndmask_hw_probe.py runs 15 words x v/-v/|v|/-|v| x
src0/src1 through tools/hw_oracle under ieee 0/1 x denorm32 0/3 in wave32 and
wave64, with a v_add_f32 and a v_mul_f32 in each kernel as controls that show
the MODE is in effect. On an RX 7800 XT (gfx1101) all 120 results are sign-bit
moves in every mode; the row now says so and that RDNA2 is not measured.

tests/test_cndmask_hw_probe.py is CPU-only; its assembler check runs when
LEONIDA_AMD_CLANG has llvm-mc beside it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:05:06 +00:00
github-bot force-pushed github-bot/gh-1784 from 028c1c315e to 45435f74b4 2026-11-26 16:23:18 +00:00 Compare
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1784/head:github-bot/gh-1784'
git switch 'github-bot/gh-1784'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1784'
git switch 'github-bot/gh-1784'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1784'
git switch 'github-bot/gh-1784'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1784'
git switch 'main'
git merge --squash 'github-bot/gh-1784'
git switch 'main'
git merge --ff-only 'github-bot/gh-1784'
git switch 'main'
git merge 'github-bot/gh-1784'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.