-
Notifications
You must be signed in to change notification settings - Fork 438
Description
Somewhat confusingly, setting AMReX_FPE=ON in the CMake options turns on compiler-specific flags that are not always equivalent to setting the amrex.fpe_trap_* ParmParse parameters.
For instance, when using gcc, AMReX_FPE=ON adds -ftrapv to the compile flags, which appears to only detect signed integer overflow (and also is broken in several gcc releases: https://blog.robertelder.org/gcc-signed-overflow-trapping-ftrapv-doesnt-work/)
amrex/Tools/CMake/AMReXFlagsTargets.cmake
Line 137 in 39f46ae
| $<${_cxx_gnu}:-ftrapv> |
Whereas the runtime options change the FPU state explicitly for specified FPU exceptions:
Line 563 in 39f46ae
| if (invalid) { curr_fpe_excepts |= FE_INVALID; } |
I think it would be more consistent to have AMReX_FPE change the defaults for the runtime parameters, so that the behavior is exactly consistent. Otherwise, the documentation (https://amrex-codes.github.io/amrex/docs_html/Debugging.html) should be changed to make it very clear that these two options are not equivalent.