Consistency of Floating-Point Results Using the Intel® Compiler

ID 标签 659217
已更新 12/19/2018
版本 Latest
公共

author-image

作者

Why Does My Application Give Differing Answers? 

Binary floating-point representations of most real numbers are inexact, and there is an inherent uncertainty in the result of most calculations involving floating-point numbers. Programmers of floating-point applications typically have the following objectives:

  • Accuracy:
    • Produce results that are close to the result of the exact calculation
      • Usually measured in fractional error, or sometimes units in the last place
  • Reproducibility
    • Produce consistent results:
      • From one run to the next
      • From one set of build options to another
      • From one compiler to another
      • From one processor or operating system to another
  • Performance
    • Produce an application that runs as fast as possible

These objectives often result in a conflict. However, good programming practices and judicious use of compiler options allow you to control the tradeoffs. For example, it is sometimes useful to have a degree of reproducibility that goes beyond the inherent accuracy of a computation. Some software quality assurance tests may require close, or even bit-for-bit, agreement between results before and after software changes, even though the mathematical uncertainty in the computation result may be considerably larger. The right compiler options can deliver consistent, closely reproducible results while preserving good (though not optimal) performance.

Bottom Line

Compiler options let you control the tradeoffs between accuracy, reproducibility, and performance. Use /fp:precise /fp:source (Windows*) or -fp-model precise -fp-model source (Linux*) to improve the consistency and reproducibility of floating-point results while limiting the impact on performance. If reproducibility between different processor types of the same architecture is important, include /Qimf-arch-consistency:true (Windows) or -fimf-arch-consistency=true (Linux). For best reproducibility between processors that support fused multiply-add (FMA) instructions and processors that do not, include /Qfma- (Windows) or -no-fma (Linux). 

For version 17 or later of the compiler, the best reproducibility may be obtained with the single switch /fp:consistent (Windows) or -fp-model consistent (Linux), which sets the above options.

Starting with version 18 of the compiler, for applications with vectorizable loops containing math functions, it may be possible to improve performance while maintaining reproducibility by adding /Qimf-use-svml (Windows) or -fimf-use-svml (Linux).

This article only includes partial content. If you want to read the full article, please download the PDF. This content is for a previous version of the compiler; this content will be updated with a future release.