.net - How are denormalized floats handled in C#? -


just read fascinating article 20x-200x slowdowns can on intel cpus denormalized floats (floating point numbers close 0).

there option sse round these off 0, restoring performance when such floating point values encountered.

how c# apps handle this? there option enable/disable _mm_flush_zero?

there no such option.

the fpu control word in c# app initialized clr @ startup. changing not option provided framework. if try change pinvoking _control87_2() not going last long; exception cause control word reset again exception handling implementation inside clr. written deal aspect of fpu control word, allows unmasking floating point exceptions. detrimental other managed code not expect global state changed that.

having no direct control on hardware implied restriction when run code in virtual machine. not @ easy in native code either, libraries tend misbehave when expect fpu have default initialization. particularly problem exception masking flags, dlls created borland tools have knack turning exceptions on, making other code fail isn't written deal such exception. extremely ugly problem solve, fpu control word worst possible global variable can imagine.

this put burden on not let floating point calculations go haywire this. calculating denormals produces nonsense results, if not radically small values, @ least quick loss of significant digits. truncating values less 2.2e-308 0 you. yes, not practical. perhaps okay program deliver nonsense results bit slower normal :)


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -