Avoiding denormal values in C++

前端 未结 6 814
遇见更好的自我
遇见更好的自我 2020-11-30 04:34

After searching a long time for a performance bug, I read about denormal floating point values.

Apparently denormalized floating-point values can be a major performa

6条回答
  •  Happy的楠姐
    2020-11-30 05:18

    Most math coprocessors have an option to truncate denormal values to zero. On x86 it is the FZ (Flush to Zero) flag in the MXCSR control register. Check your CRT implementation for a support function to set the control register. It ought to be in , something resembling _controlfp(). The option bit usually has "FLUSH" in the #defined symbol.

    Double-check your math results after you set this. Which is something you ought to do anyway, getting denormals is a sign of health problems.

提交回复
热议问题