Thread overview
Flushing denormals to zero
Feb 17, 2012
bearophile
Feb 17, 2012
Mantis
Feb 17, 2012
Don Clugston
February 17, 2012
After seeing this interesting thread: http://stackoverflow.com/questions/9314534/why-does-changing-0-1f-to-0-slow-down-performance-by-10x

Do you know if there's a simple way to perform _MM_SET_FLUSH_ZERO_MODE in D?

According to Agner that operation is not needed on Sandy Bridge processors, but most CPUs around are not that good: http://www.agner.org/optimize/blog/read.php?i=142

Bye,
bearophile
February 17, 2012
17.02.2012 4:30, bearophile пишет:
> After seeing this interesting thread:
> http://stackoverflow.com/questions/9314534/why-does-changing-0-1f-to-0-slow-down-performance-by-10x
>
> Do you know if there's a simple way to perform _MM_SET_FLUSH_ZERO_MODE in D?
>
> According to Agner that operation is not needed on Sandy Bridge processors, but most CPUs around are not that good:
> http://www.agner.org/optimize/blog/read.php?i=142
>
> Bye,
> bearophile
>
I could expect this to be adjustable in std.math.FloatingPointControl, but it isn't. Anyway, the assembly code to change FPU control word is pretty tiny:
http://software.intel.com/en-us/articles/x87-and-sse-floating-point-assists-in-ia-32-flush-to-zero-ftz-and-denormals-are-zero-daz/
February 17, 2012
On 17/02/12 09:09, Mantis wrote:
> 17.02.2012 4:30, bearophile пишет:
>> After seeing this interesting thread:
>> http://stackoverflow.com/questions/9314534/why-does-changing-0-1f-to-0-slow-down-performance-by-10x
>>
>>
>> Do you know if there's a simple way to perform _MM_SET_FLUSH_ZERO_MODE
>> in D?
>>
>> According to Agner that operation is not needed on Sandy Bridge
>> processors, but most CPUs around are not that good:
>> http://www.agner.org/optimize/blog/read.php?i=142
>>
>> Bye,
>> bearophile
>>
> I could expect this to be adjustable in std.math.FloatingPointControl,
> but it isn't.

That's because the x87 doesn't support flush-to-zero, and 32-bit x86 doesn't necessarily have SSE.
But it should probably be added for 64 bit.

Anyway, the assembly code to change FPU control word is
> pretty tiny:
> http://software.intel.com/en-us/articles/x87-and-sse-floating-point-assists-in-ia-32-flush-to-zero-ftz-and-denormals-are-zero-daz/
>