From 34a9dc3ade49f6a681e5e29336efbc89063ef630 Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Mon, 6 Jun 2022 15:56:35 -0500 Subject: [PATCH 1/4] Allow disabling variable tracking via CMake to improve compile time --- CMakeLists.txt | 1 + glue-codes/fast-farm/CMakeLists.txt | 7 ++++--- glue-codes/openfast/CMakeLists.txt | 8 ++++---- modules/openfast-library/CMakeLists.txt | 7 ++++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 36f0a0ecc3..34b69e6d63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ if (NOT CMAKE_BUILD_TYPE) "Choose the build type: Debug Release" FORCE) endif (NOT CMAKE_BUILD_TYPE) +option(VARIABLE_TRACKING "Enables variable tracking for better runtime debugging output. May increase compile time. Valid only for GNU." on) option(GENERATE_TYPES "Use the openfast-regsitry to autogenerate types modules" off) option(BUILD_SHARED_LIBS "Enable building shared libraries" off) option(DOUBLE_PRECISION "Treat REAL as double precision" on) diff --git a/glue-codes/fast-farm/CMakeLists.txt b/glue-codes/fast-farm/CMakeLists.txt index 40507fc30c..7360f244a7 100644 --- a/glue-codes/fast-farm/CMakeLists.txt +++ b/glue-codes/fast-farm/CMakeLists.txt @@ -44,10 +44,11 @@ set_property(TARGET FAST.Farm PROPERTY LINKER_LANGUAGE Fortran) string(TOUPPER ${CMAKE_Fortran_COMPILER_ID} _compiler_id) string(TOUPPER ${CMAKE_BUILD_TYPE} _build_type) -if (${_compiler_id} STREQUAL "GNU" AND ${_build_type} STREQUAL "RELEASE") +if (${_compiler_id} STREQUAL "GNU" AND NOT ${VARIABLE_TRACKING}) # With variable tracking enabled, the compile step frequently aborts on large modules and - # restarts with this option off. Disabling in Release mode avoids this problem when compiling with - # full optimizations, but leaves it enabled for RelWithDebInfo which adds both -O2 and -g flags. + # restarts with this option off. Disabling avoids this problem when compiling with + # full optimizations. However, variable tracking should be enabled when actively debugging + # for better runtime debugging output. # https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html set_source_files_properties(src/FAST_Farm_Types.f90 src/FASTWrapper_Types.f90 PROPERTIES COMPILE_FLAGS "-fno-var-tracking -fno-var-tracking-assignments") endif() diff --git a/glue-codes/openfast/CMakeLists.txt b/glue-codes/openfast/CMakeLists.txt index b6de649e29..5fe7c78227 100644 --- a/glue-codes/openfast/CMakeLists.txt +++ b/glue-codes/openfast/CMakeLists.txt @@ -27,11 +27,11 @@ add_executable(openfast_cpp src/FAST_Prog.cpp src/FastLibAPI.cpp) target_link_libraries(openfast_cpp openfastlib) string(TOUPPER ${CMAKE_Fortran_COMPILER_ID} _compiler_id) -string(TOUPPER ${CMAKE_BUILD_TYPE} _build_type) -if (${_compiler_id} STREQUAL "GNU" AND ${_build_type} STREQUAL "RELEASE") +if (${_compiler_id} STREQUAL "GNU" AND NOT ${VARIABLE_TRACKING}) # With variable tracking enabled, the compile step frequently aborts on large modules and - # restarts with this option off. Disabling in Release mode avoids this problem when compiling with - # full optimizations, but leaves it enabled for RelWithDebInfo which adds both -O2 and -g flags. + # restarts with this option off. Disabling avoids this problem when compiling with + # full optimizations. However, variable tracking should be enabled when actively debugging + # for better runtime debugging output. # https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html set_source_files_properties(src/FAST_Prog.f90 PROPERTIES COMPILE_FLAGS "-fno-var-tracking -fno-var-tracking-assignments") endif() diff --git a/modules/openfast-library/CMakeLists.txt b/modules/openfast-library/CMakeLists.txt index 1a54ec8ab4..f6496a8cb1 100644 --- a/modules/openfast-library/CMakeLists.txt +++ b/modules/openfast-library/CMakeLists.txt @@ -58,10 +58,11 @@ target_link_libraries(openfastlib openfast_postlib openfast_prelib scdataexlib f string(TOUPPER ${CMAKE_Fortran_COMPILER_ID} _compiler_id) string(TOUPPER ${CMAKE_BUILD_TYPE} _build_type) -if (${_compiler_id} STREQUAL "GNU" AND ${_build_type} STREQUAL "RELEASE") +if (${_compiler_id} STREQUAL "GNU" AND NOT ${VARIABLE_TRACKING}) # With variable tracking enabled, the compile step frequently aborts on large modules and - # restarts with this option off. Disabling in Release mode avoids this problem when compiling with - # full optimizations, but leaves it enabled for RelWithDebInfo which adds both -O2 and -g flags. + # restarts with this option off. Disabling avoids this problem when compiling with + # full optimizations. However, variable tracking should be enabled when actively debugging + # for better runtime debugging output. # https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html set_source_files_properties( src/FAST_Subs.f90 src/FAST_Types.f90 src/FAST_Library.f90 From 441a45e3388e004d4956017deb72dd1ec50d2f24 Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Mon, 6 Jun 2022 16:53:04 -0500 Subject: [PATCH 2/4] Disable variable tracking in GH Actions Improves compile time --- .github/workflows/automated-dev-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/automated-dev-tests.yml b/.github/workflows/automated-dev-tests.yml index a04fc80a2c..fd63edb92c 100644 --- a/.github/workflows/automated-dev-tests.yml +++ b/.github/workflows/automated-dev-tests.yml @@ -103,6 +103,7 @@ jobs: -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \ -DBUILD_TESTING:BOOL=ON \ -DCTEST_PLOT_ERRORS:BOOL=ON \ + -DVARIABLE_TRACKING=OFF \ ${GITHUB_WORKSPACE} - name: Build OpenFAST # if: contains(github.event.head_commit.message, 'Action - Test All') || contains(github.event.pull_request.labels.*.name, 'Action - Test All') @@ -275,6 +276,7 @@ jobs: -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \ -DBUILD_TESTING:BOOL=ON \ -DCTEST_PLOT_ERRORS:BOOL=ON \ + -DVARIABLE_TRACKING=OFF \ ${GITHUB_WORKSPACE} - name: Build FAST.Farm # if: contains(github.event.head_commit.message, 'Action - Test All') || contains(github.event.pull_request.labels.*.name, 'Action - Test All') @@ -447,6 +449,7 @@ jobs: -DBUILD_SHARED_LIBS:BOOL=ON \ -DBUILD_TESTING:BOOL=ON \ -DCTEST_PLOT_ERRORS:BOOL=ON \ + -DVARIABLE_TRACKING=OFF \ ${GITHUB_WORKSPACE} - name: Build OpenFAST C-Interfaces From 5d9c7b7f1f6e8ff9722a82bfa39e57a00d96fb4e Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Fri, 10 Jun 2022 15:37:54 -0500 Subject: [PATCH 3/4] Disable variable tracking for FAST Farm wrapper --- glue-codes/fast-farm/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glue-codes/fast-farm/CMakeLists.txt b/glue-codes/fast-farm/CMakeLists.txt index 7360f244a7..f404db7fab 100644 --- a/glue-codes/fast-farm/CMakeLists.txt +++ b/glue-codes/fast-farm/CMakeLists.txt @@ -50,7 +50,7 @@ if (${_compiler_id} STREQUAL "GNU" AND NOT ${VARIABLE_TRACKING}) # full optimizations. However, variable tracking should be enabled when actively debugging # for better runtime debugging output. # https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html - set_source_files_properties(src/FAST_Farm_Types.f90 src/FASTWrapper_Types.f90 PROPERTIES COMPILE_FLAGS "-fno-var-tracking -fno-var-tracking-assignments") + set_source_files_properties(src/FAST_Farm_Types.f90 src/FASTWrapper_Types.f90 src/FASTWrapper.f90 PROPERTIES COMPILE_FLAGS "-fno-var-tracking -fno-var-tracking-assignments") endif() if (${_compiler_id} MATCHES "^INTEL" AND ${_build_type} STREQUAL "RELEASE" AND NOT WIN32) # Compilation hangs on FAST_Farm_Types.f90 with -O3 on linux (on some hardware) From 730f322124db8d4f9aed6570b979bb1328ec4719 Mon Sep 17 00:00:00 2001 From: Rafael M Mudafort Date: Thu, 28 Jul 2022 17:54:23 -0500 Subject: [PATCH 4/4] Add a CMake warning when variable tracking is off but debug is on --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34b69e6d63..9d1d3dd61a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,12 @@ if(APPLE) option(CMAKE_MACOSX_RPATH "Use RPATH runtime linking" on) endif() +# Warn if atypical configuration for variable tracking and build type +string(TOUPPER ${CMAKE_BUILD_TYPE} _build_type) +if(NOT ${VARIABLE_TRACKING} AND (${_build_type} STREQUAL "DEBUG" OR ${_build_type} STREQUAL "RELWITHDEBINFO") ) + message(WARNING "Variable tracking is disabled and build type includes debug symbols. This may reduce the ability to debug.") +endif() + # Precompiler/preprocessor flag configuration # Do this before configuring modules so that the flags are included option(BUILD_TESTING "Build the testing tree." OFF)