Programming Objectives of Floating-point Applications

In general, the programming objectives of the floating-point applications fall into the following categories:

Based on the goal of an application, you will need to balance the tradeoffs among these objectives. For example, if you are developing a 3D graphics engine, then performance can be the most important factor to consider, and reproducibility and accuracy can be your secondary concerns.

IntelĀ® Compiler provides appropriate compiler options, such as the -fp-model (Linux* and Mac OS* X) or /fp (Windows*) option, which allows you to tune your applications based on specific objectives. The compiler processes the code differently when you specify different compiler options. Take the following code as an example:

float t0, t1, t2;

...

t0=t1+t2+4.0f+0.1f;

If you specify the -fp-model extended (Linux and Mac OS X) or /fp:extended (Windows) option in favor of accuracy, the compiler generates the following assembly code:

fld       DWORD PTR _t1

fadd      DWORD PTR _t2

fadd      DWORD PTR _Cnst4.0

fadd      DWORD PTR _Cnst0.1

fstp      DWORD PTR _t0

If you specify the -fp-model source (Linux and Mac OS X) or /fp:source (Windows) option in favor of reproducibility and portability, the compiler generates the following assembly code:

movss     xmm0, DWORD PTR _t1

addss     xmm0, DWORD PTR _t2

addss     xmm0, DWORD PTR _Cnst4.0

addss     xmm0, DWORD PTR _Cnst0.1

movss     DWORD PTR _t0, xmm0

If you specify the -fp-model fast (Linux and Mac OS X) or /fp:fast (Windows) option in favor of performance, the compiler generates the following assembly code:

movss     xmm0, DWORD PTR _Cnst4.1

addss     xmm0, DWORD PTR _t1

addss     xmm0, DWORD PTR _t2

movss     DWORD PTR _t0, xmm0

In most case, an application will be much more complicated. You should select appropriate compiler options by carefully considering your programming objectives and balancing the tradeoffs among these objectives.