|When compiling an application at -O2 on IA-32 for X87 code, the application gets stuck in an infinite loop. When compiling the application at -O0, the application runs to completion.|
The infinite loop can occur if the application depends on rounding effects to determine machine precision (as in LAPACK). This can occur because the precision of the floating point registers is a full 80-bit internal precision. The reason this works at -O0 is that -O0 enables -fltconsistency, which truncates precison from internal precision to declared precision in many places. If you do have a precision/rounding issue in your code with -O2, you can eliminate it by adding -fp-model source (or -fp-model precise, which, for Fortran, is the same). -fp-model source computes intermediate results in source precision and rounds after each operation.
It is best to rewrite the code so that it is not sensitive to slight variations in precision, because using -fp-model source with optimization results in some loss in floating point performance.
As a final note, the older switches, -mp or -fltconsistency, should not be used in conjuction with the -fp-model family of switches.
Intel® Fortran Compiler for Linux* - Code dependent on rounding effects may produce unexpected results
Для получения подробной информации о возможностях оптимизации компилятора обратитесь к нашему Уведомлению об оптимизации.