test(shader): pin the f16 output modifier against the FP16_OVFL clamp as measured on gfx1151 #27972

Open
Jirka135 wants to merge 2 commits from upstream-pr/27972 into main
Jirka135 commented 2026-11-27 23:42:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Jirka135 on 2026-11-27T23:42:10Z.


What

Extends Fp16OverflowOmod (agc_driver_fp16_overflow_omod) from v_mul_f16 to v_mul_f16, v_add_f16 and v_fma_f16. Each instruction runs with mul:2, div:2 and with no modifier, and v_mul_f16 also with mul:4.

The test uses 16 rows and their negations in lanes 16..31:

  • results that overflow only after the modifier
  • results that overflow before it, where div:2 shows whether the FP16_OVFL clamp comes first (0x77ff) or last (0x7bff)
  • an infinite source
  • a NaN

It runs in four float modes:

  • FP16_OVFL 0
  • FP16_OVFL 1
  • FP16_OVFL 1 with f16 denormals kept, where the modifier is ignored
  • FP16_OVFL 1 with IEEE mode on, where the modifier is ignored

The expected values are the hardware results, and they match the current translation: clamp to ±0x7bff first, then the modifier. The FP16_OVFL debt entry now records this ordering. On a mismatch the test prints the measured rows in the layout of Modes, ready to paste.

Tested

  • Hardware: Radeon 8060S (gfx1151, RDNA3.5), Windows 11, AMD Windows driver 32.0.22032.6002.
  • tools/hw-oracle/hw_oracle.py over HIP on gfx1151 in the four modes. gfx1151 rejects the true16 .l operands, so the HIP body uses the fake16 encodings. With FP16_OVFL=1, div:2 of a product that overflows gives 0x77ff, so the clamp comes first. All 4 × 16 rows × 10 outputs equal Modes in the test.
  • The recompiler through agc_oracle_runner (Vulkan 1.4.329 on the same GPU, HW_ORACLE_TARGET=gfx1030 for the test's GFX10 encodings) on the same rows and modes: identical to the hardware.
  • ctest -R ^agc_driver_fp16_overflow_omod$ -V: passed.
  • python tools/check_conventions.py passed with one warning: the debt entry is over 1000 characters. It was already over the limit; this change adds one sentence. python tools/debt_fold.py --check reports nothing for this fragment.

Checklist

  • Test only, no translation change
  • Debt fragment in docs/dev/debt/changes/
  • Hardware values confirmed on gfx1151
  • PS5 gfx1013 marked unmeasured

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Expanded validation of half-precision overflow behavior across multiple floating-point modes and output modifiers, with clearer reporting when results differ from expectations.
  • Documentation
    • Added measured behavior notes for half-precision overflow, including rounding and output-modifier effects, and clarified which hardware was covered by the measurements.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5534546117 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27972). Originally posted by [Jirka135](https://github.com/Jirka135) on 2026-11-27T23:42:10Z. --- ### What Extends `Fp16OverflowOmod` (`agc_driver_fp16_overflow_omod`) from `v_mul_f16` to `v_mul_f16`, `v_add_f16` and `v_fma_f16`. Each instruction runs with `mul:2`, `div:2` and with no modifier, and `v_mul_f16` also with `mul:4`. The test uses 16 rows and their negations in lanes 16..31: - results that overflow only after the modifier - results that overflow before it, where `div:2` shows whether the `FP16_OVFL` clamp comes first (`0x77ff`) or last (`0x7bff`) - an infinite source - a NaN It runs in four float modes: - `FP16_OVFL` 0 - `FP16_OVFL` 1 - `FP16_OVFL` 1 with f16 denormals kept, where the modifier is ignored - `FP16_OVFL` 1 with IEEE mode on, where the modifier is ignored The expected values are the hardware results, and they match the current translation: clamp to ±0x7bff first, then the modifier. The `FP16_OVFL` debt entry now records this ordering. On a mismatch the test prints the measured rows in the layout of `Modes`, ready to paste. ### Tested - Hardware: Radeon 8060S (gfx1151, RDNA3.5), Windows 11, AMD Windows driver 32.0.22032.6002. - `tools/hw-oracle/hw_oracle.py` over HIP on gfx1151 in the four modes. gfx1151 rejects the true16 `.l` operands, so the HIP body uses the fake16 encodings. With `FP16_OVFL`=1, `div:2` of a product that overflows gives `0x77ff`, so the clamp comes first. All 4 × 16 rows × 10 outputs equal `Modes` in the test. - The recompiler through `agc_oracle_runner` (Vulkan 1.4.329 on the same GPU, `HW_ORACLE_TARGET=gfx1030` for the test's GFX10 encodings) on the same rows and modes: identical to the hardware. - `ctest -R ^agc_driver_fp16_overflow_omod$ -V`: passed. - `python tools/check_conventions.py` passed with one warning: the debt entry is over 1000 characters. It was already over the limit; this change adds one sentence. `python tools/debt_fold.py --check` reports nothing for this fragment. ### Checklist - [x] Test only, no translation change - [x] Debt fragment in `docs/dev/debt/changes/` - [x] Hardware values confirmed on gfx1151 - [x] PS5 gfx1013 marked unmeasured 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Tests** * Expanded validation of half-precision overflow behavior across multiple floating-point modes and output modifiers, with clearer reporting when results differ from expectations. * **Documentation** * Added measured behavior notes for half-precision overflow, including rounding and output-modifier effects, and clarified which hardware was covered by the measurements. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
MarcZX10 commented 2026-11-28 11:08:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T11:08:15Z.

Review: COMMENTED


Reviewed — no blocking findings

Nothing in the inspected changes shows a verified defect; the reported test results were supplied by the author and were not run in this review.

What I ran

Reviewed head 42cbebae4798f8191275bd92ee1f905ae0b541ea. No commands or tests were run; the reader interface provided source access only.

Results

Check Result Note
Changed-file review passed Both changed files were read in full.
Reported test and convention checks not run Results in the PR description are author-reported.
Negative control not run Not available through the reader.

Findings

Blocking

None.

Non-blocking

None.

Not verified

Hardware measurements, the recompiler oracle run, the CTest result, and convention/debt-fold checks were not independently verified. No other repository files were read; the manifest lists both changed files as included and reviewed.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6097392413 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27972#pullrequestreview-6097392413). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-28T11:08:15Z. **Review:** COMMENTED --- # Reviewed — no blocking findings Nothing in the inspected changes shows a verified defect; the reported test results were supplied by the author and were not run in this review. ## What I ran Reviewed head `42cbebae4798f8191275bd92ee1f905ae0b541ea`. No commands or tests were run; the reader interface provided source access only. ## Results | Check | Result | Note | |---|---|---| | Changed-file review | passed | Both changed files were read in full. | | Reported test and convention checks | not run | Results in the PR description are author-reported. | | Negative control | not run | Not available through the reader. | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified Hardware measurements, the recompiler oracle run, the CTest result, and convention/debt-fold checks were not independently verified. No other repository files were read; the manifest lists both changed files as included and reviewed. ## To get this to a good state Nothing is required.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/27972:upstream-pr/27972'
git switch 'upstream-pr/27972'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/27972'
git switch 'upstream-pr/27972'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/27972'
git switch 'upstream-pr/27972'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/27972'
git switch 'main'
git merge --squash 'upstream-pr/27972'
git switch 'main'
git merge --ff-only 'upstream-pr/27972'
git switch 'main'
git merge 'upstream-pr/27972'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!27972
No description provided.