Skip to content

docs: pin the LDS ds_add_f32 rows to measured gfx1100 flush-to-zero - #4137

Closed
bobcatchris wants to merge 3 commits into
ItsNotRexed:mainfrom
bobcatchris:docs/lds-add-f32-hw
Closed

bobcatchris wants to merge 3 commits into
ItsNotRexed:mainfrom
bobcatchris:docs/lds-add-f32-hw

Conversation

@bobcatchris

Copy link
Copy Markdown
Contributor

Row ds_add_f32, ds_add_rtn_f32 said how the LDS adder treats denormals and NaN payloads was not measured, and pointed at OpFAdd instead.

Measured natively on an RX 7900 XTX (gfx1100, driver 26.10.1) through tools/hw_oracle, 49 cases, one kernel each: it seeds one LDS dword, runs the op (and the _rtn_ form), reads the dword back and parks both words. Expected words for the normal cases are one exact-rational binary32 addition rounded once to nearest even, written in the probe from the documented rule — not read from the translator.

What it shows:

  • Denormals flush both ways. 0x00800001 + -0x00800000 gives +0, not the exact 0x00000001; 0x007fffff + 0x00800000 gives 0x00800000, not the tie's 0x00ffffff; 0x00000001 + 0x00000001 gives +0. The OpFAdd the translator loops on keeps these, so that is a divergence, now recorded in the row.
  • NaN: quieted with payload and sign kept (0x7f800001 sNaN → 0x7fc00001), and with two NaNs the DATA operand wins whatever the payloads (0x7fc00007 + 0x7fc00000 → 0x7fc00000, 0x7fc00002 + 0xffc00001 → 0xffc00001). inf + -inf gives 0xffc00000.
  • Rounding matches the model everywhere else: ties to even (1.0 + 2^-24 stays 1.0, 1.0 + 3*2^-25 rounds up), -0 + -0 → -0, +0 + -0 → +0, overflow to ±inf, and _rtn_ returns the raw pre-op dword including a denormal one.

Docs-only: one row of docs/design.md (1 insertion, 1 deletion). tests/test_docs_design_rows.py, test_docs_links.py, test_docs_list_items.py, test_docs_repo_paths.py: 12 passed. No game data, synthetic operands only. AI-assisted.

@tupacfan04

Copy link
Copy Markdown
Contributor

Tested at the head on Windows 11 / Python 3.13.0: 25 docs tests passed with 6 subtests, the cited tests/semantic/test_lds_add_f32.py 5 passed / 128 subtests, git diff --check clean, and it fast-forwards on origin/main and merges cleanly with #4147/#4141.

The row (docs/design.md:342) is unique, names gfx1100 / RX 7900 XTX / 26.10.1 / tools/hw_oracle / 49 cases, and has no stale "not measured" tail; there is no ds_add/LDS-adder entry in shader_validation.md to contradict. The body and row agree (flush both ways, NaN payload/sign, DATA wins, inf + -inf = 0xffc00000).

Approve. AI-assisted review, docs only.

@sds-228 sds-228 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review of fda3feb: no issues found. The unmeasured qualifier is replaced by a coherent measured paragraph with no stale duplication.

AI-assisted (OpenCode).

@memorypressure

Copy link
Copy Markdown

Reviewed on Linux: docs-only hardware pin — the row moves to the gfx1100 measurement consistently with the other hw_oracle-pinned rows, tools/hw_oracle is present in the tree, and the case counts and bit patterns are internally consistent with the model the row already documented. The native measurements stand on the author's bench (no AMD hardware on this side). AI-assisted: yes.

The row said the LDS float adder's denormal and NaN behaviour was unmeasured. 49 cases on gfx1100 now show it
flushes denormal inputs and denormal results to zero, so the OpFAdd the translator loops on keeps values the
hardware drops; NaN is quieted with its payload and sign kept, DATA wins when both operands are NaN, and
inf + -inf gives 0xffc00000. The returning form gives the raw pre-op dword.
@PingasMech

Copy link
Copy Markdown

The 49-case gfx1100 result is worth keeping. At 7c4ef193, the same row still says “Not measured” and “Not GPU-verified” immediately before the hardware result. The CPU-test description appears twice, and the bold markup around gfx1100 has lost its opening marker. Current row

There’s a one-row fix already in the branch history. I restored just the previously reviewed row at fda3febc in a local trial merge with main at 0db7fed5. That removes the stale claims and duplication while preserving the full hardware result and its scope.

On Windows, all five LDS addition CPU tests and all eight documentation tests in test_docs_design_rows.py and test_design_contract_rows.py passed with that row restored. The hardware measurement is the author’s. AI-assisted review.

@bobcatchris

Copy link
Copy Markdown
Contributor Author

