fix(libc): implement remaining lgammal finite domains #24360
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24360"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-20T15:08:18Z.
Unresolved maintainer requirement: coefficient provenance still needs an established permitted source with its licence notice or a genuine generator. This CMake maintenance establishes neither and does not resolve that request. Passing numerical tests is not provenance evidence.
What
Completes the finite-argument portion of
lgammalafter #24306. Moderate inputs now use recurrence, rational corrections and split-log reconstruction; twelve negative-root intervals use shifted polynomials. NaNs and infinities are classified before evaluation. The remaining host gamma fallback is removed.For example, the bundled reference returns the last mantissa bit
...ac47forlgammal(-2.5L)in the default extended precision mode, while host math returns...ac48. Exact inputs 1 and 2 also raise inexact in the reference even though the result is zero. The new implementation preserves those results and flags under caller-selected precision and rounding.The constants and operation order were characterized against PPSA21564's bundled libc in a guarded CPU fixture. No original binary or disassembled code is included. This adds no export and makes no title-unblock claim.
Tested
Partial independent coefficient audit (2026-11-26): at unchanged public head
8a26b67d16747938b3175aaff19f38eea8ee950d, a newly authored standalone prototype regenerates all 215 root Taylor coefficients and 24 high/low center pieces from mathematical definitions, without reading or embedding the coefficient or split-center tables in its generation path; rational-center and degree/layout choices remain explicit parameters. Pure-Python mpmath 1.3.0 at its pinned source revision gives identical results at 320 and 384 bits; a one-ulp target perturbation is rejected while generated values stay unchanged. Prototype, source pin/licence, portable recipe and verified outputs (SHA-2562dfb74d537194df59d1c5da416d8867ed80d9b21db385e182440222ed3fb2366, nine payload hashes verified after anonymous download). The 37 rational coefficients, interval-threshold/degree selection and historical source/licence remain unresolved. This is not a complete committed generator, a provenance resolution, or new runtime/console qualification. Numerical source and fixtures are unchanged.CMake integration maintenance (2026-11-26): head
8a26b67d16747938b3175aaff19f38eea8ee950dincorporates main37749b6cd5670e4183753d13efb4865792358f4d; 6/6 focused Linux raw-provider CPU CTests pass, zero skips. The large/finite registrations now use libc test fragments with the originalBUILD_TESTING, Linux trap and Windows PATH behavior retained. Numerical implementation and fixture bytes match the preceding public head. The five selected full branches also merge without resolutions and pass 15/15 CPU CTests. Logs, pins, maintenance patches and loader/hash receipts (SHA-25693f3e19a0c6c81d4473bd0964fd01158956aaa30b03a0e6676d89e77bacb8eea, 60 payloads, anonymously downloaded and verified). No new full-SDK, original-module differential, Windows, console, title/GPU or performance run is claimed.Arch Linux, GCC 16.2.1, Release, candidate
f32b9754e630bcb30a47d88862ca2569a5326d3f, against parent #24306 (fab4bc0f32290667f21adbcd0dd35be00a66a3c0).libsSDK and relinker build passed. Seven focused CTests passed:guest_lgamma_finite(2,292 reference cases),guest_lgamma_large,guest_lgamma_large_trap_inexact,guest_lgamma_poles,guest_math,guest_math_exact, andguest_floating_point.7fa48cd1c6cda62b4ebe86575085199a33e08c1dis clean; the test results above remain pinned to the exact candidate, rather than claiming a retest of that merge.Full test evidence and reproducer (SHA-256
25256a9df6b377ed413b33000924ad22d240310967361366779d354b251c31c4, 89 payloads; downloaded and verified).Not tested: console execution, exhaustive inputs, or enabled-exception behavior in the new finite paths. No game, GPU, FPS or loading-time gain is claimed.
Independent Linux validation: PrivacyOnion reported Ubuntu 24.04 / GCC 13.3 / Ninja Release at
f32b9754e6: conventions and all three gamma test targets built cleanly, and all four focused CTests passed. Restoring main's implementation while retaining the fixtures made the finite, large and pole tests fail; restoring the change made all four pass. The first-trap fixture also passed on the negative control, so that test alone does not distinguish the implementations. This is contributor-reported testing.Windows follow-up: the completed run reports head
7799db88651bd4c046804d7e4475e4e8a77f6454merged onto main0c6c897e9easead9a55c54, on Windows 11 Enterprise 22621 / WinLibs GCC 15.2 UCRT / Release. After the inherited guest-fenv fixture fixes,guest_lgamma_finite,guest_lgamma_largeandguest_lgamma_poleseach passed all three runs, with none skipped.guest_lgamma_large_trap_inexactis registered only on Linux and was not run on Windows. This summarizes the linked existing report; it is not a new execution or a Windows repetition of the 30,492-comparison SDK/reference matrix.Documentation-only stack follow-up
53137577143acarries the directed-rounding reference NaN/invalid note from #24306 while retaining this branch's removal of the host-fallback limitation. Implementation and test blobs are unchanged from7799db88651b; conventions, debt-fold and diff checks pass. The execution results above retain their stated commit pins; no new math run is claimed.Earlier exact-head Linux fixture check (2026-11-24): the published result records head
53137577143aon Arch Linux 7.3.5 / Ryzen 9 7950X / GCC 16.2.1 / Release Ninja.guest_lgamma_large,guest_lgamma_large_trap_inexact,guest_lgamma_finite,guest_lgamma_poleseach passed all three runs (12/12 executions). This covers the then-committed fixtures after the guest-fenv test corrections. It is the existing CPU-only run, not a new execution or a repeat of the original-module comparison matrix; the historical matrix and Windows results retain their stated source pins.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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T15:16:47Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change based on the source and fixture code reviewed; the author-reported test results were not run by me.
What I ran
Reviewed head
f32b9754e630bcb30a47d88862ca2569a5326d3f. No build or tests were run. The author reports a clean merge-tree check against main; I did not run that check.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not run the reported SDK build, focused CTests, reference comparisons, negative control, or merge-tree check. Console execution, Windows behavior, exhaustive inputs, and enabled-exception behavior are unverified, as noted in the change documentation. The prepared review folder lists no excluded changed files; I read all nine changed files:
core/libs/prx/libc/CMakeLists.txt,core/libs/prx/libc/src/Math.cpp,core/libs/prx/libc/src/MathGamma.cpp,core/libs/tests/GuestLgammaFinite.cpp,core/libs/tests/GuestLgammaLarge.cpp,core/libs/tests/GuestLgammaPoles.cpp, and the threedocs/dev/debt/changes/lgammal-*.mdfiles.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-20T15:32:46Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
f32b9754e6:tools/check_conventions.pypassed.guest_lgamma_finite_tests,guest_lgamma_large_tests,guest_lgamma_poles_testsbuilt cleanly.guest_lgamma_large,guest_lgamma_large_trap_inexact,guest_lgamma_finite,guest_lgamma_poles):core/libs/prx/libc/src/Math.cpp,core/libs/prx/libc/src/MathGamma.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T21:07:43Z.
Review: COMMENTED
Reviewed — no blocking findings
The reviewed source and targeted test code show no verified blocking defect; this review is incomplete because I did not inspect every changed test and documentation line or run the checks.
What I ran
Read the prepared diff and changed-file manifest, then inspected
MathGamma.cpp, the CMake test registrations,Math.cpparound the removed host fallback, and targeted portions of the finite, large-argument, and pole tests. No build or tests were run.Results
Findings
Blocking
None verified in the portions inspected.
Non-blocking
None.
Not verified
I did not read all lines of
GuestLgammaFinite.cpporGuestLgammaLarge.cpp, nor the three debt change notes. I did not run builds, tests, console execution, Windows checks, or enabled-exception checks. The description's test results are contributor-reported.Files read:
core/libs/prx/libc/CMakeLists.txt,core/libs/prx/libc/src/Math.cpp,core/libs/prx/libc/src/MathGamma.cpp,core/libs/tests/GuestLgammaFinite.cpp(tail),core/libs/tests/GuestLgammaLarge.cpp(head),core/libs/tests/GuestLgammaPoles.cpp, and the review description, commits, manifest, and diff. The manifest lists nine changed files; all are included, but only the files and portions identified above were read. No files were excluded by the supplied manifest.To get this to a good state
Nothing is required. The review is incomplete, so its evidence does not support approval.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T08:43:48Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this draft review; the implementation and reported checks provide useful evidence, but I could not verify every changed line or independently run the checks.
What I ran
Reviewed head
53137577143a0f6d885c282f9f54e0cb9d198699. No commands or tests were run; the prepared bundle and pinned repository reader were used for inspection.Results
Findings
Blocking
None identified in the inspected code.
Non-blocking
Not verified
I read the prepared description, commits, README, diff, and targeted ranges of
MathGamma.cpp,MathExact.cpp,CMakeLists.txt,GuestLgammaFinite.cpp,GuestLgammaLarge.cpp, andGuestLgammaPoles.cpp, plus the three changed debt notes in the diff. I did not read all added lines in the large fixture files, the full changedCMakeLists.txt, or all changed files' full text.files.jsonwas not available through the reader. No build, test, merge-preview, or console run was performed by me. Test and comparison results in the description remain contributor reported.To get this to a good state
Nothing is required. Optional: continue to state that console behavior, exhaustive inputs, and enabled-exception behavior in the finite paths remain unverified.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-26T12:45:23Z.
Review: COMMENTED
Actionable comments posted: 3
6775d6fa-87d3-43c6-a255-819acea296b4Reviewing files that changed from the base of the PR and between
37749b6cd5and8a26b67d16.core/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/src/Math.cppcore/libs/prx/libc/src/MathGamma.cppcore/libs/prx/libc/tests/cmake/guest_lgamma_finite.cmakecore/libs/prx/libc/tests/cmake/guest_lgamma_large.cmakecore/libs/tests/GuestLgammaFinite.cppcore/libs/tests/GuestLgammaLarge.cppcore/libs/tests/GuestLgammaPoles.cppdocs/dev/debt/changes/lgammal-finite-domain.mddocs/dev/debt/changes/lgammal-large-arguments.mddocs/dev/debt/changes/lgammal-pole-flags.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-26T12:59:34Z.
Review: COMMENTED
Reviewed — comments
Changes are required before merge: establish the coefficient provenance requested by the maintainer before merging this implementation.
What I ran
Reviewed head
8a26b67d16747938b3175aaff19f38eea8ee950dand its prepared diff; no build or tests were run. Targeted source reads were made throughrepo_read.py.Results
Findings
Blocking
None verified in the code reviewed.
Non-blocking
Not verified
The full text of
core/libs/prx/libc/src/Math.cpp,core/libs/tests/GuestLgammaFinite.cpp,core/libs/tests/GuestLgammaLarge.cpp, and all three changed debt notes was not read. Their changes were reviewed indiff.patchonly. The remaining coefficient table and test fixture lines were also not exhaustively inspected. No tests were run; reported results in the PR description are author-supplied. No Windows, console, or enabled-exception behavior was verified.To get this to a good state
Nothing is required. Optional: add the permitted source and required license notice, or provide a genuine coefficient generator.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T11:10:49Z.
Review: COMMENTED
Built the submitted
Math.cppandMathGamma.cppon Linux with the target's rounding-math option and contraction disabled. The exact fixtures passed 2,292 finite, precision and rounding cases, 360 measured large-argument cases, and 240 pole cases plus non-pole controls.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.