This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] New numbers in the benchtests.

Here is a possible cause for the failures, not verified as such:

The exp implementation was using get_rounding_mode.  But tgamma uses 
SET_RESTORE_ROUND and calls exp within the scope of SET_RESTORE_ROUND.  
SET_RESTORE_ROUND, for x86_64, only sets the SSE rounding mode, but 
get_rounding_mode gets the x87 rounding mode.  The effect would have been 
that the code in exp found that the x87 rounding mode was not to-nearest, 
then redundantly set the SSE rounding mode to to-nearest, then ended up 
trying to restore the rounding mode and actually setting the SSE rounding 
mode to the not-to-nearest value of the x87 rounding modes.

If this hypothesis is correct, I advise resubmitting the patch in a form 
that just uses SET_RESTORE_ROUND (FE_TONEAREST) like other libm functions 
- the performance improvement was sufficient that presumably even this 
form would still perform better than the existing code.  Then, once that 
is properly validated and checked in, it would be possible to restore the 
optimization that the use of get_rounding_mode and separate code paths 
were intended to achieve.  To do that, you'd need libc_fegetround{,f,l} 
which by default just use get_rounding_mode, but on x86 __SSE2_MATH__ do 
something different for the float and double versions to get the SSE 
rounding mode instead; exp would use libc_fegetround instead of using 
get_rounding_mode directly.

Joseph S. Myers

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]