Enable -O0 and runtime diagnostics in DEBUG build for ICON - #138
Draft
s-poll wants to merge 1 commit into
Draft
Conversation
…BUG build in BuildICON.cmake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CMAKE_BUILD_TYPE=DEBUGcurrently only adds-gto the ICON build. Under Intel, no-Olevel is set explicitly, so the compiler defaults to-O2— the "debug" build is actually optimized and gets no runtime checking at all. This made a recent segfault in ecRad take roughly a day to isolate;-check boundsalone would have pointed at it in minutes.This PR makes
DEBUGa real debug build: unoptimized and instrumented with runtime diagnostics, for both compilers.Solves #137
Changes
In
cmake/BuildICON.cmake, theDEBUGbranch now sets:-O0(explicit, both compilers) — closes the implicit-O2gap under Intel-check bounds(Intel) /-fcheck=bounds(GNU)-check uninit(Intel); on GNU there's no direct runtime-uninit-check equivalent, so this is approximated via NaN-poisoning + FP trapping below-fpe0(Intel) /-ffpe-trap=invalid,zero,overflow(GNU)-init=snan(Intel) /-finit-real=snan(GNU)Flags are gated on
CMAKE_Fortran_COMPILER_IDsince the Intel spellings (-check,-init=) aren't recognized by gfortran.RELEASE(and the unknown-build-type fallback) are unchanged.Trade-off
These diagnostics cost wall-clock time - bounds checking in particular adds real per-access overhead in hot loops, on top of the much larger cost of dropping to
-O0. That's expected and acceptable for a debug build;-fpe0/-ffpe-trapand the NaN-init are effectively free (one-time trap-mask/init cost, not per-operation).