std.math performance (SSE vs. real)

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 30 15:18:43 PDT 2014


On 6/30/14, 2:20 AM, Don wrote:
> For me, a stronger argument is that you can get *higher* precision using
> doubles, in many cases. The reason is that FMA gives you an intermediate
> value with 128 bits of precision; it's available in SIMD but not on x87.
>
> So, if we want to use the highest precision supported by the hardware,
> that does *not* mean we should always use 80 bits.
>
> I've experienced this in CTFE, where the calculations are currently done
> in 80 bits, I've seen cases where the 64-bit runtime results were more
> accurate, because of those 128 bit FMA temporaries. 80 bits are not
> enough!!

Interesting. Maybe we should follow a simple principle - define 
overloads and intrinsic operations such that real is only used if (a) 
requested explicitly (b) it brings about an actual advantage.

I.e. most of the time not using real in user code means it's never real 
throughout.


Andrei




More information about the Digitalmars-d mailing list