Developer Guide and Reference

Contents

Programming Tradeoffs in Floating-Point Applications

In general, the programming objectives for floating-point applications fall into the following categories:
  • Accuracy:
    The application produces results that are close to the correct result.
  • Reproducibility and portability:
    The application produces consistent results across different runs, different sets of build options, different compilers, different platforms, and different architectures.
  • Performance:
    The application produces fast, efficient code.
Based on the goal of an application, you will need to make tradeoffs among these objectives. For example, if you are developing a 3D graphics engine, performance may be the most important factor to consider, with reproducibility and accuracy as secondary concerns.
The Intel®
C++
Compiler provides several compiler options that allow you to tune your applications based on specific objectives. Broadly speaking, there are the floating-point specific options, such as the
-fp-model
(Linux*
and
macOS*
) or
/fp
(Windows*) option, and the fast-but-low-accuracy options, such as the
[Q]imf-max-error
option. The compiler optimizes and generates code differently when you specify these different compiler options. Select appropriate compiler options by carefully balancing your programming objectives and making tradeoffs among these objectives. Some of these options may influence the choice of math routines that are invoked.
Many routines in the
libirc
,
libm
, and
svml
library are more highly optimized for Intel microprocessors than for non-Intel microprocessors.

Using Floating-Point Options

Take the following code as an example:
Example
float t0, t1, t2; ... t0=t1+t2+4.0f+0.1f;
If you specify the
-fp-model extended
(Linux*
and
macOS*
) or
/fp:extended
(Windows*) option in favor of accuracy, the compiler generates the fo