-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathmeson.build
More file actions
290 lines (254 loc) · 8.62 KB
/
meson.build
File metadata and controls
290 lines (254 loc) · 8.62 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
project(
'SPRAL',
'c', 'cpp', 'fortran',
version: '2025.09.18',
license: 'BSD-3',
meson_version: '>= 0.63.0',
default_options: [
'buildtype=release',
'libdir=lib',
'default_library=shared',
'warning_level=0',
'c_std=c99',
'cpp_std=c++11',
],
)
# Compilers
cc = meson.get_compiler('c')
cxx = meson.get_compiler('cpp')
fc = meson.get_compiler('fortran')
nvcc_available = add_languages('cuda', required: false, native: false)
# Remove messages about deprecated Intel compilers
if cc.get_id() == 'intel'
add_global_arguments('-diag-disable=10441', language : 'c')
add_global_link_arguments('-diag-disable=10441', language : 'c')
endif
if cc.get_id() == 'intel-cl'
add_global_arguments('/Qdiag-disable=10441', language : 'c')
add_global_link_arguments('/Qdiag-disable=10441', language : 'c')
endif
if cxx.get_id() == 'intel'
add_global_arguments('-diag-disable=10441', language : 'cpp')
add_global_link_arguments('-diag-disable=10441', language : 'cpp')
endif
if cxx.get_id() == 'intel-cl'
add_global_arguments('/Qdiag-disable=10441', language : 'cpp')
add_global_link_arguments('/Qdiag-disable=10441', language : 'cpp')
endif
# Recognise old non-standard double complex intrinsics
if fc.get_id() == 'nagfor'
add_global_arguments('-dcfuns', language : 'fortran')
endif
# Options
install_modules = get_option('modules')
build_gpu = get_option('gpu')
build_tests = get_option('tests')
build_examples = get_option('examples')
build_openmp = get_option('openmp')
libblas_name = get_option('libblas')
libblas_path = get_option('libblas_path')
libblas_include = include_directories(get_option('libblas_include'))
liblapack_name = get_option('liblapack')
liblapack_path = get_option('liblapack_path')
libhwloc_name = get_option('libhwloc')
libhwloc_path = get_option('libhwloc_path')
libhwloc_include = include_directories(get_option('libhwloc_include'))
libmetis_name = get_option('libmetis')
libmetis_path = get_option('libmetis_path')
libmetis_version = get_option('libmetis_version')
metis64 = get_option('metis64')
# Dependencies
if libblas_path == []
libblas = dependency(libblas_name, required : false)
endif
if libblas_path != [] or not libblas.found()
libblas = fc.find_library(libblas_name, dirs : libblas_path, required : true)
endif
if liblapack_path == []
liblapack = dependency(liblapack_name, required : false)
endif
if liblapack_path != [] or not liblapack.found()
liblapack = fc.find_library(liblapack_name, dirs : liblapack_path, required : true)
endif
libmetis = fc.find_library(libmetis_name, dirs : libmetis_path, required : true)
libhwloc = fc.find_library(libhwloc_name, dirs : libhwloc_path, required : false)
libcuda = dependency('cuda', version : '>=10', modules : ['cublas'], required : false)
lm = cc.find_library('m', required : false)
libspral_deps = [libblas, liblapack, libmetis, libhwloc, libcuda, lm]
# CBLAS
has_cblash = cc.has_header('cblas.h', include_directories : libblas_include)
# METIS
if metis64
add_global_arguments('-DSPRAL_HAVE_METIS_H=1', language : 'fortran')
add_global_arguments('-DSIZEOF_IDX_T=8', language : 'fortran')
endif
# HWLOC
has_hwloch = cc.has_header('hwloc.h', include_directories : libhwloc_include)
if libhwloc.found() and has_hwloch
add_global_arguments('-DHAVE_HWLOC', language : 'cpp')
endif
# SCHED_GETCPU
if host_machine.system() == 'linux'
add_global_arguments('-DHAVE_SCHED_GETCPU', language : 'cpp')
endif
# HAVE_NVCC
if build_gpu and nvcc_available and libcuda.found()
add_global_arguments('-DHAVE_NVCC', language : 'cpp')
endif
# OpenMP
if build_openmp
if fc.get_id() == 'nvidia_hpc'
add_global_arguments('-mp', language : 'fortran')
elif fc.get_id() == 'nagfor'
add_global_arguments('-openmp', language : 'fortran')
elif fc.get_id() == 'gcc' or fc.get_id() == 'llvm-flang'
add_global_arguments('-fopenmp', language : 'fortran')
elif fc.get_id() == 'intel' or fc.get_id() == 'intel-llvm'
add_global_arguments('-qopenmp', language : 'fortran')
elif fc.get_id() == 'intel-cl' or fc.get_id() == 'intel-llvm-cl'
add_global_arguments('/Qopenmp', language : 'fortran')
endif
if cxx.get_id() == 'nvidia_hpc'
add_global_arguments('-mp', language : 'cpp')
elif cxx.get_id() == 'gcc' or cxx.get_id() == 'clang' or cxx.get_id() == 'clang-cl'
add_global_arguments('-fopenmp', language : 'cpp')
elif cxx.get_id() == 'intel' or cxx.get_id() == 'intel-llvm'
add_global_arguments('-qopenmp', language : 'cpp')
elif cxx.get_id() == 'intel-cl' or cxx.get_id() == 'intel-llvm-cl'
add_global_arguments('/Qopenmp', language : 'cpp')
endif
lomp = '-lgomp'
if cxx.get_id() == 'intel' or cxx.get_id() == 'intel-llvm'
lomp = '-liomp5'
endif
if cxx.get_id() == 'nvidia_hpc'
lomp = '-lomp'
endif
if host_machine.system() == 'darwin' or host_machine.system() == 'freebsd'
if cxx.get_id() == 'clang'
lomp = '-lomp'
endif
endif
add_global_link_arguments(lomp, language : 'fortran')
add_global_link_arguments(lomp, language : 'c')
add_global_link_arguments(lomp, language : 'cpp')
if nvcc_available
add_global_link_arguments(lomp, language : 'cuda')
endif
endif
binspral_src = []
libspral_src = []
libspral_c_src = []
libspral_cpp_src = []
libspral_nvcc_src = []
spral_examples = []
spral_c_examples = []
spral_tests = []
spral_c_tests = []
spral_cpp_tests = []
# Headers
spral_headers = []
libspral_include = []
libspral_include += include_directories('include', 'src')
libspral_include += libhwloc_include
libspral_include += libblas_include
# Sources
subdir('include')
subdir('interfaces/C')
subdir('src')
subdir('driver')
subdir('examples')
subdir('tests')
# Library
libspral = library('spral',
sources : libspral_src + libspral_c_src + libspral_cpp_src + libspral_nvcc_src,
dependencies : libspral_deps,
include_directories: libspral_include,
install : true)
# Binary
executable('spral_ssids',
sources : binspral_src,
dependencies : libcuda,
link_with : libspral,
install : true)
# Headers
install_headers(spral_headers)
# Fortran modules
if install_modules
script_modules = files('install_modules.py')
meson.add_install_script(script_modules)
endif
# OMP-related environment variables
omp_env = ['OMP_CANCELLATION=true', 'OMP_PROC_BIND=true']
# Tests
if build_tests
foreach test: spral_tests
package = test[0]
name = test[1]
file = test[2]
test(name,
executable(name, file,
link_with : libspral,
dependencies : libspral_deps,
include_directories: libspral_include),
suite : [package, 'tests', 'fortran'],
timeout : 300, is_parallel : false, env: omp_env)
endforeach
foreach test: spral_c_tests
package = test[0]
name = test[1]
file = test[2]
test(name,
executable(name, file,
link_with : libspral,
dependencies : libspral_deps,
include_directories : libspral_include),
suite : [package, 'tests', 'C'],
timeout : 300, is_parallel : false, env: omp_env)
endforeach
foreach test: spral_cpp_tests
package = test[0]
name = test[1]
file = test[2]
test(name,
executable(name, file,
link_with : libspral,
dependencies : libspral_deps,
include_directories : libspral_include),
suite : [package, 'tests', 'C++'],
timeout : 300, is_parallel : false, env: omp_env)
endforeach
endif
# Examples
if build_examples
fortran_examples_folder = 'examples/Fortran'
foreach example: spral_examples
package = example[0]
name = example[1]
file = example[2]
test(name,
executable(name, file,
link_with : libspral,
dependencies : libspral_deps,
include_directories : libspral_include,
install : true,
install_dir : fortran_examples_folder),
suite : [package, 'examples', 'fortran'],
timeout : 300, is_parallel : false, env: omp_env)
endforeach
c_examples_folder = 'examples/C'
foreach example: spral_c_examples
package = example[0]
name = example[1]
file = example[2]
test(name,
executable(name, file,
link_with : libspral,
dependencies : libspral_deps,
include_directories : libspral_include,
install : true,
install_dir : c_examples_folder),
suite : [package, 'examples', 'C'],
timeout : 300, is_parallel : false, env: omp_env)
endforeach
endif