‹ BackHN Continuity

Thread

Subnormal floating-point numbers are expensive on Intel processors

69 points · 54 comments · zdw

  1. khuey · · focus · HN ↗
    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.
    1. bee_rider · · focus · HN ↗
      IIRC intel’s compilers enable FTZ/DAZ, at least at higher optimization levels.
      1. account42 · · focus · HN ↗
        GCC does with the infamous -ffast-math as well.
        1. gpderetta · · focus · HN ↗
          IIRC that has been since split out of the flag and need to be asked for separately at link time.
          1. jcranmer · · focus · HN ↗
            If 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.
            1. gpderetta · · focus · HN ↗
              right, 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.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.