No CPU does IEEE binary128 in hardware; the compiler emits soft-float
calls either way, so what f128 needed was a binary128 type and a few
functions, not libquadmath. It now uses
- long double where that already is binary128 (aarch64, riscv64 and
s390x Linux), with the long double libm functions;
- otherwise __float128 (x86_64, ppc64le) with glibc's roundf128,
sqrtf128, powf128 and strfromf128 in place of roundq, sqrtq, powq and
quadmath_snprintf.
Neither needs GCC's libquadmath, so f128 now builds under clang too.
arm64 macOS has neither type and stops with a clear message.
glibc's *f128 functions and libquadmath share their implementation:
on 613 benchmark runs (classic, and --symbolic for LP-*), every res.dot
has the same labels as before. make test and the USE_CXX=1 Grover
matrix pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012q87VyzNBV8gtH2ntMeKoM
Stacked on #47. f128 no longer needs GCC's libquadmath, so it builds under clang and on ARM Linux.
Why this is possible
No CPU does IEEE binary128 arithmetic in hardware, x86 included. Every
__float128add or multiply is already a software routine that the compiler emits. What f128 needed was a binary128 type plus four functions (round,sqrt,pow, print), not libquadmath.What changes
leaf_primitive_double.hpicks the type the toolchain has:long double(already binary128 there)roundl,sqrtl,powl,%Lg__float128roundf128,sqrtf128,powf128,strfromf128-lquadmath.CLIBS_GMPfrom build: portability fixes for newer GCC, clang and macOS #47 is gone, because no build links libquadmath any more.Checked on x86_64 (GCC 13)
*f128functions and libquadmath share their implementation. Over 613 benchmark runs (all ofbenchmarks/no-measure, plus--symbolicforLP-*, capped at 20 s each), everyres.dothas exactly the same labels as the libquadmath build.ldd MEDUSA_buddy_doubles_f128no longer lists it.make testpasses, and so doesmake test-grover-f128 USE_CXX=1(glibc's_Float128declarations under C++).*f128functions only for compilers it trusts with_Float128, which excludes clang. libm and libc export them regardless, so the header declares them itself when glibc doesn't (!__HAVE_FLOAT128).CI note: this PR targets #47's branch, so
tests.yml(which runs on PRs intomainordevel) doesn't run on it. Retarget it todevelonce #47 merges.macOS
arm64 macOS has no binary128 type at all. Getting f128 there needs a software implementation, which I'm exploring separately with Berkeley SoftFloat. That work will be Mac-only.
🤖 Generated with Claude Code
https://claude.ai/code/session_012q87VyzNBV8gtH2ntMeKoM