Age | Commit message (Collapse) | Author |
|
Scripted copyright year updates based on git committer date.
|
|
These were technically undefined behaviour - they have been rewritten
without the shift so that their type is unsigned int by default.
|
|
In most cases, we mask lanes which should not trigger exceptions with
a neutral value, then let the existing special-case handler fix them
up later. For exp and exp2 we replace the more complex special-case
handler with a simple scalar fallback. All new behaviour is tested in
runulp.sh, with a new option to pass -f to the run line. We also
extend the fenv testing to Neon log and logf, which already triggered
exceptions correctly. New behaviour is mostly hidden behind a new
config setting, WANT_SIMD_EXCEPT.
|
|
fv and dv are only declared under __aarch64__ - for other targets the
new -c option should be disabled.
|
|
argf and argd have been designed such that non-special input is
tested, optionally followed by a vector with one special lane. To be
able to test that vector functions have correct behaviour w.r.t. fenv
exceptions, we need to be able to choose a different value for the
last lane, as using 1 leads to false negatives when testing a function
for which 1 is a special value. We add an option, -c, for the user to
provide a different control value.
|
|
All ulp_funcs entries use the same level of macro expansion. Also add
some missing routines in mathlib.h and remove funcs which we do not
supply from ulp_funcs.
|
|
Provide dummy example to test benchmarks without having to provide an
actual implementation.
|
|
This patch provides features for assessing accuracy of SVE routines.
It also provides dummy entries and wrappers to test ulp assessment
without having to provide an actual implementation.
|
|
- pl/ is built from top-level Makefile by adding pl to SUBS
- PLSUBS lists all pl/ subdirectories that can be built,
it only contains math for now. Please modify this list in
the top-level config.mk.
- pl libraries and infrastructure is built in build/pl/
- As a result math/ and pl/math generate separate test and bench
binaries.
- Use infrastructure provided in math/test to test and profile
pl/math routines. The build system ensures the appropriate
header files are first copied to build/pl/include/test to define
wrappers and entries in ulp and mathbench.
- Copyied scalar erff from math/ to pl/math/ to show build
system is functional.
- pl mathlib libraries are built separately to the main/portable
mathlib libraries and installed alongside.
|
|
Document contributor requirements.
|
|
The outgoing license was MIT only. The new dual license allows
using the code under Apache-2.0 WITH LLVM-exception license too.
|
|
gcc-12 -frounding-math started using runtime rounding mode for
converting double constants to float, so abstop12(pio4) is no longer
a compile time constant (this is required by iso c). Use float pio4f
instead to make the generated code the same as before and avoid
regressions on gcc-12.
|
|
Scripted copyright year updates based on git committer date.
|
|
The code relied on the final x + c*x to be done via an fma, otherwise
the intermediate c*x could underflow for tiny (almost subnormal) x.
Use explicit fmaf like elsewhere (this code is not expected to be
fast when fma is not inlined, but at least it should be correct).
|
|
erf has larger than 1 ULP errors in directed rounding modes,
increase the error threshold to 1.4 ULP in the test script.
|
|
Only tested in round-to-nearest mode. The expected worst case error
is 1.01 ULP near x=1.25. Benchmarked over random x in [-6,6] and
can increase performance by > 2x (> 3.5x for throughput) on big ooo
cores compared to the implementation in glibc 2.28.
Includes data for erfc too, but this patch only adds erf.
|
|
This was incorrect in the previous commit.
|
|
In round-to-nearest mode the maximum error is 1.09 ULP.
Compared to glibc-2.28 erff: throughput is about 2.2x better,
latency is about 1.5x better on some AArch64 cores (on random
input in [-4,4]).
There are further optimization and quality improvement opportunities.
|
|
Improve comments in math_config.h.
Set WANT_ERRNO to 0 by default.
|
|
Some functions were not tested with the statistical ulp error check
tool, this commit adds tests for the current math symbols.
|
|
This implementation is a wrapper around the scalar pow with appropriate
call abi. As such it is not expected to be faster than scalar calls,
the new double prec vector pow symbols are provided for completeness.
|
|
clang does not support c99 fenv_access and may move fp operations out
of conditional blocks causing unconditional fenv side-effects. Here
if (cond)
ix = f (x * 0x1p52);
was transformed to
ix_ = f (x * 0x1p52);
ix = cond ? ix_ : ix;
where x can be a huge negative value so the mul overflows. The added
barrier should prevent such transformation by significantly increasing
the cost of doing the mul unconditionally.
Found by enh from google on android arm and aarch64 targets.
Fixes github issue #16.
|
|
Reorganise the makefiles so subprojects can be more separately used and
maintained. Still kept the single toplevel Makefile and config.mk.
Subproject Dir.mk is expected to provide all-X, check-X, clean-X and
install-X targets where X is the subproject name and it may use generic
make variables set in config.mk, like CFLAGS_ALL and CC, or subproject
specific variables like X-cflags.
|
|
When defined as 0 the vector math code is not built and not tested.
|
|
The math_errhandling checks are incorrect in general: it is defined
by the libc math.h which is not appropriate for optimized-routines
provided functions that we are testing.
However even if we want to test a libc implementation, ISO C allows
the setting of errno even if !(math_errhandling&MATH_ERRNO), so
relax the checks.
|
|
Vector functions are only used on aarch64, so only define them there.
math/test/mathbench.c:95:1: warning: '__v_dummyf' defined but not used [-Wunused-function]
|
|
gcc-9 started warning if alias symbols have different attributes:
math/expf.c: At top level:
math/expf.c:89:21: warning: '__expf_finite' specifies less restrictive attributes than its target 'expf': 'leaf', 'nothrow', 'pure' [-Wmissing-attributes]
so copy the attributes when creating the aliases.
|
|
Compilers (incorrectly) warn about unused volatile variables:
math/math_config.h: In function 'force_eval_float':
math/math_config.h:188:18: warning: unused variable 'y' [-Wunused-variable]
silence them.
|
|
Compiler checks and realated macros need to be done earlier so they are
usable for the static inline functions.
|
|
Same design as in expf. Worst-case error of __v_exp2f and __v_exp2f_1u
is 1.96 and 0.88 ulp respectively.
It is not clear if round/convert instructions are better or +- Shift.
For expf the latter, for exp2f the former seems more consistently
faster, but both options are kept in the code for now.
|
|
Use heredoc instead of pipe when iterating over test cases to avoid
creating a subshell that would break the PASS/FAIL accounting.
|
|
This is a simple fix to the v_powf code, but in general the vector
code may not work on arbitrary targets even when compiled with
scalar types (s_powf.c), so in the long term may be all s_* should
be disabled for non-aarch64 targets (requires test system and header
changes too).
|
|
Worst-case error is 1.67 ulp, the polynomial was generated by sollya.
Uses a 128 entry (2KB) lookup table. Special cases fall back to scalar
log call.
|
|
Worst-case error is 3.5 ulp, the polynomial was generated by sollya.
For large (>2^23) and special inputs the code falls back to scalar
sin and cos.
|
|
Essentially the scalar powf algorithm is used for each element in the
vector just inlined for better scheduling and simpler special case
handling. The log polynomial is smaller as less accuracy is enough.
Worst-case error is 2.6 ulp.
|
|
The polynomials were produced by searching the coefficient space using
heuristics and ideas from https://arxiv.org/abs/1508.03211
The worst-case error is 1.886 ulp, large inputs (> 2^20) and other
special cases use scalar sinf and cosf.
|
|
The polynomial was produced by searching the coefficient space using
heuristics and ideas from https://arxiv.org/abs/1508.03211
The worst-case error is 3.34 ulp, subnormal range inputs and other
special cases use scalar logf.
|
|
Vector math routines are added to the same libmathlib library as scalar
ones. The difficulty is that they are not always available, the external
abi depends on the compiler version used for the build. Currently only
aarch64 AdvSIMD is supported, there are 4 new sets of symbols:
__s_foo is a scalar function with identical result to the vector one,
__v_foo is a vector function using the base PCS,
__vn_foo uses the vector PCS and
_ZGV*_foo is the vector ABI symbol alias of vn_foo
for a scalar math function foo.
The test and benchmark code got extended to handle vector functions.
Vector functions aim for < 5 ulp worst case error, only support nearest
rounding mode and don't support floating-point exceptions. Vector
functions may call scalar functions to handle special cases, but for a
single value they should return the same result independently of values
in other vector lanes or the position of the value in the vector.
The __v_expf and __v_expf_1u polynomials were produced by searching the
coefficient space with some heuristics and ideas from
https://arxiv.org/abs/1508.03211
Their worst case error is 1.95 and 0.866 ulp respectively.
The exp polynomial was produced by sollya, it uses a 128 element (1KB)
lookup table and has 2.38 ulp worst case error.
|
|
Not all symbols referenced by mathbench may be available in libc so
link to libmathlib too to resolve the missing symbols.
|
|
Fix it to be python3 compatible and plot the exact and approximated
values too.
|
|
The ulp tool compares output of a math function to a larger precision
implementation of the same function.
But when the input argument is converted to a larger precision number
the signaling nan property is lost, so ensure that the conversion
happens inside the critical region where fenv exceptions are checked
and then the conversion itself will raise the invalid exception, which
is the correct behaviour in most cases.
The volatile barrier is not perfect and the snan behaviour is not
always signaling, but this should give more reliable results in most
cases than before.
|
|
fenv support is not reliable in clang so provide a mechanism to
disable fenv status checks and only check the result values.
|
|
Users may want different CFLAGS for math and string subprojects, expose
a mechanism for this in config.mk.
|
|
Make ulp and runulp.sh fail on error.
|
|
Only increment once per fgets.
|
|
Make mathtest fail on error so make check fails too.
|
|
To allow libmathlib.a to be a drop-in replacement for libc functions
on 32bit arm, we should provide long double symbols otherwise the
libc long double implementation may pull in double symbols that can
conflict with libmathlib.a in case of static linking.
Using wrappers instead of alias to avoid type declaration conflicts.
|
|
Removed tanf declaration since the implementation got removed too.
|
|
It avoids the 'make check' to abort when building on architectures
that has LDBL_MANT_DIG == DBL_MANT_DIG without the mpfr installed
(arm cross-compiling for instance).
|
|
Simple script to visualize the output of the ulp test tool, e.g.
$ build/bin/ulp -e .0001 log 0.5 2.0 2345678 | math/tools/plot.py
|