denormals.h 615 B

123456789101112131415161718192021222324252627282930313233
  1. // Denormals stripping.
  2. // These snippets should be common enough to be considered public domain.
  3. #ifndef DENORMALS_H
  4. #define DENORMALS_H
  5. #ifdef __SSE__
  6. #include <xmmintrin.h>
  7. #endif
  8. #ifdef __SSE3__
  9. #include <pmmintrin.h>
  10. #endif
  11. // Set denormal protection for this thread.
  12. // To be on the safe side, don't set the DAZ flag for SSE2 builds,
  13. // even if most SSE2 CPUs can handle it.
  14. void inline disable_denormals() {
  15. #ifdef __SSE3__
  16. /* DAZ flag */
  17. _MM_SET_DENORMALS_ZERO_MODE( _MM_DENORMALS_ZERO_ON );
  18. #endif
  19. #ifdef __SSE__
  20. /* FTZ flag */
  21. _MM_SET_FLUSH_ZERO_MODE( _MM_FLUSH_ZERO_ON );
  22. #endif
  23. }
  24. #endif