* Faster PPC rounding checks in libm?
@ 2016-03-21 14:31 Paul E. Murphy
2016-03-21 23:02 ` Joseph Myers
0 siblings, 1 reply; 2+ messages in thread
From: Paul E. Murphy @ 2016-03-21 14:31 UTC (permalink / raw)
To: Joseph Myers, libc-alpha; +Cc: munroesj, Tulio Magno Quites Machado Filho
I'm looking at trying to recover a bit of performance from the transcendental
functions within libm. The mffs/mtfs instructions used to check the rounding
mode create a substantial bottleneck (see PowerISA 2.07B 4.6.10). From what
I can tell, most of these functions just need to ensure they are computed in
round to nearest.
One thought is to compute known values to infer whether the core is already
in round to even. Though, it has the drawback of always raising the inexact
exception. So, such a check is not an acceptable replacement for all uses.
How objectionable is it to add a rounding check which is allowed to raise
inexact for math functions which the inexact behavior is unspecified?
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Faster PPC rounding checks in libm?
2016-03-21 14:31 Faster PPC rounding checks in libm? Paul E. Murphy
@ 2016-03-21 23:02 ` Joseph Myers
0 siblings, 0 replies; 2+ messages in thread
From: Joseph Myers @ 2016-03-21 23:02 UTC (permalink / raw)
To: Paul E. Murphy; +Cc: libc-alpha, munroesj, Tulio Magno Quites Machado Filho
On Mon, 21 Mar 2016, Paul E. Murphy wrote:
> I'm looking at trying to recover a bit of performance from the transcendental
> functions within libm. The mffs/mtfs instructions used to check the rounding
> mode create a substantial bottleneck (see PowerISA 2.07B 4.6.10). From what
> I can tell, most of these functions just need to ensure they are computed in
> round to nearest.
>
> One thought is to compute known values to infer whether the core is already
> in round to even. Though, it has the drawback of always raising the inexact
> exception. So, such a check is not an acceptable replacement for all uses.
>
> How objectionable is it to add a rounding check which is allowed to raise
> inexact for math functions which the inexact behavior is unspecified?
Well, none of the transcendental functions have specified results for
"inexact" for non-NaN arguments. So provided the rounding mode is set
only after NaN arguments have been dealt with, checking that way seems
reasonable in those functions. Of course it's *not* valid to define the
public fesetround function that way. And you need to make clear, in the
comments on the generic definitions of the relevant (new) macros in
sysdeps/generic/math_private.h, that it's possible the macro may raise
spurious "inexact".
In fact the bulk of the existing cases setting FE_TONEAREST are in
transcendental functions (whether they do it only after NaN arguments are
handled, I haven't checked). (Exceptions for dbl-64 are in sqrt and fma,
calling libc_feholdexcept_setround and caring about exact exceptions, and
for both of those the generic implementation isn't used for Power anyway.)
This gives rise to a question of whether to add new macros / functions for
the spurious-inexact-OK cases or to adjust the semantics of the existing
interfaces and add new ones for the cases that can't have spurious
inexact; adding new macros for spurious-inexact-OK is at least safer.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-03-21 23:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-21 14:31 Faster PPC rounding checks in libm? Paul E. Murphy
2016-03-21 23:02 ` Joseph Myers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).