-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmeson.build
More file actions
243 lines (205 loc) · 7.67 KB
/
meson.build
File metadata and controls
243 lines (205 loc) · 7.67 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
project(
'biocma_mcst',
'cpp',
version: '0.9.75',
meson_version: '>= 1.3.0',
default_options: ['warning_level=3', 'b_colorout=always', 'cpp_std=c++20'],
)
build_type = get_option('buildtype')
python_install = get_option('python_install')
ci_execution = get_option('ci_execution')
use_dynamic_module = get_option('use_dynamic_module') # Use python module or not
use_cereal = get_option('use_cereal')
use_system_kokkos = get_option('use_system_kokkos')
build_test = get_option('build_test')
build_udf = get_option('build_udf')
use_cuda = get_option('use_cuda')
if not use_cuda and build_udf
add_project_arguments('-DUSE_UDF', language: 'cpp')
endif
add_global_arguments(
'-DEIGEN_NO_CUDA=1',
language: 'cpp',
)
# add_global_arguments('-DEIGEN_DONT_VECTORIZE=1', language: 'cpp')
arch_specific_args = []
compiler = meson.get_compiler('cpp')
if compiler.has_argument('-fno-math-errno')
arch_specific_args = [arch_specific_args, '-fno-math-errno']
endif
flto_flag = []
if compiler.has_argument('-flto')
flto_flag = [flto_flag, '-flto']
endif
if compiler.has_argument('-dlto')
flto_flag = [flto_flag, '-dlto']
endif
if compiler.has_argument('-march=native')
arch_specific_args = [arch_specific_args, '-march=native']
endif
if compiler.has_argument('-mtune=native')
arch_specific_args = [arch_specific_args, '-mtune=native']
endif
if compiler.has_argument('-Wno-interference-size')
# Disable cache line detection size
arch_specific_args = [arch_specific_args, '-Wno-interference-size']
endif
compiler.has_argument('-fopenmp')
#if (compiler.get_id() == 'clang')
#message('using clang')
## add_global_arguments(['-stdlib=libc++'], language: 'cpp')
## add_global_link_arguments(['-stdlib=libc++', '-lc++', '-lc++abi'], language: 'cpp')
#endif
## Define main shared variables
outdir = meson.current_build_dir()
root = meson.project_source_root()
project_name = meson.project_name()
cpp = meson.get_compiler('cpp')
if python_install
global_install_dir = get_option('prefix') + '/' + get_option('libdir')
else
global_install_dir = '/opt/biomc'
endif
use_python_define = '-DUSE_PYTHON_MODULE' # Define flag to pass to compiler if use_dynamic_module is true
## Get buildtype specific options
use_kokkos_tools = true
CMAKE_TYPE = 'Release'
if build_type == 'debug'
# NOTHING
CMAKE_TYPE = 'Debug'
add_global_arguments('-DDEBUG', language: 'cpp')
use_kokkos_tools = true
elif build_type == 'debugoptimized'
add_global_arguments('-DDEBUG', language: 'cpp')
use_kokkos_tools = true
else
add_global_arguments('-DNDEBUG', language: 'cpp')
if compiler.has_argument('-ffast-math')
arch_specific_args = [arch_specific_args, '-ffast-math']
endif
use_kokkos_tools = true
endif
cpp_args = [arch_specific_args]
if (use_kokkos_tools)
message('Kokkos tool enable')
cpp_args = [cpp_args, '-DENABLE_KOKKOS_PROFILING']
endif
no_mpi_flag = '-DNO_MPI'
mpi = dependency('mpi', language: 'cpp', required: true)
thread_dep = dependency('threads', required: true)
omp = dependency('openmp')
hwloc = dependency('hwloc')
blas = dependency('blas', required: false) # Eigen can work without BLAS
dl_dep = compiler.find_library('dl', required: true)
eigen_dep = subproject('eigen', required: true).get_variable('eigen_dep')
# if blas.found()
# add_global_arguments('-DEIGEN_USE_BLAS', language: 'cpp')
# endif
#add_global_arguments('-DEIGEN_DONT_PARALLELIZE',language:'cpp')
cmake = import('cmake', required: true)
if use_system_kokkos
__cmake_kokkos_dep__ = dependency(
'Kokkos',
method: 'cmake',
required: true,
components: ['kokkos'],
modules: ['Kokkos::kokkos'],
)
kokkos_compile_arg = ['-DKOKKOS_DEPENDENCE', '-Wno-unknown-pragmas']
if use_cuda
kokkos_compile_arg = [
kokkos_compile_arg,
'-extended-lambda',
'-Wext-lambda-captures-this',
'--expt-relaxed-constexpr',
]
endif
kokkos = declare_dependency(
dependencies: [__cmake_kokkos_dep__, omp, hwloc, thread_dep, dl_dep],
compile_args: kokkos_compile_arg,
)
else
kokkos_option = cmake.subproject_options()
kokkos_option.add_cmake_defines({'CMAKE_CXX_STANDARD': '20'})
kokkos_option.add_cmake_defines({'CMAKE_BUILD_TYPE': CMAKE_TYPE})
kokkos_option.add_cmake_defines({'Kokkos_ENABLE_OPENMP': 'ON'})
kokkos_option.add_cmake_defines({'Kokkos_ENABLE_HWLOC': 'ON'})
kokkos_option.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON'})
kokkos_option.add_cmake_defines({'Kokkos_ENABLE_DEPRECATED_CODE_4': 'OFF'})
kokkos_option.add_cmake_defines({'Kokkos_ENABLE_IMPL_VIEW_LEGACY': 'OFF'})
kokkos_option.set_install(false)
sub_kokkos = cmake.subproject('kokkos', required: true, options: kokkos_option)
kokkos = declare_dependency(
dependencies: [
sub_kokkos.dependency('kokkos'),
sub_kokkos.dependency('kokkoscore'),
sub_kokkos.dependency('kokkossimd'),
sub_kokkos.dependency('kokkoscontainers'),
sub_kokkos.dependency('kokkosalgorithms'),
omp,
hwloc,
thread_dep,
dl_dep,
],
)
endif
kokkos_sampling = dependency('kokkos_sampling-1.0', required: true)
if build_udf
dynlib_dep = dependency('dynlib-1.0', required: true)
endif
highfive_found = false
ceral_found = false
if cmake.found()
highfive_cmake_options = cmake.subproject_options()
highfive_cmake_options.add_cmake_defines({'CMAKE_CXX_STANDARD': '20'})
highfive_cmake_options.add_cmake_defines({'CMAKE_BUILD_TYPE': CMAKE_TYPE})
highfive_cmake_options.add_cmake_defines({'HIGHFIVE_USE_BOOST': false})
highfive_cmake_options.add_cmake_defines({'HIGHFIVE_EXAMPLES': false})
highfive_cmake_options.add_cmake_defines({'HIGHFIVE_UNIT_TESTS': false})
highfive_cmake_options.add_cmake_defines({'HIGHFIVE_USE_BOOST': false})
## MAYBE USE ?? IDK
highfive_cmake_options.add_cmake_defines({'HDF5_PREFER_PARALLEL': false})
highfive_cmake_options.add_cmake_defines({'HDF5_IS_PARALLEL': false})
highfive_cmake_options.set_install(false)
highfive_proj = cmake.subproject('highfive', options: highfive_cmake_options, required: false)
if highfive_proj.found()
hdf5 = dependency('hdf5', language: 'cpp', required: false)
if hdf5.found()
highfive_found = true
add_project_arguments('-DUSE_HIGHFIVE', language: 'cpp')
highfive_dependency = [
highfive_proj.dependency('HighFive'),
hdf5,
highfive_proj.dependency('HighFiveInclude'),
]
endif
endif
if use_cereal
cereal_cmake_options = cmake.subproject_options()
cereal_cmake_options.add_cmake_defines({'SKIP_PERFORMANCE_COMPARISON': true})
cereal_cmake_options.add_cmake_defines({'CMAKE_BUILD_TYPE': CMAKE_TYPE})
cereal_cmake_options.add_cmake_defines({'BUILD_DOC': false})
cereal_cmake_options.add_cmake_defines({'BUILD_SANDBOX': false})
cereal_cmake_options.add_cmake_defines({'BUILD_SANDBOX': false})
cereal_cmake_options.add_cmake_defines({'BUILD_TESTS': false})
cereal_cmake_options.set_install(false)
cereal_proj = cmake.subproject('cereal', options: cereal_cmake_options, required: false)
if cereal_proj.found()
#and not use_cuda
ceral_found = true
if compiler.has_argument('-Wno-missing-template-arg-list-after-template-kw')
cpp_args = [cpp_args, '-Wno-missing-template-arg-list-after-template-kw'] #FIXME needed with clang++-19
endif
add_project_arguments('-DUSE_CEAREAL', language: 'cpp')
cereal_dependency = cereal_proj.dependency('cereal')
endif
endif
endif
cma_dep = dependency('rcmtool', required: true, version: '>=0.1.0', static: true)
add_project_arguments(cpp_args, language: 'cpp')
subdir('apps')
_r = run_command('sh', '-c', f'ln -s @outdir@/compile_commands.json .', check: false)
subdir('tools')
if not python_install
meson.add_install_script('devutils/install_script.sh', result_dir)
endif