www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Flushing denormals to zero

reply bearophile <bearophileHUGS lycos.com> writes:
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
Feb 16 2012
parent reply Mantis <mail.mantis.88 gmail.com> writes:
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

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/
Feb 17 2012
parent Don Clugston <dac nospam.com> writes:
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

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/

Feb 17 2012