Repository navigation
fix(libc): compute cbrt with FreeBSD msun's algorithm, as titles' libc.prx does - #10283
Conversation
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Linux run at this PR's exact head Arch Linux, kernel 7.2.9, Ryzen 9 7950X, g++ (GCC) 16.2.1 20260810, glibc 2.44, x86-64. Release,
This is the focused test only; no title, console or floating-point exception flags were checked. AI-assisted: yes (Claude Code). |
harisibrar1
left a comment
There was a problem hiding this comment.
Checked against main 7c2400d and FreeBSD msun s_cbrt.c at release/9.0.0, 10.0.0, 11.4.0 and 12.0.0:
s_cbrt.cis the same code in all four releases (only a comment typo fix in between), and the port matches it exactly: B1/B2, the 2^54 subnormal path, the polynomial grouping, the 23-bit rounding and the Newton step. All five P constants round to the hex values in msun's comments.- I re-ran all 25
CheckCbrtConsoleBitsvectors through a Python emulation of the same operations in plain IEEE double, and every one matches.0xc050f6b81592ae3fis a nice case: msun gives...43fawhere the correctly rounded result is...43f9, so the test really pins msun. - The branch is on 15e71db and no longer merges into main: docs/dev/debt/libc.md conflicts because main's
coshfentry sits where thecbrtentry goes, and keeping both lines resolves it. Math.cpp and the tests merge cleanly. Could you rebase and update the "Based on current main" and "Depends on: #10274" lines? The branch doesn't seem to need #10274, which is still open.
Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
be09291 to
4641dad
Compare
|
Rebased onto main The independent Linux Release libc/math build passed; |
Additive conflicts with main's newer libc math changes: the debt list keeps both sides' entries (per entry), the GuestMath.cpp test functions and calls from both sides are kept, and Math.cpp keeps both sides' independent changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged current
AI-assisted: yes (Claude Code) |
|
Windows run of 09bd784 merged onto Built |
There was a problem hiding this comment.
Reviewed the current head 09bd784. The cbrt translation follows the cited FreeBSD msun operation order, including subnormal scaling, bit-based seed, polynomial grouping, 23-bit truncation and Newton correction. The added 25 bit-pattern vectors cover signed zero, subnormals, normal boundaries, finite extremes, infinities and NaN payloads, and explicitly assert that errno is unchanged. I verified the current diff against upstream/main, a clean merge-tree result, and passing convention/diff checks. The exact head also has reported focused Linux and Windows runs (guest_math; Windows additionally guest_dinkumware_internals) with a negative control showing guest_math fails when the implementation is replaced by main host cbrt. Hosted product jobs remain skipped, as documented. I found no outstanding blocking issue.
09bd784 to
7e0150e
Compare
|
Refreshed onto main Fresh Linux: all four focused groups pass 3/3 before and after the expected main-Math negative failure; exact-math and Dinkumware controls pass, restored library bytes match, and conventions/whitespace pass. The description links complete evidence and keeps the independent Windows report attributed to its previous measured head. No Windows/title/module rerun is claimed. AI-assisted: yes. |
7e0150e to
26e8bc5
Compare
|
Refreshed onto main Fresh Linux Refresh patch, preservation hashes and build/test logs — SHA256 |
…c.prx does cbrt returned the host's cbrt, whose last bit differs from the titles' copy on Windows on 99,933,841 of 320 million random arguments, about 31%. The titles' copy is FreeBSD msun's s_cbrt.c, and cbrt now computes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26e8bc5 to
035d9c0
Compare
Conflicts with main's newer libc changes resolved without changing either side: the debt list keeps each side's entry changes (per entry, deletions included), GuestMath.cpp keeps both sides' test functions and calls, and Math.cpp differs from main by exactly this branch's own changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged
AI-assisted: yes (Claude Code) |
|
@JJenkx heads-up: the last "merge main" here also moved submodule pointers back ( |
|
@oneandonlydean thanks, and sorry for the noise. The cause was on my side: I merged The same refresh hit five more branches (#10345, #10229, #10222, #10226, #10113). Each now has the same one-commit pointer restore on top, and none differs from AI-assisted: yes (Claude Code) |
|
Linux run at this PR's exact head Arch Linux, kernel 7.2.9, Ryzen 9 7950X, g++ (GCC) 16.2.1 20260810, glibc 2.44, x86-64. Release, Passed in each of 3 runs, exit code 0 each time, with no failed, skipped or not-run tests:
These are the focused tests only; no title or console was used. AI-assisted: yes (Claude Code). |
|
Re-checked at the current head A scratch loader runs the decrypted AI-assisted: yes (Claude Code). |
|
For prioritisation: in a Windows import audit of the 74 extracted titles on our shared library ( AI-assisted: yes (Claude Code). |
|
Supplemental Linux floating-environment qualification of the merged cube-root implementations: 49,152 sampled The actual frozen SDK is main Each export: 128 distinct encodings (special values, signed subnormals, finite/cube boundaries and deterministic random patterns), all three x87 precisions, independent four-way x87 and SSE rounding modes, four DAZ/FTZ states and two pending-flag states. Results match bit-for-bit, with equal errno, raw x87/MXCSR flags, TOP and controls. A separate expected-state check confirms both providers retain caller controls and seeded flags, with TOP zero. Both actual function owners were checked; mapped providers, the frozen bank, reference and original asset hashes remain unchanged. Probe, comparison rows, expected-state analysis and provenance — SHA-256 This is sampled, masked-exception coverage on one bundled SDK version and one Linux CPU. It does not qualify other FMA-contracted variants, unmasked traps, physical-console execution, game performance or exhaustive floating-point behavior. The original module still uses SDK dependencies. The AI-assisted: yes |
What
cbrtreturned the host'scbrt, so its last bit depended on the host. On Windows (UCRT) it differs from thelibc.prxthat titles ship on 99,933,841 of 320 million random arguments, about 31%. For example,cbrt(0x3ffa0ccfe147c94d)(about 1.628) is0x3ff2d29f09b6d6a3on the console and0x3ff2d29f09b6d6a4here.The titles' copy (NID
5ZkEP3Rq7As) is FreeBSD msun'ss_cbrt.c.cbrtnow computes it:B1/B2exponent estimate, with the 2^54 scaling for subnormals;P0–P4polynomial step;tto 23 bits;It sets no
errno, as the titles' copy does not.Tested
Refreshed onto main
5a2744c55efcedf4c5f1b190af46fccbe5df1310as26e8bc5f43e7fa8b4082ff1c06f771c53c34c3e7, one topic commit with no merge commits. The only conflict was an additive libc debt append: all current-main entries and this PR's distinct cbrt entry are preserved. The implementation andCheckCbrtConsoleBitsbodies are byte-identical to previous public head7e0150e9b0911d5af3dbb2ae859ae8bc5104e93c.Fresh Linux
libc,guest_math_testsandguest_math_exact_testsbuilds pass. Both focused CTest groups pass three times (6 passes); conventions, whitespace and merge-tree checks pass. This is rebase qualification. The original large Windows and bundled-SDK comparisons were not rerun and retain their prior head attribution, including the recorded FMA variant and exception-flag limitations.Refresh patch, preservation hashes and build/test logs — SHA256
c2816446e25860f967e9f77a750958911893cbd89189fb54c014e250e0999e56; uploaded archive downloaded and hash-verified.Independent Windows regression report on previous public head (ycbuzi): PR head
09bd784583aca366f165ef3b91245d121fcf3405was cleanly integrated onto mainfa515def85as91ba4d5371on Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 UCRT r7, Release withBUILD_TESTING=ON. The reporter builtlibc,guest_math_testsandguest_dinkumware_internals_testswithout reported errors or warnings; both focused groups passed twice usingctest --repeat until-fail:2. Their negative control replacedMath.cppwith main's version:guest_mathaborted while the Dinkumware group still passed. This is attributed independent integration/regression evidence; original-module matrices and titles were not rerun.Current Linux refresh: head
7e0150e9b0911d5af3dbb2ae859ae8bc5104e93c, one topic commit directly on mainda6c581a02dbd3983ccc70fff92169acce802f77, without merge commits. Bothcbrt_nid_postfixandCheckCbrtConsoleBitsare unchanged from previous public head09bd784583aca366f165ef3b91245d121fcf3405. Newer main math implementations, regression calls, canonical public declarations and debt entries are retained. No pending math port is required: Depends on remains none.Fresh Linux x86-64 Release validation:
guest_math,guest_math_exact,guest_dinkumware_internalsandpublic_headerseach pass three consecutive runs, then all four pass three more after negative-control restoration. With only productionMath.cppreplaced by main,guest_mathaborts as expected while exact-math and Dinkumware controls pass. Restoring the candidate produces a byte-identicallibc.prx. Conventions and whitespace checks pass. The independent Windows report above and original-module comparisons below remain pinned to their measured heads; no new Windows, title, console, exception-flag or performance claim.Exact-head Linux build/tests, negative control and preservation proof (SHA-256
2f58ea7138bff280a0c9f58642a45b20b056dbd82d785d6dabcdc2145b21ddfc).Historical Windows/module measurements (previous head): the following results are retained from the original submission; “console” below refers to the bundled SDK modules executed on Windows, not a physical console measurement.
Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
BUILD_TESTING=ON,main15e71db.Comparison: a scratch loader runs the decrypted
libc.prxof PPSA07923, PPSA05916 and PPSA13934 natively and supplies__error. It compared theircbrtwith this PR's code, checking result bits (NaN payloads included) anderrno, on:Results:
errnois never set.errno. The bits differ on 32 random arguments, because that copy is an FMA-contracted build.guest_math: the newCheckCbrtConsoleBitshas 25 cases with the console's results:±DBL_MAX, the infinities and NaN payloads of both signs;Each case checks that
errnostays unchanged.guest_mathandguest_dinkumware_internalspass in three runs out of three on the exact head.Negative control: with
main'sMath.cppand these tests,guest_mathaborts in aRequire, whileguest_dinkumware_internalsstill passes.python tools/check_conventions.py --base origin/mainandgit diff --checkpass.Overlap: other math ports can share source, test and debt insertion anchors. This cbrt implementation does not call any pending math port; textual overlap does not require the previous series order.
Not tested: macOS, a physical console, floating-point exception flags, and
cbrtl. Windows/module sampling above remains historical; current Linux validation is listed first.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)sinhfentry didAI-assisted (Claude Code; Codex for the Linux rebase and validation).