-
Notifications
You must be signed in to change notification settings - Fork 17
/
CMakeListsMachine.txt
344 lines (314 loc) · 16.3 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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# =========================================================================
# 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)
SET(FORCE_VDM_ANALYTICAL OFF)
# =========================================================================
# 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(PICLAS_INSTRUCTION "-march=znver2 -mtune=znver2")
ELSEIF (CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
SET(PICLAS_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(PICLAS_INSTRUCTION "-march=skylake-avx512 -mtune=skylake-avx512")
ELSEIF (CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
SET(PICLAS_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(PICLAS_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(PICLAS_INSTRUCTION "-march=core-avx2 -mtune=core-avx2")
ELSEIF (CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
SET(PICLAS_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(PICLAS_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(PICLAS_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(PICLAS_INSTRUCTION "-march=native -mtune=native")
# SET(PICLAS_INSTRUCTION "-mtune=generic")
ELSEIF (CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
SET(PICLAS_INSTRUCTION "-xHost")
ENDIF()
ENDIF()
MESSAGE(STATUS "Compiling Nitro/Release/Profile with [${CMAKE_Fortran_COMPILER_ID}] (v${CMAKE_Fortran_COMPILER_VERSION}) fortran compiler using PICLAS_INSTRUCTION [${PICLAS_INSTRUCTION}] instructions.")
# =========================================================================
# CHECK SUPPORT FOR VARIOUS FORTRAN (2003,2008) FEATURES
# =========================================================================
INCLUDE(CheckFortranSourceCompiles)
CHECK_FORTRAN_SOURCE_COMPILES(
"MODULE F03MOD
IMPLICIT NONE
PRIVATE
CONTAINS
! Check for MOVE_ALLOC feature
SUBROUTINE F03_MOVE_ALLOC()
REAL,ALLOCATABLE::a(:,:),b(:,:)
ALLOCATE(a(3,3))
CALL MOVE_ALLOC(a,b)
END SUBROUTINE F03_MOVE_ALLOC
END MODULE F03MOD
PROGRAM F03PROG
END"
Fortran2003Check
SRC_EXT F90)
IF(NOT Fortran2003Check)
MESSAGE(FATAL_ERROR "Failed to compile basic Fortran2003 programm! Please ensure your compiler is up-to-date!")
ENDIF()
# =========================================================================
# CHECK IF GCC CONTAINS THE PARSE_ASSOCIATE BUG (GC C13.1-13.2)
# =========================================================================
INCLUDE(CheckFortranSourceCompiles)
CHECK_FORTRAN_SOURCE_COMPILES(
"MODULE GCC13MOD
IMPLICIT NONE
PRIVATE
CONTAINS
! Check for MOVE_ALLOC feature
SUBROUTINE GCC_PARSE_ASSOCIATE()
REAL::x1(3),x2(3)
ASSOCIATE(v1 => x1, v2 => x2)
v1 = 0
v2 = 1
v1 = 0 + v1
END ASSOCIATE
END SUBROUTINE GCC_PARSE_ASSOCIATE
END MODULE GCC13MOD
PROGRAM GCC13PROG
END"
GCC13Check
SRC_EXT F90)
IF(NOT GCC13Check)
MESSAGE(WARNING "The requested compiler ${CMAKE_Fortran_COMPILER_ID} (v${CMAKE_Fortran_COMPILER_VERSION}) contains a bug in parse_associate. Ensure ASSOCIATE is only use with explicit array bounds or use a different compiler version. Please see the upstream issue, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109948")
ENDIF()
# =========================================================================
# 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")
IF(PICLAS_EXTRAE)
SET (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -finstrument-functions")
ENDIF(PICLAS_EXTRAE)
# 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_NITRO "${CMAKE_Fortran_FLAGS} -Ofast ${PICLAS_INSTRUCTION}")
SET (CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS} -O3 ${PICLAS_INSTRUCTION} -finline-functions -fstack-arrays")
SET (CMAKE_Fortran_FLAGS_PROFILE "${CMAKE_Fortran_FLAGS} -pg -O3 ${PICLAS_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 (PICLAS_COMPILE_FLAGS "-xf95-cpp-input")
ELSE()
# Trailing white space required in case variable is unset!
SET (PICLAS_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 ${PICLAS_INSTRUCTION} -finline-functions ")
SET (CMAKE_Fortran_FLAGS_PROFILE "${CMAKE_Fortran_FLAGS} -pg -O3 ${PICLAS_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 (PICLAS_COMPILE_FLAGS "-xf95-cpp-input")
ELSE()
# Trailing white space required in case variable is unset!
SET (PICLAS_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 ${PICLAS_INSTRUCTION} -qopt-report0 -qopt-report-phase=vec -no-prec-div")
SET (CMAKE_Fortran_FLAGS_PROFILE "${CMAKE_Fortran_FLAGS} -p -O3 ${PICLAS_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 (PICLAS_COMPILE_FLAGS "-fpp -allow nofpp_comments -assume bscc")
ELSE()
SET (PICLAS_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 (PICLAS_COMPILE_FLAGS "${NINJA_COLOR_DIAGNOSTICS} -F")
ELSE()
MESSAGE(SEND_ERROR "Unknown compiler")
ENDIF()
# =========================================================================
# Profile-Guided Optimization (PGO)
# =========================================================================
CMAKE_DEPENDENT_OPTION(USE_PGO "Enable profile-guided optimization (Only GNU Compiler supported)" OFF
"PICLAS_PERFORMANCE" 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_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)