我要评分
获取效率
正确性
完整性
易理解

Compilers

Different compilers can generate different calculation results when executing the same code. This is mainly because the compiler performs different tuning and conversion when converting the source code into the target code. As a result, the generated machine code is different. These tunings and conversions may include:

  • Compiler tuning: The compiler attempts to tune the code in various ways, such as eliminating unnecessary calculations, reducing the number of iterations of loops, and inlining functions. These tunings may generate different machine code, which affects the calculation results of the program.
  • Compiler conversion: Different compilers may convert the source code into different target code formats, such as different machine code formats or different byte sequences. These conversions may generate different machine code, which affects the calculation results of the program.
  • Compiler implementation: Different compilers may use different implementations to process a same language feature. For example, different compilers may use different garbage collection mechanisms or memory managements. These implementations may generate different machine code, which affects the calculation results of the program.

The compiler has the following impacts on the precision:

  • The precision of floating-point numbers is limited.
  • Each compiler has options that affect the results of floating-point calculations.
    • Intel performs special processing on multiplication and addition calculations and simplifies them into fusion instructions. The simplified rules are different from those of BiSheng.
    • The Intel precise mode does not comply with the standard.
    • When ICC uses the -fp-model precise -O0/O1 and -fp-model precise -O3 compilation options, the calculation results of SUMDP are different. This indicates that the ICC implementation does not comply with the precision standard.

    • There is a problem for the BiSheng compiler to process immediate constants. For example, the immediate constant 0.002362E12 read by different compilers to the memory is inconsistent. For an immediate whose type is undefined, the value read to the memory is not defined in the IEEE 754 standard. Therefore, different compilers lead to different implementations which cause this problem.
  • The implementation of the compilation option for each compiler is different. As a result, the generated default values are different.
  • There are options that can be enabled and disabled by options that seem irrelevant.
  • When both platforms use consistent options, the compiler can ensure that the error range is controllable.