- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am observing slight differences in a floating calculations between ifx 2024.2.0 and ifort 2021.13.0.
Here are the compiler flags being used for this comparison:
"-O2 -prec-div -fpconstant -fp-model=strict"
Replacing "-fp-model=strict" with "-fp-model=precise" gives the same output for both ifx 2024.2.0 and ifort 2021.13.0.
Are there additional flags I should add for ifx to make it behave as much as possible like ifort when "-fp-model=strict" is being used?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you haven't checked it out yet, please see fp-model, fp Compiler Option in Porting Guide for Intel® Fortran Compiler
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have extracted a small sample code segement that has a number of adds, multiplies, divides of KIND=4 reals that reproduces a differing result between ifx and ifort. Based on the porting guide referenced above, I have tried the following combination of flags. Note that the desire is to maintain the use of -fp-model=strict with ifx in order to match results from ifort as much as possible.
Based on the updates in the porting guide, here are the flag combinations I have tested. However, I am unable to find a combination that allows the continued use of -fp-model=strict and produces the same result between ifort and ifx.
For each of these tests, the ifort flags used were "-O2 -prec-div -fpconstant -fp-model=strict". I'm referring to the sample output calculation produced by ifort as the "baseline" here.
1: "ifx -O2 -prec-div -fpconstant -fp-model=strict"
- NO MATCH: results in floating point result calculation having delta from ifort baseline
2: "ifx -O2 -prec-div -fpconstant -fp-model=strict -assume ieee_compares"
- NO MATCH: results in floating point result calculation having delta from ifort baseline
3: "ifx -O2 -prec-div -fpconstant -fp-model=strict -assume noieee_compares"
- NO MATCH: results in floating point result calculation having delta from ifort baseline
4: "ifx -O2 -prec-div -fpconstant -fp-model=strict -assume ieee_compares -assume nan_compares"
- NO MATCH: results in floating point result calculation having delta from ifort baseline
5: "ifx -O2 -prec-div -fpconstant -fp-model=strict -assume iee_compares -assume nonan_compares"
- NO MATCH: results in floating point result calculation having delta from ifort baseline
6: "ifx -O2 -prec-div -fpconstant -fp-model=precise"
- MATCH: zero delta with ifort -fp-model=strict baseline
7: "ifx -O2 -prec-div -fpconstant -fp-model=strict -fp-model=consistent"
- NO MATCH: results in floating point result calculation having delta from ifort baseline
8: "ifx -O2 -prec-div -fpconstant"
- MATCH: zero delta with ifort -fp-model=strict baseline
9: "ifx -O2 -prec-div -fpconstant -fp-model=source"
- MATCH: zero delta with ifort -fp-model=strict baseline
10: "ifx -O2 -prec-div -fpconstant -fp-model=fast=1"
- MATCH: zero delta with ifort -fp-model=strict baseline
11: "ifx -O2 -prec-div -fpconstant -fp-model=fast=2"
- MATCH: zero delta with ifort -fp-model=strict baseline
While flag combinations in 6, 8, 9, 10, 11 produce matching results with the ifort baseline, they require an fp-model other than strict.
Are there suggestions for other flag combinations that are recommended in order to match the behavior of the baseline ifort flags as closely as possible?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
May I suggest that you read Improving Numerical Reproducibility in C/C++/Fortran? You may be unable to get last-bit identical results. ifx has a completely different code generator and optimizer from ifort.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks. As described in the slide "FP Expression Evaluation", my example does appear to be a case where ifort and ifx are performing the order of operations for an expression differently (in the resulting assembly) even with -fp-model=strict. I was able to add an additional set of parentheses in the expression and observe ifx and ifort produce the same results. Examining the resulting assembly (using gdb) from the two compilers for the example also confirmed slightly different order of operations. In this specific example, ifx maintained an intermediate value in one of the 128-bit xmm registers while ifort saved off the intermediate value to the stack. Perhaps the rounding that would occur with ifort but not ifx for this intermediate value accounts for the difference in results.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page