-
-
Notifications
You must be signed in to change notification settings - Fork 409
Closed
Labels
Description
Problem description
As reported in #1150, compilation with default optimization options for the Intel compiler suite icx/icpx results in incorrect results. The behavior can be reproduced for gcc with the -ffinite-math-only option (which is one of the -ffast-math flags), e.g. for a vanilla gcc toolchain on Ubuntu 20.04:
$ scons build optimize_flags="-O3 -ffinite-math-only"
The option breaks strict IEEE compliance, as it does "Allow optimizations for floating-point arithmetic that assume that arguments and results are not NaNs or +-Infs." There are some instances where Cantera uses NaN internally which presumably breaks 'fast math' optimizations.
Steps to reproduce
- Compile as indicated above.
- An attempt to run the test suite results in numerous segfaults.
- Output for
gccwith fast math (same as foricxin Optimized Cantera build with the LLVM-based Intel compilers do not work correctly #1150) ...
In [3]: gas2 = ct.Solution('gri30.yaml')
In [4]: gas2.partial_molar_cp
Out[4]:
array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
0., 0.])
In [5]: gas2.partial_molar_entropies
Out[5]:
array([-1.84618157e-12, 5.74342730e+06, 5.74342730e+06, 5.74342730e+06,
5.74342730e+06, 5.74342730e+06, 5.74342730e+06, 5.74342730e+06,
5.74342730e+06, 5.74342730e+06, 5.74342730e+06, 5.74342730e+06,
5.74342730e+06, 5.74342730e+06, 5.74342730e+06, 5.74342730e+06,
5.74342730e+06, 5.74342730e+06, 5.74342730e+06, 5.74342730e+06,
5.74342730e+06, 5.74342730e+06, 5.74342730e+06, 5.74342730e+06,
5.74342730e+06, 5.74342730e+06, 5.74342730e+06, 5.74342730e+06,
5.74342730e+06, 5.74342730e+06, 5.74342730e+06, 5.74342730e+06,
5.74342730e+06, 5.74342730e+06, 5.74342730e+06, 5.74342730e+06,
5.74342730e+06, 5.74342730e+06, 5.74342730e+06, 5.74342730e+06,
5.74342730e+06, 5.74342730e+06, 5.74342730e+06, 5.74342730e+06,
5.74342730e+06, 5.74342730e+06, 5.74342730e+06, 5.74342730e+06,
5.74342730e+06, 5.74342730e+06, 5.74342730e+06, 5.74342730e+06,
5.74342730e+06])
Behavior
System information
- Cantera version: 2.5.1, 2.6.0a3
- OS: Ubuntu 20.04 (and presumably others)
- Python/MATLAB/other software versions:
gcc/icx
Additional context
- See initial issue report Optimized Cantera build with the LLVM-based Intel compilers do not work correctly #1150; a new issue is opened as the behavior is not compiler-dependent.
- In case the issue is worth pursuing, some workarounds need to be found for
{fmt}output, which currently produces numerous warnings related toNaNcompliance. - An alternative check for
NaNcan be implemented, see SO
Reactions are currently unavailable