Skip to main content.

14. Floating Point

Some of the embedded PowerPC processors do not have a floating point unit(FPU), and so must perform all floating point operations in software. Others do have a hardware FPU unit and may perform operations in hardware.

14.1. Software

If your application has very intensive floating point requirements, you may need to switch to fixed point or choose a target processor which does have an FPU.

Floating point can be performed either by instruction emulation in the kernel, or by compiling everything with -msoft-float. In particular, it's important that all the libraries, whether dynamically or statically linked are compiled with the same options as the binaries that use them. Unless you're using a toolkit where this has already been done for you, this will generally mean that if you wish to use -msoft-float to gain maximum performance, you need to (re)compile everything, including:

You will almost certainly not get this right first time. The primary symptom is that printf gives bogus numbers for simple floating point values.However, if you succeed, you can save space by configuring the kernel without floating point emulation.

See http://lists.linuxppc.org/listarcs/linuxppc-embedded/199911/msg00056.html

To add kernel math emulation to the 2.2.13 kernel, see http://lists.linuxppc.org/listarcs/linuxppc-embedded/199912/msg00017.html

The "paranoia" test should give no complaints if everything is working correctly. See http://www.enseeiht.fr/NetLib/paranoia/index.html

14.2. Hardware

If your CPU has an FPU, you'll want to use it. Make sure that everything is consistently compiled for hardware floating point, especially if you've assembled your toolkit yourself, or are using an 8xx toolkit to compile for the 8260.

Programs compiled for hardware floating point can still run on a CPU without an FPU, provided the kernel is built with the floating point instruction emulator. This incurs a further performance penalty on CPUs lacking an FPU.

14.3. Mixed

If you are using a single set of shared libraries, you cannot mix the two techniques in the one system. If you link statically or try really hard by creating two sets of shared libraries, the two can co-exist since programs compiled with -msoft-float never generate floating point instructions requiring kernel emulation.

In general, you're better off choosing one or the other, and choosing hardware floating point with kernel instruction emulation is much easier to get working correctly.

13. Root Filesystem 1. Introduction 15. Realtime Response
Prev Home Next