[PATCH] Add generic HAVE_RM_CTX implementation
Wilco
wdijkstr@arm.com
Wed Apr 30 13:39:00 GMT 2014
> From: Siddhesh Poyarekar [mailto:siddhesh@redhat.com]
> On Tue, Apr 15, 2014 at 02:35:06PM +0100, Wilco wrote:
> > Hi,
> >
> > This patch adds a generic implementation of HAVE_RM_CTX using standard fenv calls. As a
> result math
> > functions using SET_RESTORE_ROUND* macros do not suffer from a large slowdown on targets
> which do
> > not implement optimized libc_fe*_ctx inline functions. Most of the libc_fe* inline functions
> are now
> > unused and could be removed in the future (there are a few math functions left which use a
> mixture
> > of standard fenv calls and libc_fe* inline functions - they could be updated to use
> > SET_RESTORE_ROUND or improved to avoid expensive fenv manipulations across just a few FP
> > instructions).
> >
> > libc_feholdsetround*_noex_ctx is added to enable better optimization of
> SET_RESTORE_ROUND_NOEX*
> > implementations.
> >
> > Performance measurements on ARM and x86 of sin() show significant gains over the current
> default,
> > fairly close to a highly optimized fenv_private:
> >
> > ARM x86
> > no fenv_private : 100% 100%
> > generic HAVE_RM_CTX : 250% 350%
> > fenv_private (CTX) : 250% 450%
>
> Nice. This looks useful, but I don't know if you should wait for
> feedback from arch maintainers that would actually be affected by this
> change.
Would anyone mind a huge speedup? Basically I see this as a first step towards cleaning
up math_private.h and the way math functions use fenv. Ideally the default implementation
should be efficient across all targets, and it looks like this is easy to achieve.
If the rounding mode changes had been done like this when originally added, targets wouldn't
have experienced major slowdowns of common math functions.
Wilco
More information about the Libc-alpha
mailing list