Re: clang is almost useless for complex arithmetic

2015-01-30 Thread Peter Jeremy
To resurrect an old thread...

On 2014-Mar-25 17:22:05 -0700, Steve Kargl  
wrote:
>It appears that clang developers have chosen the naive
>complex division algorithm, and it does not matter whether
>one turns CX_LIMITED_RANGE on or off.  This means that 
>if one uses clang with complex types, one must be careful
>with the range of values allowed in complex division.  In
>other words, implementation of complex libm routines cannot
>use complex data types and must fallback to a decomposition
>into real and imaginary components. 

Whilst the fixes don't seem to have made it into FreeBSD yet, it seems
that this has been improved in recent Clang/LLVM - see
http://reviews.llvm.org/D5698, committed as rL219557.

I re-implemented their division algorithm in C and checked it against
the algorithms listed in http://arxiv.org/pdf/1210.4539v2.pdf.  Whilst
it fails on same of the difficult values listed in that paper, when
faced with a range of random arguments, it seems to perform better[*]
than the "robust" algorithm.

I didn't look closely at the multiplication algorithm but, based on a
quick look, it seems that it's still susceptable to spurious overflows.

[*] or at least closer to the result given by the naive algorithm using
x87 long doubles.

-- 
Peter Jeremy


pgpvKBy2_8dn6.pgp
Description: PGP signature


Re: Optimization bug with floating-point?

2019-03-14 Thread Peter Jeremy
On 2019-Mar-13 23:30:07 -0700, Steve Kargl  
wrote:
>AFAICT, all libm float routines need to be modified to conditional
>include ieeefp.h and call fpsetprec(FP_PD).  This will work around
>issues is FP and libm.  FreeBSD needs to issue an erratum about 
>the numerical issues with clang.

I vaguely recall looking into the x87 initialisation a long time ago
and STR that the startup code (either crtX or in the kernel) does
a fninit() to set the precision.  I don't recall exactly where.

IMO, calling fpsetprec() in every libm float function is overkill. It
should be enough to fpsetprec() before main() and add a note in the
man pages that libm is built to use the default FPU configuration and
changing the configuration (precision or rounding) may result in larger
errors.

-- 
Peter Jeremy


signature.asc
Description: PGP signature