Repository navigation
fix(libc): compute tanhf with FreeBSD msun's algorithm, as titles' libc.prx does - #9867
2111 commits merged into
Conversation
|
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.
|
|
The implementation and exhaustive comparison report are detailed, and the focused Windows |
|
Rebased onto current |
3a7beb5 to
5da9d16
Compare
|
Thanks for the exact-head Windows |
|
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 |
harisibrar1
left a comment
There was a problem hiding this comment.
Checked against main 3875f8c and FreeBSD msun s_tanhf.c/s_expm1f.c at release/9.0.0, 10.0.0, 11.4.0, 12.0.0 and 13.0.0:
- The port matches release/11.4.0 line by line: volatile
tinyin tanhf, run-timehugeand the(u_int32_t)(0x7f+k)<<23twopk in expm1f. 9.0.0 and 10.0.0 differ only in qualifiers and that twopk encoding, which give the same bits over tanhf's argument range, so the 11.4.0 links are right. - A float32 emulation of msun's tanhf reproduces all 22 expected values in
CheckTanhfConsoleBits, and a correctly-rounded tanh misses 6 of the 7 non-trivial ones, so the test separates the two. - It still merges cleanly with current main.
Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed exact head 5da9d16147a3bc1324ddf5ba22a210c9ed57b002. The tanhf/expm1f port matches FreeBSD 11.4 msun's control flow, and the edge tests cover signs, small values, infinities, NaNs, errno preservation, and key boundaries. The source and test files are unchanged between the tested base and current upstream main; only the adjacent debt document changed.
I independently ran the PR's 22-case CheckTanhfConsoleBits on Linux using the exact PR Math.cpp and test source. The focused check passed. The available local full guest_math CTest build uses an older source snapshot and aborts first at its strtol check, so I am not counting that as a full-suite pass. Independent reviewer evidence on this exact PR head reports five passing Linux guest_math runs; the author reports repeated Windows runs and exhaustive bit comparison. Product CI jobs remain skipped.
5da9d16 to
82668d5
Compare
|
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). |
Additive conflicts with main's newer libc changes: the debt list keeps both sides' entries (per entry) and GuestMath.cpp keeps both sides' test functions and calls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged current
AI-assisted: yes (Claude Code) |
8af97c6 to
3c22f70
Compare
|
Refreshed onto main Fresh Linux: all four focused groups pass 3/3 before and after the expected main-Math negative failure; exact-math/Dinkumware controls pass, restoration is byte-identical, and conventions/whitespace pass. The description links exact-head logs and preserves historical independent reports with their measured pins. No new Windows/module/title rerun is claimed. AI-assisted: yes. |
…entory-exports-20261030 feat(audiodec): add missing inventory exports
…ry-exports-20261030 feat(font): add missing font inventory exports
…ngengine-inventory-exports-20261030 feat(videostreamingengine): add missing named inventory exports
…dation-20261029 fix(ngs2): validate grain size in 64-sample units
…el-input-20261029 fix(tools): validate PR records before labeling
…ranges-20261029 fix(tools): bound ELF annotation table reads
…ring-bounds-20261029 fix(tools): bound sampler COFF string reads
…shell-inventory-exports-20261030 feat(usbstorage): add missing shell inventory exports
…ngp-inventory-exports-20261030 feat(videorecordingp): add remaining inventory exports
…de-parameter feat(libSceGameLiveStreaming): implement sceGameLiveStreamingScreenInitializeSeparateModeParameter
…exports feat(libScePSNowGkp): declare 5 callable exports
feat(libSceMbus): declare 4 callable exports
feat(libSceHmd): declare 19 callable exports
…inventory-exports-20261030 feat(keyboard): add missing debug inventory export
…command-buffer-release fix(agc): free a completed batch's command buffer instead of keeping it
…nventory-exports-20261030 feat(mbus): add missing debug inventory export
…parate-mode-parameter feat(libSceSocialScreen): implement sceSocialScreenInitializeSeparateModeParameter
feat(libSceCesCs): add the ISO-2022-JP profiles, context and string conversions
…ext-320-exports feat(libSceNpSpeechToText): declare 7 callable exports
…t-dialog-320-exports feat(libSceConnectAccountDialog): declare 7 callable exports
…ument-codes fix(libSceNpUniversalDataSystem): return the console's codes for bad event and property arguments
…king-memory-size feat(libSceMoveTracker): implement sceMoveTrackerGetWorkingMemorySize
…blocking-count docs(libSceAudioOut): count the blocking values passed to sceAudioOut2ContextPush
…mory feat(libSceVrHand): implement sceVrHandQueryMemory
|
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,
|
|
Qualification update — 2026-10-30, repeat 2 Integrated pinned main Actual Linux libc/focused binaries rebuilt from this final head; Focused Linux CPU scope only: prior Windows/SDK/reference reports keep original pins. No fresh Windows, console, SDK-module, title/GPU or speed measurement is claimed by this report. AI-assisted: yes. Evidence: https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/owned-math9-maine471-linux-20261030-repeat2.tar.gz (SHA256 5da4ce1732b45bb3fc566c31078c8c9ae8bf0c403654dfc60d15ee28490e20bf). AI-assisted: yes (Codex). |
88b7503
What
tanhfreturned the host'stanh, so its last bit depended on the host. On Windows (UCRT) it differs from thelibc.prxthat titles ship on 69,671,910 of the 2^32 floats. For example, the console givestanhf(0x3f000555)=0x3eeca303andtanhf(0xbf400ddd)=0xbf22a163.The titles'
tanhf(NIDSAd0Z3wKwLA) is FreeBSD msun'ss_tanhf.c, which calls msun'ss_expm1f.c. This PR adds:tanhf:1 - 2/(expm1f(2|x|) + 2)for|x| >= 1,-t/(t + 2)witht = expm1f(-2|x|)below 1,±1from 9 up,xfor tiny arguments, and1/x ± 1for the infinities and NaN;TanhfExpm1: a full port ofexpm1ffor it, withhugeread at run time. The existingSinhfExpm1only covers the positive argumentssinhfpasses, andtanhfalso needs negative ones.The exported
expm1fis unchanged. None of the copies checked setserrnohere, and neither does this.tanhfis imported by 3 of the 22 titles whose relinker registries I audited: PPSA02630, PPSA16064 and PPSA25872.Tested
Current Linux refresh: head
3c22f70a81fdc116e8a22df82791b3295e9011ef, one topic commit directly on mainda6c581a02dbd3983ccc70fff92169acce802f77, without merge commits. The reviewedTanhfExpm1,tanhf_nid_postfixandCheckTanhfConsoleBitsare unchanged from previous public head8af97c6fb0309fa6c583c1a4d1f618c93ebb7a76. Current main math, test calls, canonical public declarations and debt entries are retained. 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.Exact-head Linux logs, negative control and preservation proof (SHA-256
c72326ce62ebac6d06a6e4a35c66122ec79c48fdf1b24413e5553765182039a5). The other stack head in the preservation/config receipt is local preparation for #10222, not a claim that its separately requested #10226 integration qualification is complete.Historical Windows/module measurements and independent review reports: retained below with their original measured revisions. No new Windows, title, console, exception-flag or performance claim.
Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
BUILD_TESTING=ON,maind6e7ab4.libc.prxof PPSA07923, PPSA05916 and PPSA13934 natively and supplies__error. It compared theirtanhfwith this build'stanhf_nid_postfixfor all 2^32 arguments.errno.guest_math: the newCheckTanhfConsoleBitshas 22 cases with the console's results, each also checking thaterrnois untouched: values in eachexpm1frange where UCRT differs, of both signs, the tiny shortcut, ±0, the smallest subnormal, ±1, the edges at 9,FLT_MAX, the infinities and NaN payloads of both signs.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 cleanly with my other math PRs (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 logf with FreeBSD msun's algorithm, as titles' libc.prx does #9841, 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 sinf, cosf, tanf and sincosf with FreeBSD msun's algorithms, as titles' libc.prx does #9857, fix(libc): compute cbrtf with FreeBSD msun's algorithm, as titles' libc.prx does #9862).tools/pr_overlap.pyfinds one adjacency indocs/dev/debt/libc.mdwith docs(libc): correct stale rmdir, nanf and bad_optional_access debt statements #9364 (next to therenameentry); keeping both entries resolves it.5da9d1614merged 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.Current Linux qualification (2026-10-28)
Rebased onto
main2227f1366188cda5699dd20e2e756a18006a5d4b. Linux CPU validation on 2026-10-28 at56b82ac96e6136cd4d10648f8174dda62cdfd9cb(Arch Linux 7.2.9, AMD Ryzen 9 7950X, GCC 16.2.1, Ninja Release, BUILD_TESTING=ON).libc,guest_math_testsandguest_math_exact_testsrebuilt from this exact source.guest_mathandguest_math_exacteach passed three consecutive runs (6/6, no skips); the same two suites each passed three runs on the pinned main (6/6). Conventions and whitespace checks pass.Exact source pins, preservation proofs, dependency checks, build logs and JUnit, SHA-256
1176269c9e6948b5252a5db9e660978d7f978fb2d9f4ed6c68bc050b10b5ae68. This is focused Linux CPU qualification; earlier Windows/title/reference measurements retain their original pins. No new title or performance result is claimed.Qualification update — 2026-10-30, repeat 2
Integrated pinned main
e471817c68d4e1b1e44b0ce369ed88bafe4ae8edata06ed844e352d33f89f6ed015da3203745330acd, retaining original topic commits as ancestors.Actual Linux libc/focused binaries rebuilt from this final head;
guest_math,guest_math_exact,guest_dinkumware_internalseach pass three consecutive runs (9 runtime passes), plus public_headers. Conventions against current origin/main and whitespace pass. Pinned main passed all seven runtime groups plus the header audit three times (24 runs). Full source/function/test/debt/header and 31 recursive dependency / 17,742 tracked-blob proofs are attached. Later main1c6b316cf762has 17 off-topic commits, no relevant libc/numeric/qsort/gitlink changes, and all 9 merge previews are clean; those preview trees were not executed.Focused Linux CPU scope only: prior Windows/SDK/reference reports keep original pins. No fresh Windows, console, SDK-module, title/GPU or speed measurement is claimed by this report. AI-assisted: yes. Evidence: https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/owned-math9-maine471-linux-20261030-repeat2.tar.gz (SHA256 5da4ce1732b45bb3fc566c31078c8c9ae8bf0c403654dfc60d15ee28490e20bf).
AI-assisted: yes (Codex).
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).