Repository navigation
fix(libc): compute logf with FreeBSD msun's algorithm, as titles' libc.prx does - #9841
Conversation
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed the 56-line port against FreeBSD 11.4 e_logf.c, including subnormal scaling, normalization, polynomial branches, and special-value handling. I also compiled the exact PR Math.cpp and ran a focused local harness covering all 21 added bit/errno cases; it passed. The PR reports exhaustive 2^32-input comparisons against three bundled title libraries, with the documented 1-ulp FMA variant. The hosted Linux/Windows product jobs are skipped by policy, and the Windows relinker and macOS x86-64 relinker checks are still pending at review time.
|
I compared the arithmetic path with the primary FreeBSD 11.4 The PR base is |
|
@MarcZX10 thanks for checking it against the source. Same as on #9784 and #9844: I'll rebase and rerun |
|
Thanks for confirming the order among #9839 and #9844. The separate current-main item remains: CONTRIBUTING says to keep the branch up to date with |
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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.
|
0300d6a to
551625b
Compare
|
Thanks for the detailed final-head Windows run. I compared current upstream |
…c.prx does logf returned the host log, so its last bit and errno depended on the host: on Windows the bits differ from the libc.prx that titles ship on 13,225,175 of the 2^32 floats. That libc.prx is msun's e_logf.c, setting ERANGE for +-0 and EDOM for every argument with the sign bit set. The port gives the same bits and errno as PPSA07923's and PPSA05916's copies for every argument; the FMA-contracted copy of PPSA13934 differs by 1 ulp on 961,881. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rebased onto current |
551625b to
a22e959
Compare
|
Linux run (the description lists Linux as not tested). Docker on Windows: Ubuntu 26.04, GCC 15, glibc 2.43, WSL2 kernel 6.6, Release,
No findings. AI-assisted: yes |
What
logfreturned the host'slog, so its last bit and itserrnodepended on the host. On Windows (UCRT) the bits differ from thelibc.prxthat titles ship on 13,225,175 of the 2^32 floats, for example0x3f7f0a10→0xbb76666fand0x40400de0→0x3f8ca894.The titles'
logf(NIDRQXLbdT2lc4) is FreeBSD msun'se_logf.c.logfnow computes it the same way:2^25;[sqrt(2)/2, sqrt(2));|f| < 2^-9path;Lg1–Lg4polynomial with its two branches;vzeroread at run time, as msun'svolatileread does.errno: msun sets none, but the titles' copy setsERANGEfor ±0 (result-inf) andEDOMfor every argument with the sign bit set, negative NaNs and-infincluded. Positive NaNs and+infleaveerrnounchanged. These map onto msun's own branches, so the port setsERANGEin the zero branch andEDOMin theix < 0branch.logfis imported by 20 of the 22 titles whose relinker registries I audited, for example PPSA01528, PPSA02630 and PPSA04158. This is thelogfcounterpart of #9839 (expf).Tested
Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
BUILD_TESTING=ON,main11f976b.libc.prxof PPSA07923, PPSA05916 and PPSA13934 natively and supplies__error. It compared theirlogfwith this build'slogf_nid_postfixfor all 2^32 arguments, bits anderrno.errnoeverywhere.errnoeverywhere. The bits differ by 1 ulp on 961,881 arguments, because that copy is an FMA-contracted build, as withexpf(fix(libc): compute expf with FreeBSD msun's algorithm, as titles' libc.prx does #9839) andasinf(fix(libc): compute asinf with FreeBSD msun's algorithm, as titles' libc.prx does #9771).guest_math: the newCheckLogfConsoleBitshas 21 cases with the console's results anderrno: values where UCRT differs (a subnormal, both sides of 1, and larger values), 1, 2, the smallest subnormal and normal,FLT_MAX,+inf, the neighbours of 1, a NaN payload, ±0, a negative subnormal, -1,-infand a negative NaN.guest_mathand the libc tests (8) pass in three runs out of three. Withmain'sMath.cppand this test,guest_mathaborts in aRequire.python tools/check_conventions.py --base origin/mainandgit diff --checkpass. The branch merges without conflicts with fix(libc): keep the sign of a failed strtof and match libc.prx strtof ERANGE #8865, fix(libc): compute asinf with FreeBSD msun's algorithm, as titles' libc.prx does #9771, fix(libc): compute atanf with FreeBSD msun's algorithm, as titles' libc.prx does #9777, fix(libc): compute atan2f with FreeBSD msun's algorithm, as titles' libc.prx does #9784 and fix(libc): compute expf with FreeBSD msun's algorithm, as titles' libc.prx does #9839.a22e959cdmerged cleanly ontomainfcd455870: Ubuntu 26.04 in Docker on Windows, GCC 15, glibc 2.43, WSL2 kernel 6.6, Release,BUILD_TESTING=ON. The reviewer reports five passingguest_mathruns (--repeat until-fail:5). Keeping this PR's test while restoring main's changed production sources makes the test fail on Linux as well. This supplies a Linux regression comparison in addition to the Windows evidence above; it is reviewer-supplied evidence for those revisions, not a local rerun or a latest-main claim.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).