-
Notifications
You must be signed in to change notification settings - Fork 134
Speed up gfortran debug CI builds #1339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b04a194
9ebb180
186cf73
a8a9845
c961888
36249ac
7b15fae
c0249a2
e65d1b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,18 @@ if (MFC_ALL) | |
| set(MFC_DOCUMENTATION ON FORCE) | ||
| endif() | ||
|
|
||
| # Validate CMAKE_BUILD_TYPE to catch typos (CMake is case-sensitive). | ||
| set(_VALID_BUILD_TYPES "Debug" "Release" "RelDebug" "") | ||
| if (NOT CMAKE_BUILD_TYPE IN_LIST _VALID_BUILD_TYPES) | ||
| message(FATAL_ERROR "Unknown CMAKE_BUILD_TYPE '${CMAKE_BUILD_TYPE}'. Valid: Debug, RelDebug, Release") | ||
| endif() | ||
|
|
||
| # RelDebug: a lighter debug mode for CI. Compiler-specific blocks below add the | ||
| # actual flags; these defaults just tell CMake it is a recognised build type. | ||
| set(CMAKE_C_FLAGS_RELDEBUG "-g" CACHE STRING "") | ||
| set(CMAKE_CXX_FLAGS_RELDEBUG "-g" CACHE STRING "") | ||
| set(CMAKE_Fortran_FLAGS_RELDEBUG "-g" CACHE STRING "") | ||
|
|
||
| if (MFC_SINGLE_PRECISION) | ||
| add_compile_definitions(MFC_SINGLE_PRECISION) | ||
| else() | ||
|
|
@@ -83,7 +95,7 @@ elseif ((CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC") OR (CMAKE_Fortran_COMPILER_ | |
| message(FATAL_ERROR "ERROR: When using NVHPC, v21.7 or newer is required to build MFC.\n${__err_msg}") | ||
| endif() | ||
|
|
||
| if ((CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 24.5) AND (CMAKE_BUILD_TYPE STREQUAL "Debug") AND MFC_OpenACC) | ||
| if ((CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 24.5) AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelDebug") AND MFC_OpenACC) | ||
| message(FATAL_ERROR "ERROR: When using NVHPC, MFC with Debug and GPU options requires NVHPC v24.5 or newer.\n${__err_msg}") | ||
| endif() | ||
| elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang") | ||
|
|
@@ -165,13 +177,29 @@ if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") | |
| -Wrealloc-lhs | ||
| -Wsurprising | ||
| ) | ||
| elseif (CMAKE_BUILD_TYPE STREQUAL "RelDebug") | ||
| add_compile_options( | ||
| -Og | ||
| -Wall | ||
| -Wextra | ||
| -fcheck=bounds,pointer | ||
| -fbacktrace | ||
| -fimplicit-none | ||
| -fsignaling-nans | ||
| -finit-real=snan | ||
| -finit-integer=-99999999 | ||
| -Wconversion | ||
| -Wintrinsic-shadow | ||
| -Wunderflow | ||
| -Wrealloc-lhs | ||
| -Wsurprising | ||
| ) | ||
| endif() | ||
|
|
||
| if (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER 10) | ||
| add_compile_options( | ||
| $<$<COMPILE_LANGUAGE:Fortran>:-fallow-invalid-boz> | ||
| $<$<COMPILE_LANGUAGE:Fortran>:-fallow-argument-mismatch> | ||
| $<$<COMPILE_LANGUAGE:Fortran>:-fcheck=bounds> | ||
| ) | ||
| endif() | ||
| elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Cray") | ||
|
|
@@ -193,6 +221,13 @@ elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Cray") | |
| "SHELL: -K trap=fp" "SHELL: -g" "SHELL: -O0" | ||
| ) | ||
| add_link_options("SHELL: -K trap=fp" "SHELL: -g" "SHELL: -O0") | ||
| elseif (CMAKE_BUILD_TYPE STREQUAL "RelDebug") | ||
| add_compile_options( | ||
| "SHELL:-h acc_model=auto_async_none" | ||
| "SHELL: -h acc_model=no_fast_addr" | ||
| "SHELL: -K trap=fp" "SHELL: -g" "SHELL: -O1" | ||
| ) | ||
| add_link_options("SHELL: -K trap=fp" "SHELL: -g" "SHELL: -O1") | ||
| endif() | ||
|
|
||
| elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Flang") | ||
|
|
@@ -201,11 +236,17 @@ elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Flang") | |
| $<$<COMPILE_LANGUAGE:Fortran>:-Mpreprocess> | ||
| $<$<COMPILE_LANGUAGE:Fortran>:-fdefault-real-8> | ||
| ) | ||
|
|
||
| if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelDebug") | ||
| add_compile_options($<$<COMPILE_LANGUAGE:Fortran>:-O1> $<$<COMPILE_LANGUAGE:Fortran>:-g>) | ||
| endif() | ||
| elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") | ||
| add_compile_options($<$<COMPILE_LANGUAGE:Fortran>:-free>) | ||
|
|
||
| if (CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
| add_compile_options(-g -Og -traceback -debug) | ||
| add_compile_options(-g -Og -traceback -debug -check all) | ||
| elseif (CMAKE_BUILD_TYPE STREQUAL "RelDebug") | ||
| add_compile_options(-g -Og -traceback -check bounds) | ||
|
Comment on lines
246
to
+249
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: For Intel oneAPI ifx (LLVM-based Fortran compiler), CMake sets:
Sources: CMake Discourse example output showing “Fortran Compiler ID: IntelLLVM” when using 🏁 Script executed: # Find and read the CMakeLists.txt file around lines 236-239 with full context
fd CMakeLists.txt | head -1 | xargs -I {} sh -c 'wc -l {} && echo "---" && head -n 260 {} | tail -n 50'Repository: MFlowCode/MFC Length of output: 2069 🏁 Script executed: fd CMakeLists.txt | head -1 | xargs -I {} sh -c 'grep -n "CMAKE_Fortran_COMPILER_ID\|IntelLLVM\|Intel" {} | head -20'Repository: MFlowCode/MFC Length of output: 1532 🏁 Script executed: fd CMakeLists.txt | head -1 | xargs -I {} sh -c 'sed -n "130,320p" {} | cat -n'Repository: MFlowCode/MFC Length of output: 9152 🏁 Script executed: cd . && git log --oneline -1 2>/dev/null || echo "Not a git repo or git not available"
git diff HEAD -- CMakeLists.txt 2>/dev/null | grep -A 5 -B 5 "CMAKE_BUILD_TYPE.*RelDebug" | head -30 || echo "No git diff available"Repository: MFlowCode/MFC Length of output: 157 🏁 Script executed: cd . && git show HEAD --stat | head -20Repository: MFlowCode/MFC Length of output: 1160 🏁 Script executed: fd . -name "*.md" | xargs grep -l "ifx\|IntelLLVM\|oneAPI" 2>/dev/null | head -5Repository: MFlowCode/MFC Length of output: 287 🏁 Script executed: fd ".*\.md$" | xargs grep -l "ifx\|IntelLLVM\|oneAPI" 2>/dev/nullRepository: MFlowCode/MFC Length of output: 187 🏁 Script executed: git show HEAD:CMakeLists.txt | grep -A 10 'CMAKE_Fortran_COMPILER_ID STREQUAL "Intel"'Repository: MFlowCode/MFC Length of output: 1349 The Intel conditional block needs to handle CMake identifies Intel oneAPI's ifx compiler as |
||
| endif() | ||
| elseif ((CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC") OR (CMAKE_Fortran_COMPILER_ID STREQUAL "PGI")) | ||
| add_compile_options( | ||
|
|
@@ -224,6 +265,13 @@ elseif ((CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC") OR (CMAKE_Fortran_COMPILER_ | |
| $<$<COMPILE_LANGUAGE:Fortran>:-Minform=inform> | ||
| $<$<COMPILE_LANGUAGE:Fortran>:-Mbounds> | ||
| ) | ||
| elseif (CMAKE_BUILD_TYPE STREQUAL "RelDebug") | ||
| add_compile_options( | ||
| $<$<COMPILE_LANGUAGE:Fortran>:-O1> | ||
| $<$<COMPILE_LANGUAGE:Fortran>:-g> | ||
| $<$<COMPILE_LANGUAGE:Fortran>:-traceback> | ||
| $<$<COMPILE_LANGUAGE:Fortran>:-Mbounds> | ||
| ) | ||
| endif() | ||
|
|
||
| if (DEFINED ENV{MFC_CUDA_CC}) | ||
|
|
@@ -282,7 +330,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Release") | |
| endif() | ||
| endif() | ||
|
|
||
| if (CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
| if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelDebug") | ||
| add_compile_definitions(MFC_DEBUG) | ||
| endif() | ||
|
|
||
|
|
@@ -596,7 +644,7 @@ function(MFC_SETUP_TARGET) | |
| ) | ||
| endif() | ||
|
|
||
| if (CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
| if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelDebug") | ||
| target_compile_options(${a_target} | ||
| PRIVATE -gpu=debug | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ class MFCConfig: | |
| mpi: bool = True | ||
| gpu: str = gpuConfigOptions.NONE.value | ||
| debug: bool = False | ||
| reldebug: bool = False | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normalize Because config is remembered across commands, Also applies to: 47-63 |
||
| gcov: bool = False | ||
| unified: bool = False | ||
| single: bool = False | ||
|
|
@@ -43,21 +44,23 @@ def make_options(self) -> typing.List[str]: | |
| Example: --no-debug --mpi --no-gpu --no-gcov --no-unified""" | ||
| options = [] | ||
| for k, v in self.items(): | ||
| cli_k = k.replace("_", "-") | ||
| if k == "gpu": | ||
| options.append(f"--{v}-{k}") | ||
| options.append(f"--{v}-{cli_k}") | ||
| else: | ||
| options.append(f"--{'no-' if not v else ''}{k}") | ||
| options.append(f"--{'no-' if not v else ''}{cli_k}") | ||
| return options | ||
|
|
||
| def make_slug(self) -> str: | ||
| """Sort the items by key, then join them with underscores. This uniquely | ||
| identifies the configuration. Example: no-debug_no-gpu_no_mpi_no-gcov""" | ||
| options = [] | ||
| for k, v in sorted(self.items(), key=lambda x: x[0]): | ||
| cli_k = k.replace("_", "-") | ||
| if k == "gpu": | ||
| options.append(f"--{v}-{k}") | ||
| options.append(f"--{v}-{cli_k}") | ||
| else: | ||
| options.append(f"--{'no-' if not v else ''}{k}") | ||
| options.append(f"--{'no-' if not v else ''}{cli_k}") | ||
| return "_".join(options) | ||
|
|
||
| def __eq__(self, other) -> bool: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: MFlowCode/MFC
Length of output: 3934
🏁 Script executed:
Repository: MFlowCode/MFC
Length of output: 109
🏁 Script executed:
Repository: MFlowCode/MFC
Length of output: 2591
🏁 Script executed:
Repository: MFlowCode/MFC
Length of output: 115
🏁 Script executed:
Repository: MFlowCode/MFC
Length of output: 4991
Verify
RelDebugsupport on multi-config generators and add Intel oneAPI compiler ID.Multi-config generators (Visual Studio, Xcode) will fail to use the custom
RelDebugflags:CMAKE_BUILD_TYPEis empty on multi-config generators, so theif(CMAKE_BUILD_TYPE STREQUAL "RelDebug")conditionals throughout the file will not fire (lines 240, 248, 259, 268, 333, 647)CMAKE_CONFIGURATION_TYPESis never set, soRelDebugis not registered as a valid configurationcmake --build --config RelDebugwill use default flags instead of the custom ones, or failThe code sets
CMAKE_BUILD_TYPE(single-config only) but later passes--config(multi-config syntax) to the build command, suggesting both patterns were intended but not properly reconciled.Additionally, the Intel Fortran block (line 243) only checks for
CMAKE_Fortran_COMPILER_ID STREQUAL "Intel"but does not handleIntelLLVM, which is what Intel oneAPI (ifx) reports. If oneAPI is installed, the compiler ID will not match and flags will not be applied.Suggested fixes:
CMAKE_CONFIGURATION_TYPESregistration for multi-config generators and use generator expressions instead ofCMAKE_BUILD_TYPEconditionals, orIntelLLVM: