Repository navigation
fix(libc): compute log10f and log2f with FreeBSD msun 9.0's algorithms, as titles' libc.prx does - #9873
Conversation
|
The PR pins the 9.0.0 source, records the distinction from The Tested section names base |
9793ee6 to
5441602
Compare
|
Rebased onto current |
MarcZX10
left a comment
There was a problem hiding this comment.
I checked the implementation against the pinned FreeBSD 9.0.0 k_logf.h, e_log2f.c, and e_log10f.c: the polynomial constants, reduction/normalization, split high/low products, and final combinations match. The PR reports exhaustive bit/errno comparisons against three title libc.prx builds and 3/3 Windows focused runs. The current hosted run has conventions/eligibility/labels and several product-adjacent checks passing, with macOS registration/relinker and one write-watch job still pending; Linux/Windows product jobs are skipped. I did not run the math binaries locally. Current main is 1da03c6f, while this head is based on 3bbd2321 (12 commits behind); please rebase and rerun the focused checks once the pending jobs finish. The reported 1-ulp difference for the FMA-contracted third title build remains documented.
|
I checked the implementation against the pinned FreeBSD 9.0.0 |
5441602 to
55659c8
Compare
|
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 (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 |
55659c8 to
7dc1474
Compare
|
Rebased onto current |
7dc1474 to
084659a
Compare
…s, as titles' libc.prx does log10f and log2f returned the host log10 and log2, so their last bit and errno depended on the host: on Windows log10f differs from the libc.prx that titles ship on 13,120,001 of the 2^32 floats and log2f on 2,155,910,778. That libc.prx is msun 9.0's e_log10f.c and e_log2f.c over that release's __kernel_logf, which give 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 some of them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
084659a to
fad8f0e
Compare
|
Main conflict refresh, 2026-10-27 10:18 UTC pass: exact head Linux Release focused rebuild: Exact source/dependency pins, patch-preservation and gitlink proofs, builds, verbose tests, JUnit and lease-push receipts. SHA-256: AI-assisted: yes. |
…below zero Titles' libc.prx returns -inf for log10f(+-0) and log2f(+-0) without raising FE_DIVBYZERO, and raises FE_INVALID with EDOM for every negative input, a negative NaN included. The port computed -two25/zero, which raised the division flag, and set errno for negatives without raising FE_INVALID when (x - x) / zero had a NaN operand. Return the infinity directly and raise through _Feraise; results and errno are unchanged. The console-bits test now checks both flags. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
New head The two flag differences fixed:
Checks (Windows 11 Enterprise 10.0.22621, WinLibs GCC 15.2.0 UCRT r7, Release):
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,
|
# Conflicts: # core/libs/prx/libc/src/Math.cpp
# Conflicts: # core/libs/prx/libc/src/Math.cpp
|
Windows check of exact head Setup: Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7 (the CI toolchain), Release,
|
log10f and log2f carry over FreeBSD msun's e_log10f.c, k_logf.h and e_log2f.c at release/9.0.0. Name each source in the form the exp port uses, followed by that file's copyright and permission notice copied verbatim from that revision. e_log10f.c's sits above Log9Reduce, k_logf.h's above Log9Kernel and e_log2f.c's above log2f. No code changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Added the source notes and licence notices this port was missing ( AI-assisted: yes. |
What
log10fandlog2freturned the host'slog10andlog2, so their last bit and theirerrnodepended on the host. On Windows (UCRT), against thelibc.prxthat titles ship,log10fdiffers on 13,120,001 of the 2^32 floats andlog2fon 2,155,910,778 of them (50 %). Examples, console thenmain:log2f(0x40400990)→0x3fcae940, andlog10f(0x3f7f1a73)→0xbac7bc3b.The titles' versions are FreeBSD msun's
e_log10f.cande_log2f.cas of release/9.0.0, over that release's__kernel_logfink_logf.h. That kernel has a short path for|f| < 2^-9, and the final combination differs from 11.4's. I found it by disassembling thelog10fexport of PPSA07923's copy. 11.4's code, either its float or itsfloat_tpath, differs from the titles by 1 ulp on about 2.4M arguments.This PR adds:
Log9Kernel: that kernel;Log9Reduce: the shared subnormal scaling, special cases and normalisation;errno: as in the titles' copy, every argument with the sign bit set except -0 setsEDOM, negative NaNs and-infincluded. ±0 return-infwithouterrno, unlikelogf(#9841), which setsERANGEthere. Positive NaNs and+infleaveerrnoalone.log2fis imported by 21 andlog10fby 20 of the 22 titles whose relinker registries I audited, for example PPSA01528, PPSA04158 and PPSA09614.Tested
Main conflict refresh, 2026-10-27 10:18 UTC pass: exact head
fad8f0e3acd059f4a86db1d5010d18c84fd2b1c3on tested main3fea2a937ba9fbab2f06c51691fe0c5763659aa3. The topic implementations and fixtures are retained alongside current main's newer math functions and coverage.Linux Release focused rebuild:
guest_mathandguest_math_exacteach pass three repetitions: 6 passes, zero skips. Conventions, whitespace and merge checks pass. Every refreshed head's submodule pointers match the pinned main; the private dependency checkouts used for the gates are aligned. No new negative-control, Windows, console, title, GPU, full-suite or performance run is claimed. Earlier measurements below retain their original exact pins. Fulfilled merge-order dependencies have been cleared from the checklist; open prerequisites remain.Exact source/dependency pins, patch-preservation and gitlink proofs, builds, verbose tests, JUnit and lease-push receipts. SHA-256:
702c4110ee9dde421c2dd5e057ed53a2df05e0cf7b01f67e8fb9cb779e332f7c; downloaded copy verified.Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
BUILD_TESTING=ON,mainf6075c2.Exhaustive comparison: a scratch loader runs the decrypted
libc.prxof PPSA07923, PPSA05916 and PPSA13934 natively and supplies__error. It compared each copy'slog10fandlog2fwith this build's for all 2^32 arguments, bits anderrno.errnoeverywhere, for both.errnoeverywhere. Its FMA-contracted build differs by 1 ulp on 930,947 (log10f) and 61,530 (log2f) arguments.guest_math: the newCheckLog10fLog2fConsoleBitshas 21 inputs, each checked through both functions with the console's results anderrno: values where UCRT differs, exact powers (1, 2, 8, 100), the smallest subnormal and normal,FLT_MAX,+inf, ±0, a negative subnormal, -1,-inf, NaN payloads of both signs and the neighbours of 1.guest_math(including the existinglog10f(100) == 2check) and 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.Overlap: two of the conflicts are with my own PRs and come from neighbouring lines in
Math.cpp. Keeping both changes resolves each.log2fis defined on the line afterlogf, which fix(libc): compute logf with FreeBSD msun's algorithm, as titles' libc.prx does #9841 replaces.log10fis the line aftertanf, which fix(libc): compute sinf, cosf, tanf and sincosf with FreeBSD msun's algorithms, as titles' libc.prx does #9857 moves.tools/pr_overlap.pyalso finds onedocs/dev/debt/libc.mdadjacency with fix(tests): skip the 1023-byte guest path check on macOS hosts #8284. The branch merges cleanly with 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, fix(libc): compute expf with FreeBSD msun's algorithm, as titles' libc.prx does #9839, fix(libc): compute exp2f with FreeBSD msun's algorithm, as titles' libc.prx does #9844, fix(libc): compute powf like the libc.prx that titles ship #9850, fix(libc): compute cbrtf with FreeBSD msun's algorithm, as titles' libc.prx does #9862 and fix(libc): compute tanhf with FreeBSD msun's algorithm, as titles' libc.prx does #9867.Independent Linux review: Dom3005's report tested head
55659c815merged 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.Not tested: macOS, a console, the floating-point exception flags.
Refreshed focused validation (2026-10-23): head
7dc14749f4, rebased ontomaind271a49580. The only conflict was thedocs/dev/debt/libc.mdlist, and both entries are kept.guest_mathandguest_dinkumware_internalspass in three runs out of three on this exact head (Windows, GCC 15.2.0 UCRT r7, Release). Withmain'sMath.cppand these tests,guest_mathaborts. Conventions andgit diff --checkpass. This refresh does not repeat the exhaustive title-library comparisons above, which keep their original base. Earlier refresh:55659c815conmain7c900bbc21, 8/8 math/libc tests 3/3.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 did72641c92f6f8; fix(libc): compute sinf, cosf, tanf and sincosf with FreeBSD msun's algorithms, as titles' libc.prx does #9857 merged ate9a551d6f40e; present in audited main3fea2a937ba)AI-assisted (Claude Code).