From 0ca9712acab6a63f3105e229ce19c7f39ba43d50 Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Mon, 18 Nov 2024 22:30:26 -0500 Subject: [PATCH] Add new cmake variable UFS_COMPILER_SUITE to support mixed Intel compilers (icx, icpx, ifort) --- CMakeLists.txt | 14 +++++++++- cmake/Intel.cmake | 1 - cmake/IntelMixed.cmake | 61 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 cmake/IntelMixed.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 702cf6a459..236a57b651 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -140,7 +140,19 @@ else() set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Set type of build to Release." FORCE) endif() -include(cmake/${CMAKE_Fortran_COMPILER_ID}.cmake) +if (CMAKE_C_COMPILER_ID MATCHES "IntelLLVM" AND CMAKE_Fortran_COMPILER_ID MATCHES "IntelLLVM") + set(UFS_COMPILER_SUITE "IntelLLVM") +elseif (CMAKE_C_COMPILER_ID MATCHES "IntelLLVM" AND CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + set(UFS_COMPILER_SUITE "IntelMixed") +elseif (CMAKE_C_COMPILER_ID MATCHES "Intel" AND CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + set(UFS_COMPILER_SUITE "Intel") +elseif (CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + set(UFS_COMPILER_SUITE "GNU") +else() + message(FATAL_ERROR "C compiler ${CMAKE_C_COMPILER_ID} + Fortran compiler ${CMAKE_Fortran_COMPILER_ID} not supported") +endif() +message("UFS COMPILER SUITE: ${UFS_COMPILER_SUITE}") +include(cmake/${UFS_COMPILER_SUITE}.cmake) ############################################################################### ### Find Dependencies diff --git a/cmake/Intel.cmake b/cmake/Intel.cmake index 6b8cae0ef6..c203abfb64 100644 --- a/cmake/Intel.cmake +++ b/cmake/Intel.cmake @@ -20,7 +20,6 @@ endif() if(DEBUG) add_definitions(-DDEBUG) - #set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -O0 -check -check noarg_temp_created -check nopointer -warn -warn noerrors -fp-stack-check -fstack-protector-all -fpe0 -debug -ftrapuv -init=snan,arrays") set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -O0 -check -check noarg_temp_created -warn -warn noerrors -fp-stack-check -fstack-protector-all -fpe0 -debug -ftrapuv -init=snan,arrays") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -ftrapuv") else() diff --git a/cmake/IntelMixed.cmake b/cmake/IntelMixed.cmake new file mode 100644 index 0000000000..3369c17994 --- /dev/null +++ b/cmake/IntelMixed.cmake @@ -0,0 +1,61 @@ +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -traceback -fpp -fno-alias -auto -safe-cray-ptr -ftz -assume byterecl -sox -align array64byte -qno-opt-dynamic-align") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qno-opt-dynamic-align -fp-model precise") + +# warning #5462: Global name too long. +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -diag-disable 5462") + +# remark #7712: This variable has not been used. +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -diag-disable 7712") + +# remark #8291: Recommended relationship between field width 'W' and the number of fractional digits 'D' in this edit descriptor is 'W>=D+7'. +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -diag-disable 8291") + +#DH MAKE THIS THE DEPRECATION WARNING SUPPRESSOR # warning #5194: Source line truncated. +#set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -diag-disable 5194") + +if(CMAKE_Platform STREQUAL "derecho.intel") + set(CMAKE_Fortran_LINK_FLAGS "-Wl,--copy-dt-needed-entries") +endif() + +if(NOT 32BIT) + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -real-size 64") +endif() + +if(DEBUG) + add_definitions(-DDEBUG) + set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -O0 -check -check noarg_temp_created -warn -warn noerrors -fp-stack-check -fstack-protector-all -fpe0 -debug -ftrapuv -init=snan,arrays") + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -ftrapuv") +else() + if(FASTER) + set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fp-model precise -assume buffered_stdout -fno-alias -align all -debug minimal -qoverride-limits -ftz -no-ip") + set(CMAKE_C_FLAGS_RELEASE "-O3 -fp-model precise -debug minimal -qoverride-limits -ftz") + else() + set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -debug minimal -qoverride-limits") + set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -fp-model consistent") + set(CMAKE_C_FLAGS_RELEASE "-O2 -debug minimal") + set(FAST "-fast-transcendentals") + endif() + if(AVX2) + set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -march=core-avx2") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -march=core-avx2") + elseif(SIMDMULTIARCH) + set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -axSSE4.2,CORE-AVX2") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -axSSE4.2,CORE-AVX2") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mcmodel=medium") + elseif(AVX) + set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -march=core-avx-i") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -march=core-avx-i") + endif() +endif() + +if(APPLE) + # The linker on macOS does not include `common symbols` by default + # Passing the -c flag includes them and fixes an error with undefined symbols + set(CMAKE_Fortran_ARCHIVE_FINISH " -c ") +endif() + +# This must be last, to override all other optimization settings. +if(DISABLE_FMA) + set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -no-fma") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -no-fma") +endif()