I'm working on an application where runtime speed is more important than precision. The number crunching involves floating point arithmetic and I'm concerned about double and/or long double being handled in software instead of natively on the processor (this is always true on a 32-bit arch right?). I would like to conditionally compile using the highest precision with hardware support, but I haven't found a quick and easy way to detect software emulation. I'm using g++ on GNU/Linux and I'm not concerned about portability. It's running on x86 arch, so I'm assuming that float is always native.
The Floating-point unit (FPU) on modern x86 is natively double (in fact, it's even bigger than double), not float (the "32" in 32-bit describes the integer register widths, not the floating-point width). This is not true, however, if your code is taking advantage of vectorized SSE instructions, which do either 4 single or 2 double operations in parallel.
If not, then your main speed hit by switching your app from float to double will be in the increased memory bandwidth.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With