Updated to 8d7d5da4 in response to @PingasMech's review. I restored the previously reviewed one-row wording from fda3febc verbatim: the stale "Not measured" / "Not GPU-verified" tail and the duplicate CPU-test sentence are gone, and the **Hardware-measured natively on gfx1100** opening marker is intact. The 49-case gfx1100 measurement and its scope are unchanged.

Verification: tests/test_docs_design_rows.py 4/4, tests/test_design_contract_rows.py 4/4, git diff --check clean, and merge-tree clean against current main and against #4161 and #4407. Docs only; no game data. AI-assisted.

Thanks for the exact row and trial-merge evidence.

@kapitche

Copy link
Copy Markdown
Contributor

Tested 8d7d5da merged with main 98fa503 on Linux (WSL), Python 3.12.16: pass

Docs only (docs/design.md, ds_add_f32 row). all 10 tests/test_docs_*.py pass (Python 3.12.16, Linux); tests/semantic/test_lds_add_f32.py also passes (5 tests). Arithmetic in the row checked: 0x00800001 + -0x00800000 is exactly 0x1 (denormal, flushed to +0 per the row); 0x007fffff + 0x00800000 is exactly 0x00ffffff; 1.0 + 2^-24 is a tie to even (1.0) and 1.0 + 3*2^-25 rounds up. The old "Not GPU-verified." is removed, so no contradiction remains. The gfx1100 results (49 cases) can't be reproduced here (no gfx1100).

Minor: 0x00ffffff is called "the tie's" result, but it is the exact sum (representable), not a tie.

@bobcatchris

Copy link
Copy Markdown
Contributor Author

@kapitche reworded at c8cdae27: 0x007fffff + 0x00800000 gives 0x00800000, not the exact sum 0x00ffffff (it is representable, not a tie). All 10 tests/test_docs_*.py pass.

AI-assisted.

@abilliontokens

Copy link
Copy Markdown
Contributor

Tested c8cdae27 on Windows 11 (26200), Python 3.12.10: pass (docs only, code read plus arithmetic). AI-assisted (omp orchestrator). No GPU run: this is a gfx1100 measurement and I have no gfx1100.

  • Merged onto main d974c88a5 (clean): python -I tests/test_docs_links.py, test_docs_design_rows.py, test_docs_table_rows.py, test_design_contract_rows.py, test_docs_list_items.py and test_docs_repo_paths.py all OK.
  • Rechecked the row's words in binary32 (Python struct):
    • the exact sums are 0x00800001 + 0x80800000 = 0x00000001 and 0x007fffff + 0x00800000 = 0x00ffffff, so the row's "not 0x00000001" and "not the exact sum 0x00ffffff" are right, and the measured +0 / 0x00800000 are flushes;
    • 1.0 + 2^-24 rounds to 0x3f800000 and 1.0 + 3*2^-25 to 0x3f800001, as the row says.
  • tools/hw_oracle/ and tests/semantic/test_lds_add_f32.py, both cited in the row, exist on the merged tree. The stale "Not measured" / "Not GPU-verified" text is gone, and the row stays one table line.

No defects found. The row now records a known divergence: the LDS adder flushes f32 denormals, while the translator's OpFAdd keeps them. A follow-up item for the translator could quote this row.

@kapitche

Copy link
Copy Markdown
Contributor

Tested c8cdae2 merged with main 3faac55 on Linux (WSL2), Python 3.12.16: pass.
Docs-only change, so no PR tests; ran tests/test_docs_*.py (10 files, all OK) on the merged tree. Negative control not applicable (no code or tests in the diff). Also ran tests/semantic/test_lds_add_f32.py (5 OK), the test the row cites.
The hw_oracle hardware measurements (49 cases, denormal flush on the LDS adder) are not reproducible on Linux, and the oracle cases are not in the repo, so those figures are taken as stated; the wording keeps the translator's behaviour listed as a known divergence.

@bobcatchris

Copy link
Copy Markdown
Contributor Author

Closing as superseded. origin/main at 1cc6e3c1 already documents the measurement this PR added: the ds_add_f32 / ds_add_rtn_f32 row carries the native gfx1100 (RX 7900 XTX, driver 26.10.1, tools/hw_oracle, 49 cases) result — denormal inputs and results flushed to zero, NaN quieted with its payload and sign kept, DATA winning when both operands are NaN, inf + -inf giving 0xffc00000 — and the normal-sum behaviour (ties to even, -0 + -0, +0 + -0, overflow to ±inf, the raw pre-op dword from _rtn_).

The row has since been edited by others, so the only thing left on this branch is prose cleanup of duplicated sentences ("Not measured: how the LDS adder treats denormals" and a repeated "Not GPU-verified"), which I am not going to re-anchor into a row someone else is editing. If that tidy-up is wanted it is a one-line docs pass on main, not a PR. AI-assisted.

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.

7 participants