Install denormal flush to zero (FTZ) in Xcode

I am using Xcode for C ++ development on OS X Mountain Lion to run on the local machine. I have performance issues with denormal numbers, and I want to set the FTZ flag so that they are reset to zero. (I checked that denormals are indeed a problem, and resetting them to zero will not cause errors in my case.) However, I cannot find any information on how I should do this in Xcode. Is this an option that I can change in the build settings? Or some code that I have to enter somewhere? Any help would be greatly appreciated.

+4
source share
1 answer

If I understand the comments in "/usr/include/fenv.h" correctly,

#include <fenv.h> fesetenv(FE_DFL_DISABLE_SSE_DENORMS_ENV); 

should do what you want.

  FE_DFL_DISABLE_SSE_DENORMS_ENV

     A pointer to a fenv_t object with the default floating-point state modifed
     to set the DAZ and FZ bits in the SSE status / control register.  When using
     this environment, denormals encountered by SSE based calculation (which
     normally should be all single and double precision scalar floating point
     calculations, and all SSE / SSE2 / SSE3 computation) will be treated as zero.
     Calculation results that are denormals will also be truncated to zero.

Setting this option reduced the programโ€™s runtime. Why does changing 0.1f to 0 slow down performance by 10x? (link given by @Mysticial in his comment) from 27 seconds to 0.3 seconds (MacBook Pro, 2.5 GHz Intel Core 2 Duo).

+6
source

Source: https://habr.com/ru/post/1482691/


All Articles