Repository navigation
Expand file tree
/
Copy pathmeson.build
More file actions
536 lines (451 loc) · 19 KB
/
Copy pathmeson.build
File metadata and controls
536 lines (451 loc) · 19 KB
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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
project('SU2', 'c', 'cpp',
version: '8.6.0 "Harrier"',
meson_version: '>=1.8.2',
license: 'LGPL2',
default_options: ['buildtype=release',
'warning_level=0',
'b_ndebug=true',
'c_std=c99',
'cpp_std=c++17'])
fsmod = import('fs')
if not fsmod.exists('su2preconfig.timestamp')
error('SU2 must be (pre-)configured with the extended Meson script (./meson.py) or with the ./preconfigure.py script in the SU2 root directory.')
endif
pymod = import('python')
python = pymod.find_installation()
if get_option('enable-cuda')
add_languages('cuda')
# Compute capability to generate code for. Anything other than 'auto' is passed to nvcc as it
# is, so 'native', 'all-major', 'compute_XY', etc. all work.
cuda_arch = get_option('cuda-arch')
if cuda_arch == 'auto'
cuda_cc = ''
# Ships with the toolkit and prints e.g. "89"; it is what nvcc's own -arch=native uses.
cuda_query = find_program('__nvcc_device_query', required : false)
if cuda_query.found()
cuda_probe = run_command(cuda_query, check : false)
if cuda_probe.returncode() == 0
cuda_cc = cuda_probe.stdout().strip().split('\n')[0].strip()
endif
endif
# Fall back to the driver, which prints e.g. "8.9".
if cuda_cc == ''
cuda_query = find_program('nvidia-smi', required : false)
if cuda_query.found()
cuda_probe = run_command(cuda_query, '--query-gpu=compute_cap', '--format=csv,noheader', check : false)
if cuda_probe.returncode() == 0
cuda_cc = cuda_probe.stdout().strip().split('\n')[0].strip().replace('.', '')
endif
endif
endif
if cuda_cc == ''
error('Could not detect the CUDA compute capability of this machine (no GPU visible?), ' +
'set it explicitly, for example -Dcuda-arch=sm_89.')
endif
cuda_arch = 'sm_' + cuda_cc
message('Detected CUDA compute capability, building for ' + cuda_arch)
endif
add_global_arguments('-arch=' + cuda_arch, language : 'cuda')
# nvcc's frontend does not recognize the AMX-tile builtins pulled in by
# newer glibc/gcc <immintrin.h>; SU2 does not use AMX, so skip the header.
add_global_arguments('-D_AMXTILEINTRIN_H_INCLUDED', language : 'cuda')
# Any target linking CUDA object code is linked via nvcc instead of the C++
# linker, which otherwise defaults to a plain host gcc and silently drops
# the MPI link flags that -Dcustom-mpi=true relies on mpicxx to provide.
add_global_arguments('-ccbin=' + meson.get_compiler('cpp').cmd_array()[0], language : 'cuda')
add_global_link_arguments('-ccbin=' + meson.get_compiler('cpp').cmd_array()[0], language : 'cuda')
endif
su2_cpp_args = []
su2_deps = [declare_dependency(include_directories: 'externals/CLI11')]
default_warning_flags = []
if build_machine.system() != 'windows'
desired_warnings = ['-Wno-empty-body',
'-Wno-ignored-qualifiers',
'-Wno-unused-parameter',
'-Wno-deprecated-declarations',
'-Wno-error=cast-function-type',
'-Wno-cast-function-type',
'-Wno-error=stringop-truncation',
'-Wno-stringop-truncation',
'-Wno-error=missing-field-initializers',
'-Wno-missing-field-initializers',
'-Wno-error=class-memaccess',
'-Wno-class-memaccess',
'-Wno-overloaded-virtual',
'-Wno-array-bounds',
'-Wno-dangling-pointer']
foreach flag : desired_warnings
if meson.get_compiler('cpp').has_argument(flag)
default_warning_flags += flag
endif
endforeach
if get_option('enable-autodiff') or get_option('enable-directdiff')
default_warning_flags += ['-Wno-non-virtual-dtor']
endif
endif
if get_option('cpu-arch') != ''
su2_cpp_args += ['-march=' + get_option('cpu-arch')]
endif
# Fast math to allow pow(x, 2) -> x * x.
if meson.get_compiler('cpp').has_argument('-fno-finite-math-only')
su2_cpp_args += ['-ffast-math', '-fno-finite-math-only']
endif
# Handle assertions: default is b_ndebug=true (assertions disabled)
# but for debug builds, we want to enable assertions
if get_option('buildtype') == 'debug'
# Undefine NDEBUG
su2_cpp_args += '-UNDEBUG'
endif
# meson script path
script_path = meson.project_source_root() / 'meson_scripts'
# mpi flag
mpi = false
# If custom mpi mode is enabled, include and library pathes for MPI have to be set manually to env variables
if get_option('custom-mpi')
mpi_dep = []
mpi = true
# Otherwise they are automatically determined
else
mpi_dep = [dependency('mpi', language:'c', required : get_option('with-mpi')),
dependency('mpi', language:'cpp', required : get_option('with-mpi'))]
if mpi_dep[0].found() or mpi_dep[1].found()
mpi = true
endif
endif
# OpenMP
omp = get_option('with-omp')
if omp
omp_dep = dependency('openmp', language:'cpp')
endif
su2_deps += declare_dependency(include_directories: 'externals/eigen')
if get_option('enable-autodiff') or get_option('enable-directdiff')
codi_dep = [declare_dependency(include_directories: 'externals/codi/include')]
codi_rev_args = ['-DCODI_REVERSE_TYPE']
codi_for_args = ['-DCODI_FORWARD_TYPE']
if get_option('debug')
codi_rev_args += '-DCODI_EnableAssert'
codi_for_args += '-DCODI_EnableAssert'
endif
endif
if get_option('enable-autodiff') and not omp
if get_option('codi-tape') == 'JacobianLinear'
codi_rev_args += '-DCODI_JACOBIAN_LINEAR_TAPE'
elif get_option('codi-tape') == 'JacobianReuse'
codi_rev_args += '-DCODI_JACOBIAN_REUSE_TAPE'
elif get_option('codi-tape') == 'JacobianMultiUse'
codi_rev_args += '-DCODI_JACOBIAN_MULTIUSE_TAPE'
elif get_option('codi-tape') == 'PrimalLinear'
codi_rev_args += '-DCODI_PRIMAL_LINEAR_TAPE'
elif get_option('codi-tape') == 'PrimalReuse'
codi_rev_args += '-DCODI_PRIMAL_REUSE_TAPE'
elif get_option('codi-tape') == 'PrimalMultiUse'
codi_rev_args += '-DCODI_PRIMAL_MULTIUSE_TAPE'
elif get_option('codi-tape') == 'Tag'
codi_rev_args += '-DCODI_TAG_TAPE'
else
error('Invalid CoDiPack tape choice @0@'.format(get_option('codi-tape')))
endif
if get_option('codi-tape') != 'JacobianLinear'
warning('The tape choice @0@ is not tested regularly in SU2'.format(get_option('codi-tape')))
endif
endif
# Add Tracy dependency if enabled
if get_option('tracy_enable')
tracy_dep = dependency('tracy', static: true)
su2_deps += tracy_dep
su2_cpp_args += '-DTRACY_ENABLE'
# Add build type check
if get_option('buildtype') != 'debugoptimized'
warning('For optimal Tracy profiling, use --buildtype=debugoptimized')
endif
endif
# add cgns library
if get_option('enable-cgns')
subdir('externals/cgns')
su2_deps += cgns_dep
su2_cpp_args += '-DHAVE_CGNS'
endif
# check for mixed precision floating point arithmetic
if get_option('enable-mixedprec') or get_option('enable-singleprec')
su2_cpp_args += '-DUSE_MIXED_PRECISION'
endif
if get_option('enable-singleprec')
su2_cpp_args += '-DUSE_SINGLE_PRECISION'
endif
# check if MPI dependencies are found and add them
if mpi
# add MPI dependency
su2_deps += mpi_dep
su2_cpp_args += '-DHAVE_MPI'
# compile metis
subdir('externals/metis')
# add metis dependency
su2_deps += metis_dep
su2_cpp_args += '-DHAVE_METIS'
# compile parmetis
subdir('externals/parmetis')
# add parmetis dependency
su2_deps += parmetis_dep
su2_cpp_args += '-DHAVE_PARMETIS'
# add medi dependency
if get_option('enable-autodiff') or get_option('enable-directdiff')
codi_dep += declare_dependency(include_directories: ['externals/medi/include', 'externals/medi/src'])
endif
endif
if omp
# add OpenMP dependency
su2_deps += omp_dep
su2_cpp_args += '-DEIGEN_DONT_PARALLELIZE'
# add opdi dependency
if get_option('enable-autodiff')
codi_dep += declare_dependency(include_directories: 'externals/opdi/include')
codi_rev_args += '-DCODI_EnableOpenMP'
codi_rev_args += '-DCODI_EnableOpDiLib'
if get_option('opdi-backend') == 'macro'
su2_cpp_args += '-DFORCE_OPDI_MACRO_BACKEND'
elif get_option('opdi-backend') == 'ompt'
su2_cpp_args += '-DFORCE_OPDI_OMPT_BACKEND'
endif
if get_option('opdi-shared-read-opt') == false
su2_cpp_args += '-DOPDI_VARIABLE_ADJOINT_ACCESS_MODE=0'
endif
endif
endif
if get_option('enable-tecio')
subdir('externals/tecio')
endif
# PaStiX
if get_option('enable-pastix')
assert(mpi,
'PaStiX support requires MPI')
assert(get_option('enable-mkl') or get_option('enable-openblas'),
'PaStiX support requires either mkl or openblas')
su2_cpp_args += '-DHAVE_PASTIX'
su2_deps += dependency('pastix')
su2_deps += meson.get_compiler('cpp').find_library('scotch', required: true)
su2_deps += meson.get_compiler('cpp').find_library('scotcherr', required: true)
su2_deps += meson.get_compiler('cpp').find_library('ptscotch', required: true)
endif
# CUDA dependencies
if get_option('enable-cuda')
su2_cpp_args += '-DHAVE_CUDA'
su2_deps += meson.get_compiler('cuda').find_library('cudart', required : true)
endif
# blas-type dependencies
if get_option('enable-mkl')
su2_cpp_args += '-DHAVE_MKL'
# the following mkl name matches the linked libs in manual dependency
# see https://software.intel.com/en-us/articles/intel-math-kernel-library-intel-mkl-and-pkg-config-tool
# should probably switch to iomp if Intel OpenMP is used
mkl_dep = dependency('mkl-static-lp64-seq', required: false)
if not mkl_dep.found()
mkl_root = get_option('mkl_root')
mkl_dep = declare_dependency(include_directories: mkl_root+'/include', compile_args: '-m64',
link_args: ['-L'+mkl_root+'/lib/intel64','-lmkl_intel_lp64','-lmkl_sequential','-lmkl_core','-lpthread','-lm','-ldl'])
endif
su2_deps += mkl_dep
elif get_option('enable-openblas')
su2_cpp_args += '-DHAVE_BLAS'
su2_cpp_args += '-DHAVE_LAPACK'
su2_deps += dependency(get_option('blas-name'))
su2_deps += dependency('lapack')
if get_option('enable-pastix')
su2_deps += dependency('lapacke')
endif
endif
if get_option('enable-librom')
assert(get_option('librom_root')!='',
'Must specify librom folder (-Dlibrom_root=path/to/libROM)')
su2_cpp_args += '-DHAVE_LIBROM'
librom_root = get_option('librom_root')
librom_dep = declare_dependency(include_directories: librom_root+'/lib',
link_args: ['-L'+librom_root+'/build', '-lROM'])
su2_deps += librom_dep
endif
mel_dep = declare_dependency(include_directories: 'externals/mel')
su2_deps += mel_dep
extra_deps = get_option('extra-deps').split(',')
foreach dep : extra_deps
if dep != ''
su2_deps += dependency(dep)
endif
endforeach
catch2_dep = declare_dependency(include_directories: 'externals/catch2/')
if get_option('enable-mpp')
cmake = import('cmake')
cmake_opts = cmake.subproject_options()
cmake_opts.set_override_option('warning_level', '0')
cmake_opts.add_cmake_defines({
'CMAKE_MAKE_PROGRAM': join_paths(meson.project_source_root(), 'ninja'),
'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'
})
cmake_opts.set_install(get_option('install-mpp'))
mpp_subproj = cmake.subproject('Mutationpp', options: cmake_opts)
mpp_dep = mpp_subproj.dependency('mutation++')
su2_deps += mpp_dep
su2_cpp_args += '-DHAVE_MPP'
if get_option('install-mpp')
py = find_program('python3', 'python')
p = run_command(py, 'SU2_PY/copy_directory.py', 'subprojects/Mutationpp/data', join_paths(get_option('prefix'), 'mpp-data'))
if p.returncode() != 0
error(p.stderr())
endif
endif
endif
if get_option('enable-coolprop')
if build_machine.cpu_family() == 'x86' or build_machine.cpu_family() == 'x86_64'
cmake = import('cmake')
cmake_opts = cmake.subproject_options()
if get_option('cpu-arch') != ''
cmake_opts.add_cmake_defines({
'CMAKE_CXX_FLAGS': '-march=' + get_option('cpu-arch')
})
endif
cmake_opts.set_override_option('warning_level', '0')
cmake_opts.add_cmake_defines({
'COOLPROP_STATIC_LIBRARY': true,
'CMAKE_MAKE_PROGRAM': join_paths(meson.project_source_root(), 'ninja'),
'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'
})
coolprop_subproj = cmake.subproject('CoolProp', options: cmake_opts)
coolprop_dep = coolprop_subproj.dependency('CoolProp')
su2_deps += coolprop_dep
su2_cpp_args += '-DHAVE_COOLPROP'
else
message('WARNING: CPU is not x86, skipping CoolProp dependency.')
endif
endif
if get_option('enable-cantera')
# Cantera is built from source via its own SCons build, driven silently as part of
# the normal SU2 build (custom_target below), rather than requiring a separate manual
# build step or a prebuilt system/conda package. Building from source (instead of
# linking a prebuilt shared library) keeps the door open for a future AD-enabled
# Cantera build variant compiled against SU2's own scalar type.
cantera_source_dir = join_paths(meson.current_source_dir(), 'subprojects', 'cantera')
cantera_prefix = join_paths(meson.current_build_dir(), 'cantera_install')
cantera_build_script = join_paths(meson.current_source_dir(), 'meson_scripts', 'build_cantera.py')
cantera_build_command = [python, cantera_build_script,
'--source', cantera_source_dir,
'--prefix', cantera_prefix,
'--stamp', '@OUTPUT@',
'--eigen-inc-dir', join_paths(meson.current_source_dir(), 'externals', 'eigen')]
cantera_build_command += ['--jobs', get_option('cantera-build-jobs').to_string()]
if get_option('cantera-boost-inc-dir') != ''
cantera_build_command += ['--boost-inc-dir', get_option('cantera-boost-inc-dir')]
endif
if get_option('cpu-arch') != ''
cantera_build_command += ['--cpu-arch', get_option('cpu-arch')]
endif
cantera_build = custom_target('build_cantera',
output: 'cantera_build.stamp',
command: cantera_build_command,
build_always_stale: true,
console: true,
)
# build_cantera.py makes Cantera's installed headers resolve Eigen through an
# "eigen3/Eigen/..." shim it creates next to the install prefix, pointing at SU2's
# own Eigen copy (see the ODR note in that script). Anything compiling those headers -
# including SU2's own CFluidCantera.cpp - needs that same shim directory on its
# include path so the "eigen3/..." form resolves for it too.
cantera_dep = declare_dependency(
compile_args: ['-I' + join_paths(cantera_prefix, 'include'),
'-I' + cantera_prefix + '_eigen_shim'],
link_args: ['-L' + join_paths(cantera_prefix, 'lib'), '-lcantera'],
sources: [cantera_build],
)
su2_cpp_args +='-DHAVE_CANTERA'
endif
if get_option('enable-mlpcpp')
su2_cpp_args += '-DHAVE_MLPCPP'
endif
if omp and get_option('enable-autodiff')
py = find_program('python3','python')
p = run_command(py, 'externals/opdi/syntax/check.py', 'su2omp.syntax.json', 'Common', 'SU2_CFD', '-p', '*.hpp', '*.cpp', '*.inl', '-r', '-q')
if p.returncode() != 0
error(p.stdout())
endif
endif
# compile common library
subdir('Common/src')
# compile SU2_CFD executable
subdir('SU2_CFD/src')
# compile SU2_DEF executable
subdir('SU2_DEF/src')
# compile SU2_DOT executable
subdir('SU2_DOT/src')
# compile SU2_GEO executable
subdir('SU2_GEO/src')
# compile SU2_SOL executable
subdir('SU2_SOL/src')
# install python scripts
subdir('SU2_PY')
# unit tests
subdir('UnitTests')
if get_option('enable-pywrapper')
subdir('SU2_PY/pySU2')
endif
message('''-------------------------------------------------------------------------
| ___ _ _ ___ |
| / __| | | |_ ) Release 8.6.0 "Harrier" |
| \__ \ |_| |/ / |
| |___/\___//___| Meson Configuration Summary |
| |
-------------------------------------------------------------------------
Option Value
---------------------
TecIO: @2@
CGNS: @3@
AD (reverse): @4@
AD (forward): @5@
Python Wrapper: @6@
Intel-MKL: @7@
OpenBlas: @8@
PaStiX: @9@
Mixed Float: @10@
libROM: @11@
CoolProp: @12@
MLPCpp: @13@
Tracy Profiler: @14@
Cantera: @16@
Please be sure to add the $SU2_HOME and $SU2_RUN environment variables,
and update your $PATH (and $PYTHONPATH if applicable) with $SU2_RUN
Based on the input to this configuration, add these lines to your .bashrc file:
export SU2_RUN=@0@
export SU2_HOME=@1@
export PATH=$PATH:$SU2_RUN
export PYTHONPATH=$PYTHONPATH:$SU2_RUN
Use './ninja -C @15@ install' to compile and install SU2
'''.format(get_option('prefix')+'/bin', meson.project_source_root(), get_option('enable-tecio'), get_option('enable-cgns'),
get_option('enable-autodiff'), get_option('enable-directdiff'), get_option('enable-pywrapper'), get_option('enable-mkl'),
get_option('enable-openblas'), get_option('enable-pastix'), get_option('enable-mixedprec'), get_option('enable-librom'), get_option('enable-coolprop'),
get_option('enable-mlpcpp'), get_option('tracy_enable'), meson.project_build_root().startswith(meson.project_source_root()) ? meson.project_build_root().split('/')[-1] : meson.project_build_root(),
get_option('enable-cantera')))
if get_option('enable-mpp')
if get_option('install-mpp')
message(''' To run SU2 with Mutation++ library, add these lines to your .bashrc file:
export MPP_DATA_DIRECTORY=$SU2_RUN/../mpp-data
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SU2_RUN/../lib
''')
else
message(''' To run SU2 with Mutation++ library, add these lines to your .bashrc file:
export MPP_DATA_DIRECTORY=$SU2_HOME/subprojects/Mutationpp/data
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SU2_HOME/<build_dir>/subprojects/Mutationpp
''')
endif
endif
if get_option('enable-cantera')
message(''' To run SU2 with Cantera, add this line to your .bashrc file:
export CANTERA_DATA=@0@/data
Cantera's own compiled-in default data directory should normally be
found automatically, but setting CANTERA_DATA explicitly avoids
relying on that at runtime.
'''.format(cantera_prefix))
endif
if get_option('enable-librom')
message(''' To run SU2 with libROM library, add this line to your .bashrc file:
export LD_LIBRARY_PATH=@0@/build/:$LD_LIBRARY_PATH
'''.format(get_option('librom_root')))
endif
if get_option('enable-pywrapper') and get_option('enable-cgns') and not get_option('static-cgns-deps')
message(''' WARNING: If compilation fails with a message regarding "attempted static link of dynamic object", reconfigure with option -Dstatic-cgns-deps=true.''')
endif