-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeListsMachine.txt
241 lines (222 loc) · 12.2 KB
/
CMakeListsMachine.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# =========================================================================
# Detect machine environments
# =========================================================================
CMAKE_HOST_SYSTEM_INFORMATION(RESULT CMAKE_FQDN_HOST QUERY FQDN)
MARK_AS_ADVANCED(FORCE CMAKE_FQDN_HOST)
MARK_AS_ADVANCED(FORCE CMAKE_HOSTNAME)
SITE_NAME(CMAKE_HOSTNAME)
# =========================================================================
# CMake generator settings
# =========================================================================
SET(USED_CMAKE_GENERATOR "${CMAKE_GENERATOR}" CACHE STRING "Expose CMAKE_GENERATOR (cannot be changed here)" FORCE)
MESSAGE(STATUS "Using cmake generator: ${CMAKE_GENERATOR}")
IF("${CMAKE_GENERATOR}" MATCHES "Ninja")
# CMake introduced the CMAKE_COLOR_DIAGNOSTICS flag with 3.24.0, https://gitlab.kitware.com/cmake/cmake/-/merge_requests/6990
IF(NOT(${CMAKE_VERSION} VERSION_LESS "3.24.0"))
SET(CMAKE_COLOR_DIAGNOSTICS ON CACHE INTERNAL "Flag if CMake should attempt to color output")
ELSE()
SET(NINJA_COLOR_DIAGNOSTICS "-fdiagnostics-color=always" CACHE INTERNAL "Flag if Ninja should attempt to color output")
ENDIF()
ENDIF()
# =========================================================================
# Some clusters requires setting the compilers by hand and invoking
# ENABLE_LANGUAGE afterwards, which is required for
# CMAKE_Fortran_COMPILER_ID that is used below
# > This block must be called before ENABLE_LANGUAGE
# =========================================================================
# HLRS HAWK / SuperMUC
IF ("${CMAKE_HOSTNAME}" MATCHES "login")
SET(CMAKE_C_COMPILER mpicc)
SET(CMAKE_CXX_COMPILER mpicxx)
SET(CMAKE_Fortran_COMPILER mpif90) # mpif08 wrapper seems to have issue
# IAG Prandtl
ELSEIF("${CMAKE_HOSTNAME}" MATCHES "^prandtl")
SET(CMAKE_C_COMPILER gcc)
SET(CMAKE_CXX_COMPILER c++)
SET(CMAKE_Fortran_COMPILER gfortran)
# IAG Grafik01/Grafik02
ELSEIF ("${CMAKE_HOSTNAME}" MATCHES "^grafik0")
SET(CMAKE_C_COMPILER gcc)
SET(CMAKE_CXX_COMPILER c++)
SET(CMAKE_Fortran_COMPILER gfortran)
ELSEIF ("${CMAKE_HOSTNAME}" MATCHES "^ilahead1")
SET(CMAKE_C_COMPILER mpicc)
SET(CMAKE_CXX_COMPILER mpicxx)
SET(CMAKE_Fortran_COMPILER mpif90) # mpif08 wrapper seems to have issue
ELSEIF ("${CMAKE_HOSTNAME}" MATCHES "^xenon")
SET(CMAKE_C_COMPILER mpicc)
SET(CMAKE_CXX_COMPILER mpicxx)
SET(CMAKE_Fortran_COMPILER mpif90) # mpif08 wrapper seems to have issue
ENDIF()
# =========================================================================
# After settings specific compilers, enable named languages for cmake
# =========================================================================
ENABLE_LANGUAGE(Fortran C)
INCLUDE(GNUInstallDirs)
# =========================================================================
# Set machine-specific definitions and settings
# =========================================================================
# Revert to default via -DHOPR_INSTRUCTION= once this value has been changed via, e.g., -DHOPR_INSTRUCTION=-mtune=generic
IF(NOT DEFINED HOPR_INSTRUCTION)
SET(HOPR_INSTRUCTION "")
ENDIF()
# HLRS HAWK / SuperMUC
IF("${HOPR_INSTRUCTION}" STREQUAL "")
IF ("${CMAKE_HOSTNAME}" MATCHES "login")
MARK_AS_ADVANCED(FORCE C_PATH CXX_PATH Fortran_PATH)
# HAWK and SuperMUC name their login nodes identically, so use the Fully Qualified Domain Name (FQDN) to identify
CMAKE_HOST_SYSTEM_INFORMATION(RESULT FQDN QUERY FQDN)
MARK_AS_ADVANCED(FORCE FQDN)
# HLRS HAWK
IF (FQDN MATCHES "hawk.hww.hlrs.de")
MESSAGE(STATUS "Compiling on Hawk")
# Overwrite compiler target architecture
IF (CMAKE_Fortran_COMPILER_ID MATCHES "GNU" OR CMAKE_Fortran_COMPILER_ID MATCHES "Flang")
SET(HOPR_INSTRUCTION "-march=znver2")
ELSEIF (CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
SET(HOPR_INSTRUCTION "-xCORE-AVX2")
ENDIF()
# Use AMD Optimized Lapack/BLAS
# SET(BLA_VENDOR "FLAME")
# SuperMUC
ELSEIF (FQDN MATCHES "sng.lrz.de")
MESSAGE(STATUS "Compiling on SuperMUC")
# Overwrite compiler target architecture
IF (CMAKE_Fortran_COMPILER_ID MATCHES "GNU" OR CMAKE_Fortran_COMPILER_ID MATCHES "Flang")
SET(HOPR_INSTRUCTION "-march=skylake-avx512")
ELSEIF (CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
SET(HOPR_INSTRUCTION "-xSKYLAKE-AVX512")
# Explicitely enable usage of AVX512 registers
SET (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qopt-zmm-usage=high")
ENDIF()
ENDIF()
# IAG Prandtl
ELSEIF("${CMAKE_HOSTNAME}" MATCHES "^prandtl")
MESSAGE(STATUS "Compiling on Prandtl")
MARK_AS_ADVANCED(FORCE C_PATH CXX_PATH Fortran_PATH)
SET(HOPR_INSTRUCTION "-march=native")
# IAG Grafik01/Grafik02
ELSEIF ("${CMAKE_HOSTNAME}" MATCHES "^grafik0")
MESSAGE(STATUS "Compiling on ${CMAKE_HOSTNAME}")
MARK_AS_ADVANCED(FORCE C_PATH CXX_PATH Fortran_PATH)
SET(HOPR_INSTRUCTION "-march=native")
ELSEIF ("${CMAKE_HOSTNAME}" MATCHES "^ilahead1")
MESSAGE(STATUS "Compiling on ILA cluster")
MARK_AS_ADVANCED(FORCE C_PATH CXX_PATH Fortran_PATH)
# Overwrite compiler target architecture
IF (CMAKE_Fortran_COMPILER_ID MATCHES "GNU" OR CMAKE_Fortran_COMPILER_ID MATCHES "Flang")
SET(HOPR_INSTRUCTION "-march=core-avx2")
ELSEIF (CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
SET(HOPR_INSTRUCTION "-xCORE-AVX2")
ENDIF()
ELSEIF ("${CMAKE_HOSTNAME}" MATCHES "^xenon")
MESSAGE(STATUS "Compiling on ILA student cluster")
MARK_AS_ADVANCED(FORCE C_PATH CXX_PATH Fortran_PATH)
SET(HOPR_INSTRUCTION "-march=native")
ELSE()
MESSAGE(STATUS "Compiling on a generic machine")
# Set compiler target architecture
IF (CMAKE_Fortran_COMPILER_ID MATCHES "GNU" OR CMAKE_Fortran_COMPILER_ID MATCHES "Flang" )
SET(HOPR_INSTRUCTION "-march=native")
ELSEIF (CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
SET(HOPR_INSTRUCTION "-xHost")
ENDIF()
ENDIF()
ENDIF()
MESSAGE(STATUS "Compiling Release/Profile with [${CMAKE_Fortran_COMPILER_ID}] (v${CMAKE_Fortran_COMPILER_VERSION}) fortran compiler using HOPR_INSTRUCTION [${HOPR_INSTRUCTION}] instructions.")
# =========================================================================
# COMPILER FLAGS
# =========================================================================
# FFLAGS depend on the compiler
GET_FILENAME_COMPONENT (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
# GNU Compiler Collection (GCC)
IF (CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
# set Flags (disable lto type warnings due to false positives with MATMUL, which is a known bug)
IF (NOT DEFINED C_FLAGS_INITIALIZED )
SET (C_FLAGS_INITIALIZED "yes" CACHE INTERNAL "Flag if compiler flags are already initialized" )
SET (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8 -fdefault-double-8 -fbackslash -ffree-line-length-0 -finit-real=snan -finit-integer=snan -Wno-lto-type-mismatch -DGNU")
ENDIF()
SET (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS} -O3 ${HOPR_INSTRUCTION} -finline-functions -fstack-arrays")
SET (CMAKE_Fortran_FLAGS_PROFILE "${CMAKE_Fortran_FLAGS} -pg -O3 ${HOPR_INSTRUCTION} -finline-functions -fstack-arrays")
SET (CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -g -Og -ggdb3 -ffpe-trap=invalid -fbounds-check -finit-real=snan -fbacktrace -Wall")
SET (CMAKE_Fortran_FLAGS_SANITIZE "${CMAKE_Fortran_FLAGS} -g -Og -ggdb3 -ffpe-trap=invalid,zero,overflow,denorm -fbounds-check -finit-real=snan -fbacktrace -Wall -fsanitize=address,undefined,leak -fno-omit-frame-pointer -Wc-binding-type -Wuninitialized -pedantic")
# add flags only for compiling not linking!
# Compile flags depend on the generator
IF(NOT "${CMAKE_GENERATOR}" MATCHES "Ninja")
# add flags only for compiling not linking!
SET (HOPR_COMPILE_FLAGS "-xf95-cpp-input -fPIC")
ELSE()
SET (HOPR_COMPILE_FLAGS "${NINJA_COLOR_DIAGNOSTICS} -fPIC")
ENDIF()
# AMD Optimized LLVM/CLANG
ELSEIF (CMAKE_Fortran_COMPILER_ID MATCHES "Flang")
# set Flags
IF (NOT DEFINED C_FLAGS_INITIALIZED )
SET (C_FLAGS_INITIALIZED "yes" CACHE INTERNAL "Flag if compiler flags are already initialized" )
SET (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8 -std=f2008 -DFLANG")
ENDIF()
SET (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS} -O3 ${HOPR_INSTRUCTION} -finline-functions ")
SET (CMAKE_Fortran_FLAGS_PROFILE "${CMAKE_Fortran_FLAGS} -pg -O3 ${HOPR_INSTRUCTION} -finline-functions ")
SET (CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -g -O0 -ggdb3 -ffpe-trap=invalid -fbounds-check -finit-real=snan -fbacktrace -Wall")
# Compile flags depend on the generator
IF(NOT "${CMAKE_GENERATOR}" MATCHES "Ninja")
# add flags only for compiling not linking!
SET (HOPR_COMPILE_FLAGS "-xf95-cpp-input -fPIC")
ELSE()
SET (HOPR_COMPILE_FLAGS "${NINJA_COLOR_DIAGNOSTICS} -fPIC")
ENDIF()
# Intel Compiler
ELSEIF (CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
# set Flags
IF (NOT DEFINED C_FLAGS_INITIALIZED )
SET (C_FLAGS_INITIALIZED "yes" CACHE INTERNAL "Flag if compiler flags are already initialized" )
SET (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -r8 -i4 -traceback -warn all -shared-intel -DINTEL")
ENDIF()
SET (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS} -O2 ${HOPR_INSTRUCTION} -qopt-report0 -qopt-report-phase=vec")
SET (CMAKE_Fortran_FLAGS_PROFILE "${CMAKE_Fortran_FLAGS} -p -O2 ${HOPR_INSTRUCTION} -qopt-report0 -qopt-report-phase=vec")
SET (CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -g -O0 -fpe0 -traceback -check all,noarg_temp_created,noformat,nooutput_conversion,pointer,uninit -init=snan -init=arrays")
# Compile flags depend on the generator
IF(NOT "${CMAKE_GENERATOR}" MATCHES "Ninja")
# add flags only for compiling not linking!
SET (HOPR_COMPILE_FLAGS "-fpp -allow nofpp_comments -assume bscc")
ELSE()
SET (HOPR_COMPILE_FLAGS "${NINJA_COLOR_DIAGNOSTICS} -allow nofpp_comments -assume bscc")
ENDIF()
# Cray Compiler
ELSEIF (CMAKE_Fortran_COMPILER_ID MATCHES "Cray")
# set Flags
IF (NOT DEFINED C_FLAGS_INITIALIZED )
SET (C_FLAGS_INITIALIZED "yes" CACHE INTERNAL "Flag if compiler flags are already initialized" )
SET (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -f free -s real64 -em -DCRAY")
ENDIF()
SET (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS} -O2 -hfp3 -p . -rm")
SET (CMAKE_Fortran_FLAGS_PROFILE "${CMAKE_Fortran_FLAGS} -O2 -hfp3 -h profile_generate -p . -rm")
SET (CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -O0 -eD -rm")
# add flags only for compiling not linking!
SET (HOPR_COMPILE_FLAGS "${NINJA_COLOR_DIAGNOSTICS} -F")
ELSE()
MESSAGE(SEND_ERROR "Unknown compiler")
ENDIF()
# =========================================================================
# Profile-Guided Optimization (PGO)
# =========================================================================
OPTION(USE_PGO "Enable profile-guided optimization (Only GNU Compiler supported)" OFF)
IF (USE_PGO)
IF (CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
SET(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -fprofile-use")
SET(CMAKE_Fortran_FLAGS_PROFILE "${CMAKE_Fortran_FLAGS_PROFILE} -fprofile-generate")
ELSE()
MESSAGE( SEND_ERROR "Profile-guided optimization (PGO) currently only supported for GNU compiler. Either set USE_GPO=OFF or use the GNU compiler." )
ENDIF()
ENDIF()
# Save the current compiler flags to the cache every time cmake configures the project.
MARK_AS_ADVANCED(FORCE CMAKE_Fortran_FLAGS)
MARK_AS_ADVANCED(FORCE CMAKE_Fortran_FLAGS_RELEASE)
MARK_AS_ADVANCED(FORCE CMAKE_Fortran_FLAGS_PROFILE)
MARK_AS_ADVANCED(FORCE CMAKE_Fortran_FLAGS_DEBUG)
MARK_AS_ADVANCED(FORCE CMAKE_Fortran_FLAGS_SANITIZE)
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}" CACHE STRING "Default compiler flags" FORCE)
SET(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE}" CACHE STRING "Release compiler flags" FORCE)
SET(CMAKE_Fortran_FLAGS_PROFILE "${CMAKE_Fortran_FLAGS_PROFILE}" CACHE STRING "Profile compiler flags" FORCE)
SET(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG}" CACHE STRING "Debug compiler flags" FORCE)
SET(CMAKE_Fortran_FLAGS_SANITIZE "${CMAKE_Fortran_FLAGS_SANITIZE}" CACHE STRING "Sanitize compiler flags" FORCE)