[PATCH 1/4 v2] Optimized generic expf and exp2f with wrappers

Szabolcs Nagy szabolcs.nagy@arm.com
Wed Sep 13 10:45:00 GMT 2017


Based on new expf and exp2f code from
https://github.com/ARM-software/optimized-routines/

with the new expf benchmark
https://sourceware.org/ml/libc-alpha/2017-08/msg01126.html
aarch64 expf reciprocal-throughput: 3.3x faster
aarch64 expf latency: 1.7x faster
aarch64 libm.so size: -8byte data, -2140byte text
expf/exp2f worst case nearest rounding ulp error: 0.502

Error checks are inline and errno setting is in separate
tail called functions, but the wrappers are kept in this
patch to handle the _LIB_VERSION==_SVID_ case.  (So e.g.
errno is set twice for expf calls and once __expf_finite
calls now on targets where the new code is used.)

Double precision arithmetics is used which is expected
to be faster on most targets (including soft-float) than
using single precision and it is easier to get good
precision result with it.

Const data is kept in a separate translation unit which
complicates maintenance a bit, but is expected to give
good code for literal loads on most targets and allows
sharing data across expf, exp2f and powf. (This data is
disabled on i386 and ia64 which have their own expf, exp2f
and powf code.)

Some configuration is in a new math_config.h the settings
may need further discussion.

Some details may need target specific tweaks:
- best convert and round to int operation in the arg
reduction may be different across targets.
- code was optimized on fma target, optimal polynomial
eval may be different without fma.
- gcc does not always generate good code for fp bit
representation access via unions or it may be inherently
slow on some target.

The libm-test-ulps will need adjustment because..
- The argument reduction ideally uses nearest rounded rint,
but that is not efficient on most targets, so the polynomial
can get evaluated on a wider interval in non-nearest
rounding mode making 1 ulp errors common in that case.
- The polynomial is evaluated such that it has 1 ulp error
on negative tiny inputs with upward rounding, but in
exchange the evaluation is better pipelined.


v2:
- keep the compat wrappers for now.
- cosmetic changes to math_config.h.
- disable math_errf.c and e_exp2f_data.c on i386 and ia64.
- remove unused t_exp2f.h

2017-09-13  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* math/Makefile (type-float-routines): Add math_errf and e_exp2f_data.
	* sysdeps/aarch64/fpu/math_private.h (TOINT_INTRINSICS): Define.
	(roundtoint, converttoint): Likewise.
	* sysdeps/i386/fpu/e_exp2f_data.c: New file.
	* sysdeps/i386/fpu/math_errf.c: New file.
	* sysdeps/ia64/fpu/e_exp2f_data.c: New file.
	* sysdeps/ia64/fpu/math_errf.c: New file.
	* sysdeps/ieee754/flt-32/e_expf.c: New implementation.
	* sysdeps/ieee754/flt-32/e_exp2f.c: New implementation.
	* sysdeps/ieee754/flt-32/e_exp2f_data.c: New file.
	* sysdeps/ieee754/flt-32/math_config.h: New file.
	* sysdeps/ieee754/flt-32/math_errf.c: New file.
	* sysdeps/ieee754/flt-32/t_exp2f.h: Remove.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-expf.patch
Type: text/x-patch
Size: 37688 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20170913/a621aad2/attachment.bin>


More information about the Libc-alpha mailing list