0

I'm not really able with compiler/sse, but for some purpose I need to check if the denormals numbers are deactivated (for optimizing performances).

How do I check if my compiler has those flags (FTZ and DMZ) on/off? I'm on Visual Studio 2015 and Windows 10 Professional.

Theoretically is in the x86intrin.h? I can't find it.

EDIT

Within C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\crt\src\linkopts\loosefpmath.cpp I have this code:

//
// loosefpmath.cpp
//
//      Copyright (c) Microsoft Corporation. All rights reserved.
//
// A link option that sets the DAZ and FTZ bits for SSE2 architectures.
//
#include <float.h>



extern "C" void __CRTDECL _initialize_denormal_control()
{
    _controlfp_s(nullptr, _DN_FLUSH, _MCW_DN);
}
markzzz
  • 47,390
  • 120
  • 299
  • 507
  • Have a read of (and parents of): https://msdn.microsoft.com/en-us/library/a8b5ts9s(v=vs.100).aspx says in header `xmmintrin.h` Note that the FPU state is per thread. – Richard Critten Aug 25 '16 at 09:38
  • 1
    Your compiler doesn't control those bits. You can see the code you want in C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\crt\src\linkopts\loosefpmath.cpp – Hans Passant Aug 25 '16 at 10:54
  • @HansPassant: edited the answer! Check the code! Are denormals value ignored with that settings? – markzzz Aug 25 '16 at 11:18
  • Well, not ignored, the point is to get them truncated to 0. Try it. – Hans Passant Aug 25 '16 at 11:20
  • For an explanation of `_DN_FLUSH` see here: http://stackoverflow.com/questions/2051534/floating-point-math-execution-time (you could find this easily with a Google search). – Cody Gray - on strike Aug 25 '16 at 11:24
  • @HansPassant: yes, what I mean! The question is: whit my actual settings, is compiler already truncate them to 0? Or need I to add further flags? – markzzz Aug 25 '16 at 12:21
  • 1
    As noted, no, the compiler does not control this. You have to call _controlfp_s() like that yourself before you do the math that needs to be "fast". I do recommend you restore it afterwards, tinkering with this processor register can be destabilizing to math code in a library that was tested with normal settings. Albeit that FTZ is fairly innocent. Fwiw, you found this code in the CRT source directory only because it is used in UWP apps. – Hans Passant Aug 25 '16 at 15:22

0 Answers0