3 ms·
If you don't _need_ subnormals MXCSR.DAZ/FTZ (which you can get gcc to set via -mdaz-ftz) will let you ignore all of this.
by khuey 8d ago
If you don't _need_ subnormals MXCSR.DAZ/FTZ (which you can get gcc to set via -mdaz-ftz) will let you ignore all of this.
- bee_rider 8d agoIIRC intel’s compilers enable FTZ/DAZ, at least at higher optimization levels.
- account42 8d agoGCC does with the infamous -ffast-math as well.
- gpderetta 8d agoIIRC that has been since split out of the flag and need to be asked for separately at link time.
- jcranmer 8d agoIf you use -ffast-math when linking an executable but not a shared library, both gcc and clang will link in crtfastmath.o which has the bit of code to set the DAZ/FTZ flags.
- deleted 8d ago[deleted]
- gpderetta 8d agoright, but the issue was that if an application was linked with a library that happened to link with a fast-math shared library, it would unknowingly bring along the crt code. Now the only way to get it is to use the fast-math flag when linking the final binary, which at least is an explicit request.
- adrian_b 7d agoWhich is certain to produce big errors at every instance where a subnormal result would have been generated or propagated otherwise. Such options exist only for games or for experts in numeric analysis, not for general-purpose programming.
- adrian_b 7d agoMost people who believe that they do not need subnormals do not actually know whether they need or not subnormals and it is very likely that they need subnormals. The options mentioned above are guaranteed to generate big errors, so they are acceptable only when errors really do not matter, e.g. in graphics for games. The only correct option for avoiding subnormals is to enable the underflow exception and handle it in a manner that is considered more suitable for that application than the use of subnormals.