In general, the programming objectives of the floating-point applications fall into the following categories:
Accuracy: The application produces that results that are close to the correct result.
Reproducibility and portability: The application produces results that are consistent across different runs, different set of build options, different compilers, different platforms, and different architectures.
Performance: The application produces the most efficient code possible.
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*) or /fp (Windows*) option, which allows you to tune your applications based on specific objectives. The compiler process 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) 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) 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) 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 the real world, an application may be much more complicated. You should select appropriate compiler options by carefully consider your programming objectives and balance the tradeoffs among these objectives.