forked from flexi-framework/flexi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeListsMachine.txt
283 lines (259 loc) · 14.4 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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# =========================================================================
# 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()
MESSAGE(STATUS "Generating for [${CMAKE_GENERATOR}] build system")
# =========================================================================
# 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
IF (CMAKE_FQDN_HOST MATCHES "hawk\.hww\.hlrs\.de$")
SET(CMAKE_C_COMPILER mpicc)
SET(CMAKE_CXX_COMPILER mpicxx)
SET(CMAKE_Fortran_COMPILER mpif90) # mpif08 wrapper seems to have issue
# SuperMUC
# ELSEIF(CMAKE_FQDN_HOST MATCHES "sng\.lrz\.de$"
# LUMI
ELSEIF(CMAKE_FQDN_HOST MATCHES "\.can$")
SET(CMAKE_C_COMPILER cc)
SET(CMAKE_CXX_COMPILER CC)
SET(CMAKE_Fortran_COMPILER ftn)
# IAG Prandtl
ELSEIF(CMAKE_FQDN_HOST MATCHES "^(prandtl|grafik.*)\.iag\.uni\-stuttgart\.de")
SET(CMAKE_C_COMPILER gcc)
SET(CMAKE_CXX_COMPILER c++)
SET(CMAKE_Fortran_COMPILER gfortran)
# IAG Grafik01/Grafik02
ELSEIF (CMAKE_FQDN_HOST MATCHES "^ila(head.*|cfd.*)\.ila.uni\-stuttgart\.de")
SET(CMAKE_C_COMPILER mpicc)
SET(CMAKE_CXX_COMPILER mpicxx)
SET(CMAKE_Fortran_COMPILER mpif90) # mpif08 wrapper seems to have issue
ELSEIF (CMAKE_FQDN_HOST MATCHES "^(xenon.*|argon.*)\.ila.uni\-stuttgart\.de")
SET(CMAKE_C_COMPILER mpicc)
SET(CMAKE_CXX_COMPILER mpicxx)
SET(CMAKE_Fortran_COMPILER mpif90) # mpif08 wrapper seems to have issue
ENDIF()
# =========================================================================
# Score-P instrumentation infrastructure
# > This option must be called before ENABLE_LANGUAGE, thus is only available
# > through -DMACHINE_USE_SCOREP=ON
# =========================================================================
IF (MACHINE_USE_SCOREP)
FIND_PROGRAM(SCOREP_C_COMPILER scorep-${CMAKE_C_COMPILER})
MARK_AS_ADVANCED(FORCE SCOREP_C_COMPILER )
IF (SCOREP_C_COMPILER MATCHES "NOTFOUND")
MESSAGE (FATAL_ERROR "Score-P not available in PATH. Did you load the module?")
ENDIF()
# Set default build type to profile
IF (NOT CMAKE_BUILD_TYPE)
SET (CMAKE_BUILD_TYPE Profile CACHE STRING "Choose the type of build, options are: Debug Release Profile Sanitize." FORCE)
ENDIF (NOT CMAKE_BUILD_TYPE)
IF (CMAKE_BUILD_TYPE MATCHES "Release")
MESSAGE (WARNING "Score-P requires debug compile flags which are not available with BUILD_TYPE='Release'")
ENDIF()
SET(CMAKE_C_COMPILER "scorep-${CMAKE_C_COMPILER}")
SET(CMAKE_CXX_COMPILER "scorep-${CMAKE_CXX_COMPILER}")
SET(CMAKE_Fortran_COMPILER "scorep-${CMAKE_Fortran_COMPILER}")
ENDIF()
# =========================================================================
# After settings specific compilers, enable named languages for cmake
# =========================================================================
ENABLE_LANGUAGE(Fortran C CXX)
INCLUDE(GNUInstallDirs)
MARK_AS_ADVANCED(FORCE C_PATH CXX_PATH Fortran_PATH)
# =========================================================================
# Set machine-specific definitions and settings
# =========================================================================
# HLRS HAWK
IF (CMAKE_FQDN_HOST 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(FLEXI_INSTRUCTION "-march=znver2 -mtune=znver2")
ELSEIF (CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
SET(FLEXI_INSTRUCTION "-xCORE-AVX2")
ENDIF()
# Use AMD Optimized Lapack/BLAS
# SET(BLA_VENDOR "FLAME")
# Set LUSTRE definition to account for filesystem and MPI implementation
ADD_DEFINITIONS(-DLUSTRE)
# SuperMUC
ELSEIF (CMAKE_FQDN_HOST 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(FLEXI_INSTRUCTION "-march=skylake-avx512 -mtune=skylake-avx512")
ELSEIF (CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
SET(FLEXI_INSTRUCTION "-xSKYLAKE-AVX512")
# Explicitely enable usage of AVX512 registers
SET (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qopt-zmm-usage=high")
ENDIF()
# Set LUSTRE definition to account for filesystem and MPI implementation
ADD_DEFINITIONS(-DLUSTRE)
# LUMI
ELSEIF(CMAKE_FQDN_HOST MATCHES "\.can$")
MESSAGE(STATUS "Compiling on LUMI")
IF (CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
SET(FLEXI_INSTRUCTION "-march=znver3 -mtune=znver3")
ELSE()
MESSAGE(FATAL_ERROR "LUMI currently only supported using the GNU Compiler Collection (GCC). Please load/swap the following modules: LUMI PrgEnv-gnu cray-hdf5-parallel")
ENDIF()
# IAG Prandtl
ELSEIF(CMAKE_FQDN_HOST MATCHES "^(prandtl|grafik.*)\.iag\.uni\-stuttgart\.de")
MESSAGE(STATUS "Compiling on ${CMAKE_HOSTNAME}")
SET(FLEXI_INSTRUCTION "-march=native -mtune=native")
# Set LUSTRE definition to account for filesystem
ADD_DEFINITIONS(-DLUSTRE)
ELSEIF (CMAKE_FQDN_HOST MATCHES "^ila(head.*|cfd.*)\.ila.uni\-stuttgart\.de")
MESSAGE(STATUS "Compiling on ILA cluster")
# Overwrite compiler target architecture
IF (CMAKE_Fortran_COMPILER_ID MATCHES "GNU" OR CMAKE_Fortran_COMPILER_ID MATCHES "Flang")
SET(FLEXI_INSTRUCTION "-march=core-avx2 -mtune=core-avx2")
ELSEIF (CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
SET(FLEXI_INSTRUCTION "-xCORE-AVX2")
ENDIF()
# Work around MPI-IO issue 4446 on machines mounting storage via NFS
ADD_DEFINITIONS(-DNFS)
ELSEIF (CMAKE_FQDN_HOST MATCHES "^(xenon.*|argon.*)\.ila.uni\-stuttgart\.de")
MESSAGE(STATUS "Compiling on ILA student cluster")
SET(FLEXI_INSTRUCTION "-march=native -mtune=native")
# Work around MPI-IO issue 4446 on machines mountng storage via NFS
ADD_DEFINITIONS(-DNFS)
ELSEIF ("${CMAKE_FQDN_HOST}" MATCHES "gitlab\.ila\.uni\-stuttgart\.de")
MESSAGE(STATUS "Compiling on ILA Gitlab")
ADD_DEFINITIONS(-DVDM_ANALYTICAL)
SET(FLEXI_INSTRUCTION "-march=native -mtune=native")
ELSE()
MESSAGE(STATUS "Compiling on a generic machine [${CMAKE_HOSTNAME}]")
# Set compiler target architecture
IF (CMAKE_Fortran_COMPILER_ID MATCHES "GNU" OR CMAKE_Fortran_COMPILER_ID MATCHES "Flang" OR CMAKE_Fortran_COMPILER_ID MATCHES "Cray")
SET(FLEXI_INSTRUCTION "-march=native -mtune=native")
ELSEIF (CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
SET(FLEXI_INSTRUCTION "-xHost")
ENDIF()
ENDIF()
MESSAGE(STATUS "Compiling with [${CMAKE_Fortran_COMPILER_ID}] (v${CMAKE_Fortran_COMPILER_VERSION}) fortran compiler using [${FLEXI_INSTRUCTION}] instruction")
# =========================================================================
# COMPILER FLAGS
# =========================================================================
# FFLAGS depend on the compiler
GET_FILENAME_COMPONENT (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
# CMake can always request position independent code
# SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
# 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 -lstdc++ -DGNU")
# LUMI has an issue with argument types in MPI(CH) calls
IF(CMAKE_FQDN_HOST MATCHES "\.can$")
SET (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch")
ENDIF()
ENDIF()
# initialize all variables as signalling NaNs to force the user to correctly initialize these data types
SET (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS} -O3 ${FLEXI_INSTRUCTION} -finline-functions -fstack-arrays")
SET (CMAKE_Fortran_FLAGS_PROFILE "${CMAKE_Fortran_FLAGS} -pg -O3 ${FLEXI_INSTRUCTION} -finline-functions -fstack-arrays")
SET (CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS} -g -Og -ggdb3 -ffpe-trap=invalid -fbounds-check -fbacktrace -Wall")
SET (CMAKE_Fortran_FLAGS_SANITIZE "${CMAKE_Fortran_FLAGS} -g -Og -ggdb3 -ffpe-trap=invalid,zero,overflow,denorm -fbounds-check -fbacktrace -Wall -fsanitize=address,undefined,leak -fno-omit-frame-pointer -Wc-binding-type -Wuninitialized -pedantic")
# Compile flags depend on the generator
IF(NOT "${CMAKE_GENERATOR}" MATCHES "Ninja")
# add flags only for compiling not linking!
SET (FLEXI_COMPILE_FLAGS "-xf95-cpp-input")
ELSE()
# Trailing white space required in case variable is unset!
SET (FLEXI_COMPILE_FLAGS "${NINJA_COLOR_DIAGNOSTICS} ")
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 -lstdc++ -DFLANG")
ENDIF()
SET (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS} -O3 ${FLEXI_INSTRUCTION} -finline-functions ")
SET (CMAKE_Fortran_FLAGS_PROFILE "${CMAKE_Fortran_FLAGS} -pg -O3 ${FLEXI_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 (FLEXI_COMPILE_FLAGS "-xf95-cpp-input")
ELSE()
# Trailing white space required in case variable is unset!
SET (FLEXI_COMPILE_FLAGS "${NINJA_COLOR_DIAGNOSTICS} ")
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 -lstdc++ -DINTEL")
ENDIF()
SET (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS} -O3 ${FLEXI_INSTRUCTION} -qopt-report0 -qopt-report-phase=vec -no-prec-div")
SET (CMAKE_Fortran_FLAGS_PROFILE "${CMAKE_Fortran_FLAGS} -p -O3 ${FLEXI_INSTRUCTION} -qopt-report0 -qopt-report-phase=vec -no-prec-div")
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 (FLEXI_COMPILE_FLAGS "-fpp -allow nofpp_comments -assume bscc")
ELSE()
SET (FLEXI_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} -ffree -s real64 -s integer64 -em -lstdc++ -hfp0 -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} -g -O0 -eD -rm")
# add flags only for compiling not linking!
SET (FLEXI_COMPILE_FLAGS "${NINJA_COLOR_DIAGNOSTICS} -F")
ELSE()
MESSAGE(SEND_ERROR "Unknown compiler")
ENDIF()
# =========================================================================
# Profile-Guided Optimization (PGO)
# =========================================================================
CMAKE_DEPENDENT_OPTION(FLEXI_PERFORMANCE_PGO "Enable profile-guided optimization (Only GNU Compiler supported)" OFF
"FLEXI_PERFORMANCE" OFF)
IF (FLEXI_PERFORMANCE_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 FLEXI_PERFORMANCE_PGO=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)