Skip to content

docs(design): tidy the f16 frexp/ldexp row - #4797

Open
liang-kai-shui wants to merge 1 commit into
ItsNotRexed:mainfrom
liang-kai-shui:proc-235-frexp-row
Open

liang-kai-shui wants to merge 1 commit into
ItsNotRexed:mainfrom
liang-kai-shui:proc-235-frexp-row

Conversation

@liang-kai-shui

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #4683 (comment)

Fixes PROC-235 (found by @Krashgamer): the contract row for v_frexp_mant_f16, v_frexp_exp_i16_f16 and v_ldexp_f16 in docs/design.md (line 415 on 98fa503f) contradicted itself in four ways, so a reader could not tell which rule the translation follows.

What changed (text only)

  • infinities and NaNs give the input unchanged and exponent 0 appeared twice, and the first copy still said denormals are "read as zero" next to "f16 denormals are kept"; now: zero -> signed zero / exponent 0, infinities and NaNs -> input unchanged / exponent 0, f16 denormals kept and normalized (with the measured 0x0001, 0x03ff words);
  • v_ldexp_f16 claimed "no denormal results" and then listed measured denormal results rounded to nearest even; now one rule: S1 clamped to [-64, 64], overflow -> ?infinity, below the smallest normal -> denormal rounded to nearest even (measured 0x0200, 0x0002, 0x0001, 0x0400 cases), zero/inf/NaN ignore S1;
  • "clamp and the output multipliers are rejected as unsupported" contradicted the later measured clamp behaviour; now: VOP3 clamp acts on the FP16 result of v_frexp_mant_f16/v_ldexp_f16 (hardware-verified on gfx1036, 302 kernels), omod (mul:2/mul:4/div:2) is rejected, and clamp on v_frexp_exp_i16_f16 is rejected;
  • "Not measured on hardware ... whether v_frexp_exp_i16_f16 keeps the high half ... is the translator's choice" contradicted the next sentence's gfx1036 measurement; now the measured paragraph says the high half is kept by all three, and only the NaN payload (and the IEEE 1 signalling-NaN quieting) remain not modelled.

The measured words (gfx1036, tools/hw_oracle, 65,536 inputs per frexp op and v_ldexp_f16 under 16 exponents) and the current translator behaviour are unchanged; tests/semantic/test_alu_frexp_ldexp_f16.py still holds the words quoted.

Tested

  • python -I tests/test_docs_links.py -> 6 tests OK; python -I tests/test_docs_design_rows.py -> 4 tests OK (the row's first cell is unchanged, so it is still one topic per table).
  • git diff --check clean; docs/design.md only, one row (1 insertion / 1 deletion).
  • No game data, no GPU.

Overlap: #2171 and #4311 edit this same row and are still open; this can be folded into whichever lands first (the text is the same rule set either way).

AI-assisted.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md).
  • A new translator rule is in the contract table of docs/design.md ??not applicable (documents already-implemented rules).

PROC-235: the contract row repeated "infinities and NaNs give the
input unchanged and exponent 0", said denormals are both read as zero
and kept, claimed v_ldexp_f16 produces no denormal results before
listing measured denormal results, contradicted itself on clamp (and
omod) support, and still called the destination's high half unmeasured
despite the gfx1036 measurement. Rewrite those sentences to one
self-consistent rule set; the measured words and the current translator
behaviour are unchanged.
@Krashgamer

Copy link
Copy Markdown

Thanks for taking PROC-235. On the overlap with #2171: its only change to this row is the last sentence, which gains the GPU check. This PR leaves that sentence as main has it, so the conflict is mechanical: keep #2171's version of that sentence and your rewrite of the rest. #2171's sentence:

Checked on the CPU by tests/semantic/test_alu_frexp_ldexp_f16.py, which holds measured words (including VOP3 clamp), and on the GPU by runtime/test/shaders/cs_f16_frexp_ldexp.asm: check.py and run_gpu_tests.py compare the translated program's words for all 65,536 inputs of the three ops, v_ldexp_f16 under 21 exponents, with the same rule (exact on an RTX 3080, NVIDIA 610.88); not run on the shader corpus.

If this one lands first, I'll rebase #2171 onto it the same way.

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