Age | Commit message (Collapse) | Author | Files | Lines |
|
There are spelling mistakes in assert messages. Fix them.
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
C23 adds various <math.h> function families originally defined in TS
18661-4. Add the pown functions, which are like pow but with an
integer exponent. That exponent has type long long int in C23; it was
intmax_t in TS 18661-4, and as with other interfaces changed after
their initial appearance in the TS, I don't think we need to support
the original version of the interface. The test inputs are based on
the subset of test inputs for pow that use integer exponents that fit
in long long.
As the first such template implementation that saves and restores the
rounding mode internally (to avoid possible issues with directed
rounding and intermediate overflows or underflows in the wrong
rounding mode), support also needed to be added for using
SET_RESTORE_ROUND* in such template function implementations. This
required math-type-macros-float128.h to include <fenv_private.h>, so
it can tell whether SET_RESTORE_ROUNDF128 is defined. In turn, the
include order with <fenv_private.h> included before <math_private.h>
broke loongarch builds, showing up that
sysdeps/loongarch/math_private.h is really a fenv_private.h file
(maybe implemented internally before the consistent split of those
headers in 2018?) and needed to be renamed to fenv_private.h to avoid
errors with duplicate macro definitions if <math_private.h> is
included after <fenv_private.h>.
The underlying implementation uses __ieee754_pow functions (called
more than once in some cases, where the exponent does not fit in the
floating type). I expect a custom implementation for a given format,
that only handles integer exponents but handles larger exponents
directly, could be faster and more accurate in some cases.
I encourage searching for worst cases for ulps error for these
implementations (necessarily non-exhaustively, given the size of the
input space).
Tested for x86_64 and x86, and with build-many-glibcs.py.
|
|
|
|
C23 adds various <math.h> function families originally defined in TS
18661-4. Add the powr functions, which are like pow, but with simpler
handling of special cases (based on exp(y*log(x)), so negative x and
0^0 are domain errors, powers of -0 are always +0 or +Inf never -0 or
-Inf, and 1^+-Inf and Inf^0 are also domain errors, while NaN^0 and
1^NaN are NaN). The test inputs are taken from those for pow, with
appropriate adjustments (including removing all tests that would be
domain errors from those in auto-libm-test-in and adding some more
such tests in libm-test-powr.inc).
The underlying implementation uses __ieee754_pow functions after
dealing with all special cases that need to be handled differently.
It might be a little faster (avoiding a wrapper and redundant checks
for special cases) to have an underlying implementation built
separately for both pow and powr with compile-time conditionals for
special-case handling, but I expect the benefit of that would be
limited given that both functions will end up needing to use the same
logic for computing pow outside of special cases.
My understanding is that powr(negative, qNaN) should raise "invalid":
that the rule on "invalid" for an argument outside the domain of the
function takes precedence over a quiet NaN argument producing a quiet
NaN result with no exceptions raised (for rootn it's explicit that the
0th root of qNaN raises "invalid"). I've raised this on the WG14
reflector to confirm the intent.
Tested for x86_64 and x86, and with build-many-glibcs.py.
|
|
The current approach tracks math maximum supported errors by explicitly
setting them per function and architecture. On newer implementations or
new compiler versions, the file is updated with newer values if it
shows higher results. The idea is to track the maximum known error, to
update the manual with the obtained values.
The constant libm-test-ulps shows little value, where it is usually a
mechanical change done by the maintainer, for past releases it is
usually ignored whether the ulp change resulted from a compiler
regression, and the math tests already have a maximum ulp error that
triggers a regression.
It was shown by a recent update after the new acosf [1] implementation
that is correctly rounded, where the libm-test-ulps was indeed from a
compiler issue.
This patch removes all arch-specific libm-test-ulps, adds system generic
libm-test-ulps where applicable, and changes its semantics. The generic
files now track specific implementation constraints, like if it is
expected to be correctly rounded, or if the system-specific has
different error expectations.
Now multiple libm-test-ulps can be defined, and system-specific
overrides generic implementation. This is for the case where
arch-specific implementation might show worse precision than generic
implementation, for instance, the cbrtf on i686.
Regressions are only reported if the implementation shows larger errors
than 9 ulps (13 for IBM long double) unless it is overridden by
libm-test-ulps and the maximum error is not printed at the end of tests.
The regen-ulps rule is also removed since it does not make sense to
update the libm-test-ulps automatically.
The manual error table is also removed, Paul Zimmermann and others have
been tracking libm precision with a more comprehensive analysis for some
releases; so link to his work instead.
[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=9cc9f8e11e8fb8f54f1e84d9f024917634a78201
|
|
Commit 6bc301672bfbd ("math: Remove __XXX math functions from installed
math.h [BZ #32418]") left an extra semicolon after macro expansion. For
instance the ceil declaration after expansion is:
extern double ceil (double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));;
This chokes very naive parsers like gauche c-wrapper. Fix that by
removing that extra semicolon in the macro.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
C23 adds various <math.h> function families originally defined in TS
18661-4. Add the rsqrt functions (1/sqrt(x)). The test inputs are
taken from those for sqrt.
Tested for x86_64 and x86, and with build-many-glibcs.py.
|
|
Single-precision remainderf() and quad-precision remainderl()
implementation derived from Sun is affected by an issue when the result
is +-0. IEEE754 requires that if remainder(x, y) = 0, its sign shall be
that of x regardless of the rounding direction.
The implementation seems to have assumed that x - x = +0 in all
rounding modes, which is not the case. When rounding direction is
roundTowardNegative the sign of an exact zero sum (or difference) is −0.
Regression tests that triggered this erroneous behavior are added to
math/libm-test-remainder.inc.
Tested for cross riscv64 and powerpc.
Original fix by: Bruce Evans <bde@FreeBSD.org> in FreeBSD's
a2ddfa5ea726c56dbf825763ad371c261b89b7c7.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
The libm size improvement built with gcc-14, "--enable-stack-protector=strong
--enable-bind-now=yes --enable-fortify-source=2":
Before:
582292 844 12 583148 8e5ec aarch64-linux-gnu/math/libm.so
975133 1076 12 976221 ee55d x86_64-linux-gnu/math/libm.so
1203586 5608 368 1209562 1274da powerpc64le-linux-gnu/math/libm.so
After:
581972 844 12 582828 8e4ac aarch64-linux-gnu/math/libm.so
974941 1076 12 976029 ee49d x86_64-linux-gnu/math/libm.so
1203394 5608 368 1209370 12741a powerpc64le-linux-gnu/math/libm.so
Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
|
|
The libm size improvement built with gcc-14, "--enable-stack-protector=strong
--enable-bind-now=yes --enable-fortify-source=2":
Before:
text data bss dec hex filename
583444 844 12 584300 8ea6c aarch64-linux-gnu/math/libm.so
976349 1076 12 977437 eea1d x86_64-linux-gnu/math/libm.so
1204738 5608 368 1210714 12795a powerpc64le-linux-gnu/math/libm.so
After:
582292 844 12 583148 8e5ec aarch64-linux-gnu/math/libm.so
975133 1076 12 976221 ee55d x86_64-linux-gnu/math/libm.so
1203586 5608 368 1209562 1274da powerpc64le-linux-gnu/math/libm.so
Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
|
|
The libm size improvement built with gcc-14, "--enable-stack-protector=strong
--enable-bind-now=yes --enable-fortify-source=2":
Before:
text data bss dec hex filename
584500 844 12 585356 8ee8c aarch64-linux-gnu/math/libm.so
977341 1076 12 978429 eedfd x86_64-linux-gnu/math/libm.so
1205762 5608 368 1211738 127d5a powerpc64le-linux-gnu/math/libm.so
After:
text data bss dec hex filename
583444 844 12 584300 8ea6c aarch64-linux-gnu/math/libm.so
976349 1076 12 977437 eea1d x86_64-linux-gnu/math/libm.so
1204738 5608 368 1210714 12795a powerpc64le-linux-gnu/math/libm.so
Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
|
|
The libm size improvement built with "--enable-stack-protector=strong
--enable-bind-now=yes --enable-fortify-source=2":
Before:
text data bss dec hex filename
585192 860 12 586064 8f150 aarch64-linux-gnu/math/libm.so
960775 1068 12 961855 ead3f x86_64-linux-gnu/math/libm.so
1189174 5544 368 1195086 123c4e powerpc64le-linux-gnu/math/libm.so
After:
text data bss dec hex filename
584952 860 12 585824 8f060 aarch64-linux-gnu/math/libm.so
960615 1068 12 961695 eac9f x86_64-linux-gnu/math/libm.so
1189078 5544 368 1194990 123bee powerpc64le-linux-gnu/math/libm.so
The are small code changes for x86_64 and powerpc64le, which do not
affect performance; but on aarch64 with gcc-14 I see a slight better
code generation due the usage of ldq for floating point constant loading.
Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
|
|
The libm size improvement built with "--enable-stack-protector=strong
--enable-bind-now=yes --enable-fortify-source=2":
Before:
text data bss dec hex filename
587304 860 12 588176 8f990 aarch64-linux-gnu-master/math/libm.so
962855 1068 12 963935 eb55f x86_64-linux-gnu-master/math/libm.so
1191222 5544 368 1197134 12444e powerpc64le-linux-gnu-master/math/libm.so
After:
text data bss dec hex filename
585192 860 12 586064 8f150 aarch64-linux-gnu/math/libm.so
960775 1068 12 961855 ead3f x86_64-linux-gnu/math/libm.so
1189174 5544 368 1195086 123c4e powerpc64le-linux-gnu/math/libm.so
The are small code changes for x86_64 and powerpc64le, which do not
affect performance; but on aarch64 with gcc-14 I see a slight better
code generation due the usage of ldq for floating point constant loading.
Reviewed-by: Andreas K. Huettel <dilfridge@gentoo.org>
|
|
The CORE-MATH implementation is correctly rounded (for any rounding mode)
and shows better performance to the generic atanpif.
The code was adapted to glibc style and to use the definition of
math_config.h (to handle errno, overflow, and underflow).
Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1,
gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1):
latency master patched improvement
x86_64 66.3296 52.7558 20.46%
x86_64v2 66.0429 51.4007 22.17%
x86_64v3 60.6294 48.7876 19.53%
aarch64 (Neoverse) 24.3163 20.9110 14.00%
power8 16.5766 13.3620 19.39%
power10 16.5115 13.4072 18.80%
reciprocal-throughput master patched improvement
x86_64 30.8599 16.0866 47.87%
x86_64v2 29.2286 15.4688 47.08%
x86_64v3 23.0960 12.8510 44.36%
aarch64 (Neoverse) 15.4619 10.6752 30.96%
power8 7.9200 5.2483 33.73%
power10 6.8539 4.6262 32.50%
Reviewed-by: DJ Delorie <dj@redhat.com>
|
|
The logic was copied wrong from CORE-MATH.
|
|
The logic was copied wrong from CORE-MATH.
|
|
It was copied wrong from CORE-MATH.
|
|
Vector variant of the new C23 tanpi. New tests pass on AArch64.
|
|
Vector variant of the new C23 cospi. New tests pass on AArch64.
|
|
Vector variant of the new C23 sinpi. New tests pass on AArch64.
|
|
More routines are to follow, some of which hit many failures in the
current testsuite due to wrong sign of zero (mathvec routines are not
required to get this right). Instead of disabling a large number of
tests, change the failure condition such that, for vector routines,
tests pass as long as computed == expected == 0.0, regardless of sign.
Affected tests (vector tests for expm1, log1p, sin, tan and tanh) all
still pass.
|
|
Clang's <tgmath.h> doesn't support all C23 functions in glibc's <tgmath.h>:
https://github.com/llvm/llvm-project/issues/121536
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
|
|
These inputs were generated with the programs from
https://gitlab.inria.fr/zimmerma/math_accuracy,
with rounding to nearest:
* for univariate binary32 functions by exhaustive search
* for other functions with the "threshold" parameter up to 10^6
|
|
|
|
clang warns that since the global variables are only used to function
calls (without being actually used), they are not needed and will
not be emitted.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
|
|
Clang doesn't support -ffloat-store:
clang: error: optimization flag '-ffloat-store' is not supported [-Werror,-Wignored-optimization-argument]
Define test-config-cflags-float-store for -ffloat-store and use it in
math/Makefile for testing.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
|
|
Since math/math.h isn't a system header, clang issues errors:
In file included from test-flt-eval-method.c:20:
In file included from ../include/math.h:7:
../math/math.h:91:11: error: 'INFINITY' macro redefined [-Werror,-Wmacro-redefined]
91 | # define INFINITY (__builtin_inff ())
| ^
/usr/bin/../lib/clang/19/include/float.h:173:11: note: previous definition is here
173 | # define INFINITY (__builtin_inff())
| ^
In file included from test-flt-eval-method.c:20:
In file included from ../include/math.h:7:
../math/math.h:98:11: error: 'NAN' macro redefined [-Werror,-Wmacro-redefined]
98 | # define NAN (__builtin_nanf (""))
| ^
/usr/bin/../lib/clang/19/include/float.h:174:11: note: previous definition is here
174 | # define NAN (__builtin_nanf(""))
Don't define INFINITY nor NAN if they are defined.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
|
|
Since __builtin_complex was added to Clang 12, support __builtin_complex
for Clang 12.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
|
|
tgmath3-macro-tests won't compile with <float.h> and <tgmath.h> from
Clang due to missing C23 support:
https://github.com/llvm/llvm-project/issues/97335
Disable them for now when Clang is used for testing so that "make check"
can finish.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
Clang has its own <tgmath.h> and doesn't use <tgmath.h> from glibc. Pass
"-I." to compiler only if $($(<F)-no-include-dot) are undefined. Define
it to yes for tgmath tests when testing with Clang.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
|
|
On powerpc math/test-ibm128-tanpi shows multiple failures:
testing long double (without inline functions)
Failure: tanpi_downward (0xfffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_downward (0xfffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_downward (0xfffffffffffffffdp-1)
Result:
is: 4.68843873182857939141363635204365e+28 0x1.2efbb6629d1d59b032520400df8p+95
should be: inf inf
Failure: tanpi_downward (0x3fffffffffffffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_downward (0x3fffffffffffffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_downward (0x3fffffffffffffffffffffffffdp-1)
Result:
is: 1.41444453325831960404472183124793e+16 0x1.9202627cbf98e052d5fdbeee1f8p+53
should be: inf inf
Failure: tanpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): Exception "Invalid operation" set
Failure: tanpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: tanpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): errno set to 33, expected 0 (unchanged)
Failure: Test: tanpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020)
Result:
is: qNaN
should be: -0.00000000000000000000000000000000e+00 -0x0.000000000000000000000000000p+0
Failure: Test: tanpi_downward (0x3.fffffffffffffffcp+108)
Result:
is: 2.91356019227449116879287504834896e-15 0x1.a3e365fee24d4632f95a2235698p-49
should be: 0.00000000000000000000000000000000e+00 0x0.000000000000000000000000000p+0
difference: 2.91356019227449116879287504834896e-15 0x1.a3e365fee24d4632f95a2235698p-49
ulp : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
max.ulp : 8.0000
Failure: Test: tanpi_downward (0x3.ffffffffffffffffffffffffffp+108)
Result:
is: 7.94911926685664643005642781870827e-16 0x1.ca3c4b83eb5688e1474146dc338p-51
should be: 0.00000000000000000000000000000000e+00 0x0.000000000000000000000000000p+0
difference: 7.94911926685664643005642781870827e-16 0x1.ca3c4b83eb5688e1474146dc338p-51
ulp : 160891965142034222272327839154722485473479235229008379884749401713481320342777314570400076204240982703218835644458374555276642
max.ulp : 8.0000
Failure: tanpi_towardzero (0xfffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_towardzero (0xfffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_towardzero (0xfffffffffffffffdp-1)
Result:
is: 2.14718475310122677917055904836884e+28 0x1.1584624c14882fff76592b4ec10p+94
should be: inf inf
Failure: tanpi_towardzero (-0xfffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_towardzero (-0xfffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_towardzero (-0xfffffffffffffffdp-1)
Result:
is: -2.14718475310122677917055904836884e+28 -0x1.1584624c14882fff76592b4ec10p+94
should be: -inf -inf
Failure: tanpi_towardzero (0x3fffffffffffffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_towardzero (0x3fffffffffffffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_towardzero (0x3fffffffffffffffffffffffffdp-1)
Result:
is: 6.60739946234609289593176521179840e+15 0x1.7796511d79d6ce55bc8bf083fe0p+52
should be: inf inf
Failure: tanpi_towardzero (-0x3fffffffffffffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_towardzero (-0x3fffffffffffffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_towardzero (-0x3fffffffffffffffffffffffffdp-1)
Result:
is: -6.60739946234609289593176521179840e+15 -0x1.7796511d79d6ce55bc8bf083fe0p+52
should be: -inf -inf
Failure: Test: tanpi_towardzero (-0x3.fffffffffffffffcp+108)
Result:
is: -1.17953443892757434921819283936141e-14 -0x1.a8f8d97fb893518cbe5688935c0p-47
should be: -0.00000000000000000000000000000000e+00 -0x0.000000000000000000000000000p+0
difference: 1.17953443892757434921819283936141e-14 0x1.a8f8d97fb893518cbe5688935c0p-47
ulp : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
max.ulp : 8.0000
Failure: Test: tanpi_towardzero (-0x3.ffffffffffffffffffffffffffp+108)
Result:
is: -1.85584803206881692897837494734542e-14 -0x1.4e51e25c1f5ab4470a3a0a42c24p-46
should be: -0.00000000000000000000000000000000e+00 -0x0.000000000000000000000000000p+0
difference: 1.85584803206881692897837494734542e-14 0x1.4e51e25c1f5ab4470a3a0a42c24p-46
ulp : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
max.ulp : 8.0000
Failure: Test: tanpi_towardzero (0x3.fffffffffffffffcp+108)
Result:
is: 1.17953443892757434921819283936141e-14 0x1.a8f8d97fb893518cbe5688935c0p-47
should be: 0.00000000000000000000000000000000e+00 0x0.000000000000000000000000000p+0
difference: 1.17953443892757434921819283936141e-14 0x1.a8f8d97fb893518cbe5688935c0p-47
ulp : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
max.ulp : 8.0000
Failure: Test: tanpi_towardzero (0x3.ffffffffffffffffffffffffffp+108)
Result:
is: 1.85584803206881692897837494734542e-14 0x1.4e51e25c1f5ab4470a3a0a42c24p-46
should be: 0.00000000000000000000000000000000e+00 0x0.000000000000000000000000000p+0
difference: 1.85584803206881692897837494734542e-14 0x1.4e51e25c1f5ab4470a3a0a42c24p-46
ulp : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
max.ulp : 8.0000
Failure: tanpi_upward (-0xfffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_upward (-0xfffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_upward (-0xfffffffffffffffdp-1)
Result:
is: -2.14718475310122677917055904836884e+28 -0x1.1584624c14882fff76592b4ec10p+94
should be: -inf -inf
Failure: tanpi_upward (-0x3fffffffffffffffffffffffffdp-1): Exception "Divide by zero" not set
Failure: tanpi_upward (-0x3fffffffffffffffffffffffffdp-1): errno set to 0, expected 34 (ERANGE)
Failure: Test: tanpi_upward (-0x3fffffffffffffffffffffffffdp-1)
Result:
is: -6.60739946234609289593176521179829e+15 -0x1.7796511d79d6ce55bc8bf083fdbp+52
should be: -inf -inf
Failure: Test: tanpi_upward (-0x3.fffffffffffffffcp+108)
Result:
is: -1.17953443892757434921819283936138e-14 -0x1.a8f8d97fb893518cbe5688935b0p-47
should be: -0.00000000000000000000000000000000e+00 -0x0.000000000000000000000000000p+0
difference: 1.17953443892757434921819283936139e-14 0x1.a8f8d97fb893518cbe5688935b0p-47
ulp : inf
max.ulp : 8.0000
Failure: Test: tanpi_upward (-0x3.ffffffffffffffffffffffffffp+108)
Result:
is: -1.85584803206881692897837494734542e-14 -0x1.4e51e25c1f5ab4470a3a0a42c24p-46
should be: -0.00000000000000000000000000000000e+00 -0x0.000000000000000000000000000p+0
difference: 1.85584803206881692897837494734543e-14 0x1.4e51e25c1f5ab4470a3a0a42c24p-46
ulp : inf
max.ulp : 8.0000
Failure: tanpi_upward (0xf.ffffffffffffbffffffffffffcp+1020): Exception "Invalid operation" set
Failure: tanpi_upward (0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: tanpi_upward (0xf.ffffffffffffbffffffffffffcp+1020): errno set to 33, expected 0 (unchanged)
Failure: Test: tanpi_upward (0xf.ffffffffffffbffffffffffffcp+1020)
Result:
is: qNaN
should be: 0.00000000000000000000000000000000e+00 0x0.000000000000000000000000000p+0
|
|
The pi defined constants are not the expected value for carg
on non-default rounding modes (similar to atan). Instead use
autogenerated value.
|
|
The pi defined constants are not the expected value for atan2
on non-default rounding modes. Instead use the autogenerated value.
Reviewed-by: DJ Delorie <dj@redhat.com>
|
|
The M_PI_2 (lit_pi_2_d) constant is not the expected value for atanf
on non-default rounding modes. Instead use the autogenerated value.
|
|
For some correctly rounded inputs where infinity might generate
a number (like atanf), comparing to a pre-defined constant does not
yield the expected result in all rounding modes.
The most straightforward way to handle it would be to get the expected
result from mpfr, where it handles all the rounding modes.
|
|
Reviewed-by: DJ Delorie <dj@redhat.com>
|
|
C23 adds various <math.h> function families originally defined in TS
18661-4. Add the atan2pi functions (atan2(y,x)/pi).
Tested for x86_64 and x86, and with build-many-glibcs.py.
|
|
Since libm doesn't export __XXX math functions, don't declare them in
the installed math.h by adding <bits/mathcalls-macros.h> to declare
__XXX math functions internally for glibc build. This fixes BZ #32418.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Reviewed-by: Sam James <sam@gentoo.org>
|
|
C23 adds various <math.h> function families originally defined in TS
18661-4. Add the atanpi functions (atan(x)/pi).
Tested for x86_64 and x86, and with build-many-glibcs.py.
|
|
C23 adds various <math.h> function families originally defined in TS
18661-4. Add the asinpi functions (asin(x)/pi).
Tested for x86_64 and x86, and with build-many-glibcs.py.
|
|
C23 adds various <math.h> function families originally defined in TS
18661-4. Add the acospi functions (acos(x)/pi).
Tested for x86_64 and x86, and with build-many-glibcs.py.
|
|
C23 adds various <math.h> function families originally defined in TS
18661-4. Add the tanpi functions (tan(pi*x)).
Tested for x86_64 and x86, and with build-many-glibcs.py.
|
|
On powerpc math/test-ibm128-sinpi shows:
testing long double (without inline functions)
Failure: sinpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): Exception "Invalid operation" set
Failure: sinpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: sinpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): errno set to 33, expected 0 (unchanged)
Failure: Test: sinpi_downward (-0xf.ffffffffffffbffffffffffffcp+1020)
Result:
is: qNaN
should be: -0.00000000000000000000000000000000e+00 -0x0.000000000000000000000000000p+0
Failure: Test: sinpi_downward (0x3.fffffffffffffffcp+108)
Result:
is: 2.97479253223185882765417834495004e-15 0x1.acb679186c7b49a36c9ec63e110p-49
should be: 0.00000000000000000000000000000000e+00 0x0.000000000000000000000000000p+0
difference: 2.97479253223185882765417834495004e-15 0x1.acb679186c7b49a36c9ec63e110p-49
ulp : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
max.ulp : 4.0000
Failure: Test: sinpi_downward (0x3.ffffffffffffffffffffffffffp+108)
Result:
is: 2.63250110604328276654475674742669e-15 0x1.7b6225fa8503a5a8c514f5c0208p-49
should be: 0.00000000000000000000000000000000e+00 0x0.000000000000000000000000000p+0
difference: 2.63250110604328276654475674742669e-15 0x1.7b6225fa8503a5a8c514f5c0208p-49
ulp : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
max.ulp : 4.0000
Failure: Test: sinpi_towardzero (-0x3.fffffffffffffffcp+108)
Result:
is: -1.71856472474338625450766636956702e-14 -0x1.3596cf230d8f69346d93d8c3100p-46
should be: -0.00000000000000000000000000000000e+00 -0x0.000000000000000000000000000p+0
difference: 1.71856472474338625450766636956702e-14 0x1.3596cf230d8f69346d93d8c3100p-46
ulp : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
max.ulp : 3.0000
Failure: Test: sinpi_towardzero (-0x3.ffffffffffffffffffffffffffp+108)
Result:
is: -9.73792846364428462525599942305655e-15 -0x1.5ed8897ea140e96a31453d6e580p-47
should be: -0.00000000000000000000000000000000e+00 -0x0.000000000000000000000000000p+0
difference: 9.73792846364428462525599942305655e-15 0x1.5ed8897ea140e96a31453d6e580p-47
ulp : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
max.ulp : 3.0000
Failure: Test: sinpi_towardzero (0x3.fffffffffffffffcp+108)
Result:
is: 1.71856472474338625450766636956702e-14 0x1.3596cf230d8f69346d93d8c3100p-46
should be: 0.00000000000000000000000000000000e+00 0x0.000000000000000000000000000p+0
difference: 1.71856472474338625450766636956702e-14 0x1.3596cf230d8f69346d93d8c3100p-46
ulp : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
max.ulp : 3.0000
Failure: Test: sinpi_towardzero (0x3.ffffffffffffffffffffffffffp+108)
Result:
is: 9.73792846364428462525599942305655e-15 0x1.5ed8897ea140e96a31453d6e580p-47
should be: 0.00000000000000000000000000000000e+00 0x0.000000000000000000000000000p+0
difference: 9.73792846364428462525599942305655e-15 0x1.5ed8897ea140e96a31453d6e580p-47
ulp : 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321
max.ulp : 3.0000
Failure: Test: sinpi_upward (-0x3.fffffffffffffffcp+108)
Result:
is: -1.71856472474338625450766636956709e-14 -0x1.3596cf230d8f69346d93d8c3110p-46
should be: -0.00000000000000000000000000000000e+00 -0x0.000000000000000000000000000p+0
difference: 1.71856472474338625450766636956710e-14 0x1.3596cf230d8f69346d93d8c3110p-46
ulp : inf
max.ulp : 4.0000
Failure: Test: sinpi_upward (-0x3.ffffffffffffffffffffffffffp+108)
Result:
is: -9.73792846364428462525599942305708e-15 -0x1.5ed8897ea140e96a31453d6e598p-47
should be: -0.00000000000000000000000000000000e+00 -0x0.000000000000000000000000000p+0
difference: 9.73792846364428462525599942305709e-15 0x1.5ed8897ea140e96a31453d6e598p-47
ulp : inf
max.ulp : 4.0000
Failure: sinpi_upward (0xf.ffffffffffffbffffffffffffcp+1020): Exception "Invalid operation" set
Failure: sinpi_upward (0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: sinpi_upward (0xf.ffffffffffffbffffffffffffcp+1020): errno set to 33, expected 0 (unchanged)
Failure: Test: sinpi_upward (0xf.ffffffffffffbffffffffffffcp+1020)
Result:
is: qNaN
should be: 0.00000000000000000000000000000000e+00 0x0.000000000000000000000000000p+0
|
|
On powerpc math/test-ibm128-cospi shows:
testing long double (without inline functions)
Failure: cospi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): Exception "Invalid operation" set
Failure: cospi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: cospi_downward (-0xf.ffffffffffffbffffffffffffcp+1020): errno set to 33, expected 0 (unchanged)
Failure: Test: cospi_downward (-0xf.ffffffffffffbffffffffffffcp+1020)
Result:
is: qNaN
should be: 1.00000000000000000000000000000000e+00 0x1.000000000000000000000000000p+0
Failure: Test: cospi_downward (0x3.fffffffffffffffcp+108)
Result:
is: 9.99999999999999999999999999995574e-01 0x1.ffffffffffffffffffffffff4c8p-1
should be: 1.00000000000000000000000000000000e+00 0x1.000000000000000000000000000p+0
difference: 4.42501664022411309598141492088312e-30 0x1.670000000000000000000000000p-98
ulp : 179.5000
max.ulp : 4.0000
Failure: Test: cospi_downward (0x3.ffffffffffffffffffffffffffp+108)
Result:
is: 9.99999999999999999999999999996524e-01 0x1.ffffffffffffffffffffffff730p-1
should be: 1.00000000000000000000000000000000e+00 0x1.000000000000000000000000000p+0
difference: 3.47591836363008326759542899077727e-30 0x1.1a0000000000000000000000000p-98
ulp : 141.0000
max.ulp : 4.0000
Failure: Test: cospi_towardzero (-0x3.fffffffffffffffcp+108)
Result:
is: 9.99999999999999999999999999852310e-01 0x1.ffffffffffffffffffffffe8990p-1
should be: 1.00000000000000000000000000000000e+00 0x1.000000000000000000000000000p+0
difference: 1.47689552599346303944427057331536e-28 0x1.767000000000000000000000000p-93
ulp : 5991.0000
max.ulp : 4.0000
Failure: Test: cospi_towardzero (-0x3.ffffffffffffffffffffffffffp+108)
Result:
is: 9.99999999999999999999999999952569e-01 0x1.fffffffffffffffffffffff87c0p-1
should be: 1.00000000000000000000000000000000e+00 0x1.000000000000000000000000000p+0
difference: 4.74302619264133348003801799876275e-29 0x1.e10000000000000000000000000p-95
ulp : 1924.0000
max.ulp : 4.0000
Failure: Test: cospi_towardzero (0x3.fffffffffffffffcp+108)
Result:
is: 9.99999999999999999999999999852310e-01 0x1.ffffffffffffffffffffffe8990p-1
should be: 1.00000000000000000000000000000000e+00 0x1.000000000000000000000000000p+0
difference: 1.47689552599346303944427057331536e-28 0x1.767000000000000000000000000p-93
ulp : 5991.0000
max.ulp : 4.0000
Failure: Test: cospi_towardzero (0x3.ffffffffffffffffffffffffffp+108)
Result:
is: 9.99999999999999999999999999952569e-01 0x1.fffffffffffffffffffffff87c0p-1
should be: 1.00000000000000000000000000000000e+00 0x1.000000000000000000000000000p+0
difference: 4.74302619264133348003801799876275e-29 0x1.e10000000000000000000000000p-95
ulp : 1924.0000
max.ulp : 4.0000
Failure: Test: cospi_upward (-0x3.fffffffffffffffcp+108)
Result:
is: 9.99999999999999999999999999852323e-01 0x1.ffffffffffffffffffffffe899bp-1
should be: 1.00000000000000000000000000000000e+00 0x1.000000000000000000000000000p+0
difference: 1.47673235656615530277812119019587e-28 0x1.766568e20369c00000000000000p-93
ulp : 5990.3382
max.ulp : 4.0000
Failure: Test: cospi_upward (-0x3.ffffffffffffffffffffffffffp+108)
Result:
is: 9.99999999999999999999999999952583e-01 0x1.fffffffffffffffffffffff87cbp-1
should be: 1.00000000000000000000000000000000e+00 0x1.000000000000000000000000000p+0
difference: 4.74136253815267677203679334037676e-29 0x1.e0d4cf1e9076600000000000000p-95
ulp : 1923.3252
max.ulp : 4.0000
Failure: cospi_upward (0xf.ffffffffffffbffffffffffffcp+1020): Exception "Invalid operation" set
Failure: cospi_upward (0xf.ffffffffffffbffffffffffffcp+1020): Exception "Overflow" set
Failure: cospi_upward (0xf.ffffffffffffbffffffffffffcp+1020): errno set to 33, expected 0 (unchanged)
Failure: Test: cospi_upward (0xf.ffffffffffffbffffffffffffcp+1020)
Result:
is: qNaN
should be: 1.00000000000000000000000000000000e+00 0x1.000000000000000000000000000p+0
|
|
This should fix the reported issue building cospi and sinpi with GCC 6.
Tested for x86_64 (not with GCC 6).
|
|
Fix variables in Makefiles:
1. There is a tab, not a space, between "variable" and =, +=, :=.
2. The last entry doesn't have a trailing \.
and sort them.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
C23 adds various <math.h> function families originally defined in TS
18661-4. Add the sinpi functions (sin(pi*x)).
Tested for x86_64 and x86, and with build-many-glibcs.py.
|
|
C23 adds various <math.h> function families originally defined in TS
18661-4. Add the cospi functions (cos(pi*x)).
Tested for x86_64 and x86, and with build-many-glibcs.py.
|
|
So we can eventually replace each implementation.
Reviewed-by: DJ Delorie <dj@redhat.com>
|
|
The CORE-MATH implementation is correctly rounded (for any rounding mode).
This can be checked by exhaustive tests in a few minutes since there are
less than 2^32 values to check against for example GNU MPFR.
This patch also adds some bench values for tgammaf.
Tested on x86_64 and x86 (cfarm26).
With the initial GNU libc code it gave on an Intel(R) Core(TM) i7-8700:
"tgammaf": {
"": {
"duration": 3.50188e+09,
"iterations": 2e+07,
"max": 602.891,
"min": 65.1415,
"mean": 175.094
}
}
With the new code:
"tgammaf": {
"": {
"duration": 3.30825e+09,
"iterations": 5e+07,
"max": 211.592,
"min": 32.0325,
"mean": 66.1649
}
}
With the initial GNU libc code it gave on cfarm26 (i686):
"tgammaf": {
"": {
"duration": 3.70505e+09,
"iterations": 6e+06,
"max": 2420.23,
"min": 243.154,
"mean": 617.509
}
}
With the new code:
"tgammaf": {
"": {
"duration": 3.24497e+09,
"iterations": 1.8e+07,
"max": 1238.15,
"min": 101.155,
"mean": 180.276
}
}
Signed-off-by: Alexei Sibidanov <sibid@uvic.ca>
Signed-off-by: Paul Zimmermann <Paul.Zimmermann@inria.fr>
Changes in v2:
- include <math.h> (fix the linknamespace failures)
- restored original benchtests/strcoll-inputs/filelist#en_US.UTF-8 file
- restored original wrapper code (math/w_tgammaf_compat.c),
except for the dealing with the sign
- removed the tgammaf/float entries in all libm-test-ulps files
- address other comments from Joseph Myers
(https://sourceware.org/pipermail/libc-alpha/2024-July/158736.html)
Changes in v3:
- pass NULL argument for signgam from w_tgammaf_compat.c
- use of math_narrow_eval
- added more comments
Changes in v4:
- initialize local_signgam to 0 in math/w_tgamma_template.c
- replace sysdeps/ieee754/dbl-64/gamma_productf.c by dummy file
Changes in v5:
- do not mention local_signgam any more in math/w_tgammaf_compat.c
- initialize local_signgam to 1 instead of 0 in w_tgamma_template.c
and added comment
Changes in v6:
- pass NULL as 2nd argument of __ieee754_gammaf_r in
w_tgammaf_compat.c, and check for NULL in e_gammaf_r.c
Changes in v7:
- added Signed-off-by line for Alexei Sibidanov (author of the code)
Changes in v8:
- added Signed-off-by line for Paul Zimmermann (submitted of the patch)
Changes in v9:
- address comments from review by Adhemerval Zanella
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|