Using the -fp-model or /fp Option

The -fp-model (Linux* and Mac OS*) or /fp (Windows*) option allows you to control the optimizations on floating-point data. You can use this option to tune the performance, level of accuracy, or result consistency across platforms for floating-point applications.

For applications that do not require support for denormalized numbers, the -fp-model or /fp option can be combined with the -ftz (Linux and Mac OS) or /Qftz (Windows) option to flush denormalized results to zero in order to obtain improved runtime performance on processors based on:

You can use keywords to specify the semantics to be used. Possible values of the keywords are as follows:

Keyword

Description

precise

Enables value-safe optimizations on floating-point data.

fast[=1|2]

Enables more aggressive optimizations on floating-point data.

strict

Enables precise and except, disables contractions, and enables pragma stdc fenv_access.

source

Rounds intermediate results to source-defined precision and enables value-safe optimizations.

double

Rounds intermediate results to 53-bit (double) precision and enables value-safe optimizations.

extended

Rounds intermediate results to 64-bit (extended) precision and enables value-safe optimizations.

[no-]except (Linux and Mac OS) or
except[-]
(Windows)

Determines whether floating-point exception semantics are used.

The default value of the option is -fp-model fast=1 or /fp:fast=1, which means that the compiler uses more aggressive optimizations on floating-point calculations.

Several examples are provided to illustrate the usage of the keywords. These examples show:

-fp-model fast or /fp:fast

Example source code:

float t0, t1, t2;

...

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

When this option is specified, the compiler applies the following semantics:

Using these semantics, the following shows some possible ways the compiler may interpret the original code:

float t0, t1, t2;

...

t0 = (float)((double)t1 + (double)t2) + 4.1f;

 

float t0, t1, t2;

...

t0 = (t1 + t2) + 4.1f;

 

float t0, t1, t2;

...

t0 = (t1 + 4.1f) + t2;

 

-fp-model extended or /fp:extended

This setting is equivalent to -fp-model precise on Linux systems based on the IA-32 architecture and -fp-model precise or /fp:precise on systems based on the IA-64 architecture.

Example source code:

float t0, t1, t2;

...

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

When this option is specified, the compiler applies the following semantics:

Using these semantics, the following shows a possible way the compiler may interpret the original code:

float t0, t1, t2;

...

t0 = (float)(((long double)4.1f + (long double)t1) + (long double)t2);

 

-fp-model source or /fp:source

This setting is equivalent to -fp-model precise or /fp:precise on systems based on the Intel® 64 architecture.

Example source code:

float t0, t1, t2;

...

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

When this option is specified, the compiler applies the following semantics:

Using these semantics, the following shows a possible way the compiler may interpret the original code:

float t0, t1, t2;

...

t0 = ((4.1f + t1) + t2);

 

-fp-model double or /fp:double

This setting is equivalent to -fp-model precise or /fp:precise on Windows systems based on the IA-32 architecture.

Example source code:

float t0, t1, t2;

...

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

When this option is specified, the compiler applies the following semantics:

Using these semantics, the following shows s a possible way the compiler may interpret the original code:

float t0, t1, t2;

...

t0 = (float)(((double)4.1f + (double)t1) + (double)t

 

-fp-model strict or /fp:strict

Example source code:

float t0, t1, t2;

...

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

When this option is specified, the compiler applies the following semantics:

Using these semantics, the following shows a possible way the compiler may interpret the original code:

float t0, t1, t2;

...

t0 = (float)((((long double)4.0f + (long double)0.1f) +

               (long double)t1) + (long double)t2);

 

See Also