This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] improves exp() and expf() performance on Sparc.
On Wed, 6 Sep 2017, Patrick McGehearty wrote:
> The sysdeps/ieee754/dbl-64/w_exp_compat.c
> declares __exp (double x)
> and then adds:
> hidden_def (__exp)
> weak_alias (__exp, exp)
>
> I believe the weak_alias in w_exp_compat.c is overriden by the
> sparc_libm_ifunc in e_exp-generic.c. At least, I am not seeing any
> link time errors about double exp declarations and I am seeing the new
> code being executed (as proved by the speed and accuracy changes).
Then you should avoid any object code from w_exp_compat.c being linked
into libm.so at all, by overriding it with a dummy file, rather than just
letting certain symbols be overridden at link time.
> As for error handling, I believe the extra level of indirection on
> return from exp provided by the sysdeps/ieee754/dbl-64/w_exp_compat.c
> routine is an anti-performance design. Every normal return from e_exp
It's fairly clearly a design optimized for consistency of error handling
in the presence of several architecture-specific implementations of the
main function, without needing to e.g. deal with TLS in assembly code for
accessing errno or make multiple implementations handle matherr the same
way. When you avoid architecture-specific implementations (especially .S
ones) as far as possible, integrated error handling is more practical,
especially if you also use new symbol versions to avoid needing to deal
with matherr.
For expf performance obviously needs to be compared with Szabolcs's
implementation (compiled with whatever options and configured
appropriately regarding conversions to integer etc. to be optimal for
SPARC). For exp, I'm inclined to say performance should be compared with
the existing exp *with the slow paths calling __slowexp removed along with
the associated checks for whether to use those slow paths* since those
slow paths are completely unnecessary.
--
Joseph S. Myers
joseph@codesourcery.com