Skip to content

Commit 6230626

Browse files
committed
Detect and set UFS_COMPILER_SUITE in cmake/detect_compiler_suite.cmake to support cmake/IntelMixed.cmake
1 parent 9c754c7 commit 6230626

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ else()
141141
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Set type of build to Release." FORCE)
142142
endif()
143143

144-
include(cmake/${CMAKE_Fortran_COMPILER_ID}.cmake)
144+
# Detect and set UFS_COMPILER_SUITE in detect_compiler_suite.cmake
145+
set(UFS_COMPILER_SUITE)
146+
include(cmake/detect_compiler_suite.cmake)
147+
include(cmake/${UFS_COMPILER_SUITE}.cmake)
145148

146149
###############################################################################
147150
### Find Dependencies

cmake/IntelMixed.cmake

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -traceback -fpp -fno-alias -auto -safe-cray-ptr -ftz -assume byterecl -align array64byte -qno-opt-dynamic-align")
2+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qno-opt-dynamic-align -fp-model precise")
3+
4+
# warning #5462: Global name too long.
5+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -diag-disable 5462")
6+
7+
# remark #7712: This variable has not been used.
8+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -diag-disable 7712")
9+
10+
# remark #8291: Recommended relationship between field width 'W' and the number of fractional digits 'D' in this edit descriptor is 'W>=D+7'.
11+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -diag-disable 8291")
12+
13+
if(CMAKE_Platform STREQUAL "derecho.intel")
14+
set(CMAKE_Fortran_LINK_FLAGS "-Wl,--copy-dt-needed-entries")
15+
endif()
16+
17+
if(NOT 32BIT)
18+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -real-size 64")
19+
endif()
20+
21+
if(DEBUG)
22+
add_definitions(-DDEBUG)
23+
#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")
24+
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")
25+
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -ftrapuv")
26+
else()
27+
if(FASTER)
28+
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -fp-model precise -assume buffered_stdout -fno-alias -align all -debug minimal -qoverride-limits -ftz -no-ip")
29+
set(CMAKE_C_FLAGS_RELEASE "-O3 -fp-model precise -debug minimal -qoverride-limits -ftz")
30+
else()
31+
set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -debug minimal -qoverride-limits")
32+
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -fp-model consistent")
33+
set(CMAKE_C_FLAGS_RELEASE "-O2 -debug minimal")
34+
set(FAST "-fast-transcendentals")
35+
endif()
36+
if(AVX2)
37+
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -march=core-avx2")
38+
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -march=core-avx2")
39+
elseif(SIMDMULTIARCH)
40+
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -axSSE4.2,CORE-AVX2")
41+
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -axSSE4.2,CORE-AVX2")
42+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mcmodel=medium")
43+
elseif(AVX)
44+
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -march=core-avx-i")
45+
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -march=core-avx-i")
46+
endif()
47+
endif()
48+
49+
if(APPLE)
50+
# The linker on macOS does not include `common symbols` by default
51+
# Passing the -c flag includes them and fixes an error with undefined symbols
52+
set(CMAKE_Fortran_ARCHIVE_FINISH "<CMAKE_RANLIB> -c <TARGET>")
53+
endif()
54+
55+
# This must be last, to override all other optimization settings.
56+
if(DISABLE_FMA)
57+
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -no-fma")
58+
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -no-fma")
59+
endif()

cmake/detect_compiler_suite.cmake

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Detect UFS compiler suite and set at parent scope
2+
3+
if(CMAKE_C_COMPILER_ID STREQUAL "Intel" AND
4+
CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND
5+
CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
6+
set(UFS_COMPILER_SUITE "Intel")
7+
elseif(CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM" AND
8+
CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM" AND
9+
CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
10+
set(UFS_COMPILER_SUITE "IntelMixed")
11+
elseif(CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM" AND
12+
CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM" AND
13+
CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM")
14+
set(UFS_COMPILER_SUITE "IntelLLVM")
15+
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND
16+
CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND
17+
CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
18+
set(UFS_COMPILER_SUITE "GNU")
19+
else()
20+
message(FATAL_ERROR "Unsupported combination of compilers (CC/CXX/FC): "
21+
"${CMAKE_C_COMPILER_ID}/${CMAKE_CXX_COMPILER_ID}/${CMAKE_Fortran_COMPILER_ID}")
22+
endif()
23+
24+
message(STATUS "UFS Compiler Suite: ${UFS_COMPILER_SUITE}")

0 commit comments

Comments
 (0)