about summary refs log tree commit diff
path: root/math
diff options
context:
space:
mode:
authorWilco Dijkstra <wdijkstr@arm.com>2018-08-10 17:31:30 +0100
committerWilco Dijkstra <wdijkstr@arm.com>2018-08-10 17:34:39 +0100
commitea5c662c623125ad39fc43d5b9224150256407a9 (patch)
treed4adba7c05e215900b95d9278ace33cd7554272c /math
parent43cfdf8f4811c63bca8a2185d82a6d92977a125b (diff)
downloadglibc-ea5c662c623125ad39fc43d5b9224150256407a9.tar.gz
glibc-ea5c662c623125ad39fc43d5b9224150256407a9.tar.xz
glibc-ea5c662c623125ad39fc43d5b9224150256407a9.zip
Improve performance of sincosf
This patch is a complete rewrite of sincosf.  The new version is
significantly faster, as well as simple and accurate.
The worst-case ULP is 0.5607, maximum relative error is 0.5303 * 2^-23 over
all 4 billion inputs.  In non-nearest rounding modes the error is 1ULP.

The algorithm uses 3 main cases: small inputs which don't need argument
reduction, small inputs which need a simple range reduction and large inputs
requiring complex range reduction.  The code uses approximate integer
comparisons to quickly decide between these cases.

The small range reducer uses a single reduction step to handle values up to
120.0.  It is fastest on targets which support inlined round instructions.

The large range reducer uses integer arithmetic for simplicity.  It does a
32x96 bit multiply to compute a 64-bit modulo result.  This is more than
accurate enough to handle the worst-case cancellation for values close to
an integer multiple of PI/4.  It could be further optimized, however it is
already much faster than necessary.

sincosf throughput gains on Cortex-A72:
* |x| < 0x1p-12 : 1.6x
* |x| < M_PI_4  : 1.7x
* |x| < 2 * M_PI: 1.5x
* |x| < 120.0   : 1.8x
* |x| < Inf     : 2.3x

	* math/Makefile: Add s_sincosf_data.c.
	* sysdeps/ia64/fpu/s_sincosf_data.c: New file.
	* sysdeps/ieee754/flt-32/s_sincosf.h (abstop12): Add new function.
	(sincosf_poly): Likewise.
	(reduce_small): Likewise.
	(reduce_large): Likewise.
	* sysdeps/ieee754/flt-32/s_sincosf.c (sincosf): Rewrite.
	* sysdeps/ieee754/flt-32/s_sincosf_data.c: New file with sincosf data.
	* sysdeps/m68k/m680x0/fpu/s_sincosf_data.c: New file.
	* sysdeps/x86_64/fpu/s_sincosf_data.c: New file.
Diffstat (limited to 'math')
-rw-r--r--math/Makefile2
1 files changed, 1 insertions, 1 deletions
diff --git a/math/Makefile b/math/Makefile
index d78f40f741..5210430e81 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -131,7 +131,7 @@ type-double-routines := branred doasin dosincos mpa mpatan2	\
 # float support
 type-float-suffix := f
 type-float-routines := k_rem_pio2f math_errf e_exp2f_data e_logf_data	\
-		       e_log2f_data e_powf_log2_data
+		       e_log2f_data e_powf_log2_data s_sincosf_data
 
 # _Float128 support
 type-float128-suffix := f128