Intel® oneAPI DPC++/C++ Compiler Developer Guide and Reference

ID 767253
Date 3/22/2024
Public
Document Table of Contents

fp-model, fp

Controls the semantics of floating-point calculations.

Syntax

Linux:

-fp-model=keyword

Windows:

/fp:keyword

Arguments

keyword

Specifies the semantics to be used. Possible values are:

precise

Disables optimizations that are not value-safe on floating-point data.

fast

Enables more aggressive optimizations on floating-point data.

consistent

Disables optimizations that are not value-safe on floating-point data and disables contraction (FMA) and selects math library functions that produce consistent results across different microarchitectural implementations of the same architecture.

strict

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

Default

-fp-model=fast
or /fp:fast

The compiler uses more aggressive optimizations on floating-point calculations.

Description

This option controls the semantics of floating-point calculations.

The floating-point (FP) environment is a collection of registers that control the behavior of FP machine instructions and indicate the current FP status. The floating-point environment may include rounding-mode controls, exception masks, flush-to-zero controls, exception status flags, and other floating-point related features.

Option

Description

-fp-model=precise or /fp:precise

Tells the compiler to strictly adhere to value-safe optimizations when implementing floating-point calculations. It disables optimizations that can change the result of floating-point calculations, which is required for strict ANSI conformance.

These semantics ensure the reproducibility of floating-point computations for serial code, including code vectorized or auto-parallelized by the compiler, but they may slow performance. They do not ensure value safety or run-to-run reproducibility of other parallel code.

Run-to-run reproducibility for floating-point reductions in OpenMP* code may be obtained for a fixed number of threads through the KMP_DETERMINISTIC_REDUCTION environment variable. For more information about this environment variable, see topic "Supported Environment Variables".

The compiler assumes the default floating-point environment; you are not allowed to modify it.

-fp-model=fast or /fp:fast

Tells the compiler to use more aggressive optimizations when implementing floating-point calculations. These optimizations increase speed, but they may affect the accuracy or reproducibility of floating-point computations.

-fp-model=consistent or /fp:consistent

Disables optimizations that are not value-safe on floating-point data and disables contraction (FMA) and selects math library functions that produce consistent results across different microarchitectural implementations of the same architecture.

For more information, see the article titled: Consistency of Floating-Point Results using the Intel® Compiler.

-fp-model=strict or /fp:strict

Tells the compiler to strictly adhere to value-safe optimizations when implementing floating-point calculations and enables floating-point exception semantics. This is the strictest floating-point model.

The compiler does not assume the default floating-point environment; you are allowed to modify it.

The -fp-model and /fp options determine the setting for the maximum allowable relative error for math library function results (max-error) if none of the following options are specified:

  • -fimf-accuracy-bits (Linux*) or /Qimf-accuracy-bits (Windows*)

  • -fimf-max-error (Linux) or /Qimf-max-error (Windows)

  • -fimf-precision (Linux) or /Qimf-precision (Windows)

Option -fp-model=fast (and /fp:fast) sets option -fimf-precision=medium (/Qimf-precision:medium) and option -fp-model=precise (and /fp:precise); it implies -fimf-precision=high (and /Qimf-precision:high).

NOTE:

In Microsoft* Visual Studio, when you create a Microsoft* Visual C++ project, option /fp:precise is set by default. It sets the floating-point model to improve consistency for floating-point operations by disabling certain optimizations that may reduce performance. To set the option back to the general default /fp:fast, change the IDE project property for Floating Point Model to Fast.

Product and Performance Information

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.

Notice revision #20201201

IDE Equivalent

Visual Studio: Code Generation>Floating Point Model

Code Generation>Enable Floating Point Exceptions

Code Generation> Floating Point Expression Evaluation

Eclipse: Floating Point > Floating Point Model

Alternate Options

None