The same floating-point AMD X86-64 digital signal processing system mentioned in my previous question has a problem where it sometimes slows down substantially when signals attain values very near (but not exactly) zero.

The problem is that denormalized floating point values require special processing by the CPU which is dramatically slower than dealing with normal floating point values. This can cause the DSP system to run too slow--taking longer than $1/f_s$ to compute everything that needs to be computed in one cycle.

A workaround is to add a small offset to all numbers to force them into the range of normal numbers. Is there a way to instead instruct the FPU to simply not generate denormal numbers in the first place?

The OS is Linux and the compiler is gcc.

EDIT: Also, what are the numerical consequences of disabling denormal numbers?

  • $\begingroup$ Are you using x87 FPU instructions, MMX, SSE, AVX, all of the above, etc.? $\endgroup$
    – Jason R
    Aug 29 '11 at 18:49
  • $\begingroup$ Just FPU, I think. Double precision. For the most part, the math is implemented directly in C and the C compiler (gcc) does whatever it does. Instead of the math library we use some small inline assembly functions to get sincos, etc. $\endgroup$
    – nibot
    Aug 29 '11 at 18:50

You can force denormal numbers to zero by setting the "flush to zero" and "denormals are zero" bits (15,6) in the MXCSR register.

_mm_setcsr( _mm_getcsr() | (1<<15) | (1<<6));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.