← Fri, Sep 18 digest

Subnormal floating-point numbers are expensive on Intel processors

read article ↗ hn thread ↗

summary

Subnormal floating-point numbers cause severe performance degradation on modern Intel processors, while AMD and Arm processors handle them with little to no penalty. This performance hit occurs because Intel CPUs treat subnormals as special cases that require significantly more clock cycles to process. Consequently, developers targeting Intel hardware may still need to avoid subnormals to maintain high computational speed.

key points

  1. Multiplications and divisions on Intel processors are drastically slower when subnormals are involved, with multiplication latency increasing from 4 cycles to 128 cycles in dependent chains.
  2. The performance penalty on Intel is so severe that even a small percentage of subnormal values can slow down entire vectorized blocks of computation.
  3. In contrast, AMD Zen 5 and Arm processors (Graviton 5 and Apple M4 Max) process subnormals at nearly full speed, making them a non-issue for those architectures.

who should read it

Software performance engineers, game developers, and machine learning specialists who optimize floating-point calculations for diverse hardware architectures.

discussion mixed

consensus

Commenters agree that subnormal numbers often cause significant performance penalties on Intel CPUs because they are handled via microcode rather than dedicated silicon. The prevailing solution is to enable 'flush-to-zero' (FTZ) and 'denormals-are-zero' (DAZ) flags, often via compiler flags like -ffast-math, to treat these tiny numbers as zero. While subnormals provide mathematical benefits like gradual underflow and the property that x-y == 0 implies x == y, most practitioners find them unnecessary for general use cases.

top insight

Intel's P-cores continue to suffer from subnormal performance penalties while newer E-cores have implemented a fast path for them. This discrepancy is attributed to different design teams and the inertia of semiconductor engineering, where older beliefs about the rarity of subnormals persisted in the P-core architecture while the E-core team adopted more modern FP implementations.

Generated by an LLM from the article and thread. Check the sources before relying on it.