[racket] Fun with denormalized floating point numbers

From: Asumu Takikawa (asumu at ccs.neu.edu)
Date: Wed Aug 1 15:05:26 EDT 2012

On 2012-08-01 12:40:04 -0600, Michael Wilber wrote:
> Fascinating. I wonder if your machine has better floating point hardware
> So maybe this is just something to watch out for on older chips.

FWIW, on an AMD Phenom II X2 555:
  subnormal addition:
  cpu time: 1668 real time: 1680 gc time: 0
  cpu time: 1672 real time: 1674 gc time: 0
  cpu time: 1660 real time: 1656 gc time: 0
  cpu time: 1664 real time: 1663 gc time: 0
  cpu time: 1676 real time: 1675 gc time: 0

  normal addition:
  cpu time: 144 real time: 141 gc time: 0
  cpu time: 140 real time: 144 gc time: 0
  cpu time: 140 real time: 137 gc time: 0
  cpu time: 140 real time: 139 gc time: 0
  cpu time: 144 real time: 144 gc time: 0

On a Core i5 3210M (similar numbers on an i7):

  subnormal addition:
  cpu time: 80 real time: 80 gc time: 0
  cpu time: 84 real time: 83 gc time: 0
  cpu time: 164 real time: 166 gc time: 0
  cpu time: 88 real time: 86 gc time: 0
  cpu time: 84 real time: 86 gc time: 0

  normal addition:
  cpu time: 84 real time: 81 gc time: 0
  cpu time: 84 real time: 85 gc time: 0
  cpu time: 76 real time: 78 gc time: 0
  cpu time: 88 real time: 89 gc time: 0
  cpu time: 88 real time: 84 gc time: 0

So it looks like newer Intel chips are a lot faster on the subnormal
case. Some searching turned up this:
  http://www.agner.org/optimize/microarchitecture.pdf

Which has the following snippet:
  "The Sandy Bridge has eliminated some of these penalties by handling
  underflow and denormal numbers in hardware rather than in microcode
  exceptions for the case of addition."

(the i5 I'm running is an Ivy Bridge, the successor to Sandy Bridge)

Cheers,
Asumu

Posted on the users mailing list.