Analyzing Compilation Options
Compiler has a great impact on precision. Some compilation options sacrifice precision for performance, and some compilation options are implemented differently on different compilers. This section describes how to find the compilation options that affect the calculation result.
Prerequisites
The output of two platforms is the same when no compilation option is added even though the initial output of the two platforms is different. If there are differences caused by math libraries, use the open source math library SLEEF to temporarily block the differences. For details, see Using the Open-Source Database SLEEF.
The following uses WRF 3.4.1 as an example.
- Kunpeng uses the BiSheng Compiler. The initial compilation option is as follows:
FCBASEOPTS_NO_G = -w
- x86 uses ICC. The initial compilation options are as follows:
FCBASEOPTS_NO_G = -w -ftz -align all -fno-alias -fp-model precise
- Remove all the compilation options of FCBASEOPTS_NO_G from the two platforms.
The calculation results are the same.
- Kunpeng compilation option:
FCBASEOPTS_NO_G =
- x86 compilation option:
FCBASEOPTS_NO_G =
- Kunpeng compilation option:
- Gradually add the remaining compilation options.
- After -w is added, the calculation results on the two platforms are still the same.
- Kunpeng compilation option:
FCBASEOPTS_NO_G = -w
- Initial x86 compilation option:
FCBASEOPTS_NO_G = -w
- Kunpeng compilation option:
- Add -ftz. The calculation results on the two platforms are different.
- Kunpeng compilation option:
FCBASEOPTS_NO_G = -w
- x86 compilation options:
FCBASEOPTS_NO_G = -w -ftz
- Kunpeng compilation option:
- Block the -ftz compilation option and add other compilation options. No new compilation option affects the result.
- After -w is added, the calculation results on the two platforms are still the same.
- For the -ftz compilation option that affects the calculation result, analyze the cause of the difference and the modification method.
Parent topic: Difference Analysis Methods