3 ms·
I think NaNs tend to pollute results more effectively than denormals. However NaNs can be trapped easily by enabling the appropriate floating-point exceptions s
by brucedawson 12y ago
I think NaNs tend to pollute results more effectively than denormals. However NaNs can be trapped easily by enabling the appropriate floating-point exceptions so that they turn into crashes.
Note that on most CPUs flush-to-zero is a CPU state so it's not really a default of a compiler, but of a run-time. Also, it is a per-thread state, so you can end up with code that runs faster (and with different results) on one thread from another!
I'm glad you liked the articles. There have actually been several in the Floating Point category since then. I think this one is the most important:
https://randomascii.wordpress.com/2014/01/27/theres-only-four-billion-floatsso-test-them-all/ https://randomascii.wordpress.com/2014/01/27/theres-only-fou...
but the entire set is available ehre:
https://randomascii.wordpress.com/category/floating-point/ https://randomascii.wordpress.com/category/floating-point/
- nkurz 12y agoThanks for the articles and the response! Yes, it's a CPU state, but I'm pretty sure that by default different compilers set it differently at thread start (or alternatively, choose to leave it as is). The ICC to GCC switch was the one that tricked me. So while the changes at runtime can override either, in the absence of an explicit override you'll often see different behavior based on compiler choice. Useful details and links here: http://stackoverflow.com/questions/9314534/why-does-changing-0-1f-to-0-slow-down-performance-by-10x http://stackoverflow.com/questions/9314534/why-does-changing...