-
Notifications
You must be signed in to change notification settings - Fork 277
Expand file tree
/
Copy pathmeson.build
More file actions
432 lines (378 loc) · 16.7 KB
/
meson.build
File metadata and controls
432 lines (378 loc) · 16.7 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
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
project('nixl', 'CPP', version: '1.0.1',
default_options: ['buildtype=release',
'werror=true',
'cpp_std=c++17',
'prefix=/opt/nvidia/nvda_nixl'],
meson_version: '>= 0.64.0'
)
enable_plugins_opt = get_option('enable_plugins')
disable_plugins_opt = get_option('disable_plugins')
is_explicit_enable = enable_plugins_opt != ''
if enable_plugins_opt != '' and disable_plugins_opt != ''
error('Cannot specify both enable_plugins and disable_plugins options')
endif
all_plugins = ['UCX', 'LIBFABRIC', 'POSIX', 'OBJ', 'GDS', 'GDS_MT', 'MOONCAKE', 'HF3FS', 'GUSLI', 'GPUNETIO', 'UCCL', 'AZURE_BLOB']
enabled_plugins = {}
if enable_plugins_opt != ''
enabled_plugins_list = []
foreach p : enable_plugins_opt.split(',')
p_stripped = p.strip()
if p_stripped not in all_plugins
error('Requested plugin "' + p_stripped + '" is not available. Available plugins are: ' + ', '.join(all_plugins))
endif
enabled_plugins_list += [p_stripped]
endforeach
foreach plugin : all_plugins
enabled_plugins += {plugin: plugin in enabled_plugins_list}
endforeach
message('Building only selected plugins: ' + enable_plugins_opt)
elif disable_plugins_opt != ''
disabled_plugins_list = []
foreach p : disable_plugins_opt.split(',')
p_stripped = p.strip()
if p_stripped not in all_plugins
error('Cannot exclude unknown plugin "' + p_stripped + '". Available plugins are: ' + ', '.join(all_plugins))
endif
disabled_plugins_list += [p_stripped]
endforeach
foreach plugin : all_plugins
enabled_plugins += {plugin: plugin not in disabled_plugins_list}
endforeach
message('Building all plugins except: ' + disable_plugins_opt)
else
foreach plugin : all_plugins
enabled_plugins += {plugin: true}
endforeach
message('Building all available plugins')
endif
# set up some global vars for compiler, platform, configuration, etc.
cpp = meson.get_compiler('cpp')
fs = import('fs')
dl_dep = cpp.find_library('dl', required: true)
rt_dep = cpp.find_library('rt', required: true)
thread_dep = dependency('threads')
# Check for libaio (for LINUX AIO plugin and test)
has_linux_aio = false
linux_aio_dep = cpp.find_library('aio', required: false)
if linux_aio_dep.found()
has_linux_aio = cpp.has_function('io_setup', prefix: '#include <libaio.h>', dependencies: [linux_aio_dep])
endif
# Check for liburing
has_io_uring = false
io_uring_dep = dependency('liburing', required: false)
if io_uring_dep.found()
has_io_uring = cpp.has_function('io_uring_queue_init_params', prefix: '#include <liburing.h>', dependencies: [io_uring_dep])
endif
# Check for POSIX aio
has_posix_aio = cpp.has_function('aio_cancel', prefix: '#include <aio.h>', dependencies: [rt_dep])
# Check whether the POSIX plugin is enabled
has_posix_plugin = has_linux_aio or has_io_uring or has_posix_aio
# Check for CUObject Client library
cuobj_dep = dependency('cuobjclient-13.1', required: false)
if cuobj_dep.found()
add_project_arguments('-DHAVE_CUOBJ_CLIENT', language: ['cpp'])
endif
# Forced to ignore this error due to:
# https://github.com/abseil/abseil-cpp/issues/1779
# This must be global since subprojects cannot be assigned with arguments.
# Adding this configuration only for release build to consider it while developing.
if get_option('buildtype') == 'release'
abseil_flags = cpp.get_supported_arguments('-Wno-error=maybe-uninitialized', '-Wno-maybe-uninitialized')
add_global_arguments(abseil_flags, language: 'cpp')
endif
# Search for Abseil dependencies in the system first
absl_base_dep = dependency('absl_base', required: false)
absl_log_dep = dependency('absl_log', required: false)
absl_log_initialize_dep = dependency('absl_log_initialize', required: false)
absl_flat_hash_map_dep = dependency('absl_flat_hash_map', required: false)
absl_status_dep = dependency('absl_status', required: false)
absl_statusor_dep = dependency('absl_statusor', required: false)
absl_strings_dep = dependency('absl_strings', required: false)
absl_synchronization_dep = dependency('absl_synchronization', required: false)
absl_time_dep = dependency('absl_time', required: false)
if absl_base_dep.found() and not absl_log_dep.found()
error('Your Abseil version is too old: found absl_base but missing support for absl_log. ' +
'Cannot fallback to subproject because that would result in a mix of Abseil versions at runtime. ' +
'Please install a recent Abseil from source on your system and remove old libabsl & libabsl-dev packages.')
endif
if not (absl_log_dep.found() and
absl_log_initialize_dep.found() and
absl_flat_hash_map_dep.found() and
absl_status_dep.found() and
absl_statusor_dep.found() and
absl_strings_dep.found() and
absl_synchronization_dep.found() and
absl_time_dep.found())
message('System Abseil missing required components; using subproject fallback')
abseil_proj = subproject('abseil-cpp')
absl_log_dep = abseil_proj.get_variable('absl_log_dep')
absl_log_initialize_dep = absl_log_dep
absl_flat_hash_map_dep = abseil_proj.get_variable('absl_container_dep')
absl_status_dep = abseil_proj.get_variable('absl_status_dep')
absl_statusor_dep = absl_status_dep
absl_strings_dep = abseil_proj.get_variable('absl_strings_dep')
absl_synchronization_dep = abseil_proj.get_variable('absl_synchronization_dep')
absl_time_dep = abseil_proj.get_variable('absl_time_dep')
summary({'Abseil source': 'subproject'}, section: 'Dependencies')
else
message('Using system Abseil dependencies')
summary({'Abseil source': 'system'}, section: 'Dependencies')
endif
taskflow_proj = dependency('taskflow', fallback: ['taskflow', 'taskflow_dep'])
cuda_inc_path = get_option('cudapath_inc')
cuda_lib_path = get_option('cudapath_lib')
cuda_stub_path = get_option('cudapath_stub')
if cuda_lib_path == ''
cuda_dep = dependency('cuda', required : false, modules : [ 'cudart', 'cuda' ])
if not cuda_dep.found()
# Meson is not detecting CUDA reliably on ARM, fallback to default
cuda_home = run_command('bash', '-c', 'echo $CUDA_HOME').stdout().strip()
if cuda_home == ''
cuda_home = '/usr/local/cuda'
endif
cuda_lib = cuda_home + '/lib64'
cuda_inc = cuda_home + '/include'
cuda_stub = cuda_lib + '/stubs'
if fs.exists(cuda_lib) and fs.exists(cuda_inc)
cuda_dep = declare_dependency(
link_args : ['-L' + cuda_lib, '-L' + cuda_stub, '-lcuda', '-lcudart'],
include_directories : include_directories(cuda_inc))
if cuda_dep.found()
message('Found CUDA installation through fallback method:', cuda_home)
endif
endif
endif
else
message('cuda lib path ', cuda_lib_path)
if cuda_stub_path == ''
cuda_stub_path = cuda_lib_path + '/stubs'
endif
cuda_dep = declare_dependency(
link_args : ['-L' + cuda_lib_path, '-L' + cuda_stub_path, '-lcuda', '-lcudart'],
include_directories : include_directories(cuda_inc_path))
endif
if cuda_dep.found()
add_languages('CUDA')
cuda = import('unstable-cuda')
nvcc = meson.get_compiler('cuda')
# Please extend with your arch if not present in the list
nvcc_flags = []
# nixl ep cannot be built with sm_80
if not get_option('build_nixl_ep')
nvcc_flags += ['-gencode', 'arch=compute_80,code=sm_80']
endif
nvcc_flags += ['-gencode', 'arch=compute_90,code=sm_90']
add_project_arguments(nvcc_flags, language: 'cuda')
# Refer to https://mesonbuild.com/Cuda-module.html
add_project_arguments('-forward-unknown-to-host-compiler', language: 'cuda')
add_project_arguments('-rdc=true', language: 'cuda')
nvcc_flags_link = []
# nixl ep cannot be built with sm_80
if not get_option('build_nixl_ep')
nvcc_flags_link += ['-gencode=arch=compute_80,code=sm_80']
endif
nvcc_flags_link += ['-gencode=arch=compute_90,code=sm_90']
add_project_link_arguments(nvcc_flags_link, language: 'cuda')
message('nvcc version: ' + nvcc.version())
if nvcc.version().version_compare('>=12.8')
doca_gpunetio_dep = dependency('doca-gpunetio', required : false)
else
warning('GPUNETIO plugin not supported in CUDA version: ' + nvcc.version())
doca_gpunetio_dep = disabler()
endif
# Set the Python CUDA-specific wheel directory
cuda_version_major = nvcc.version().split('.')[0]
if cuda_version_major == '12'
cuda_wheel_dir = 'nixl_cu12'
elif cuda_version_major == '13'
cuda_wheel_dir = 'nixl_cu13'
else
error('Unsupported CUDA version: ' + cuda_version_major)
endif
else
warning('CUDA not found. UCX backend will be built without CUDA support, and some plugins will be disabled.')
doca_gpunetio_dep = disabler()
warning('CUDA not found, cannot autodetect wheel dir; defaulting to nixl_cu12')
cuda_wheel_dir = 'nixl_cu12'
endif
# Check for etcd-cpp-api - use multiple methods for discovery
etcd_dep = dependency('etcd-cpp-api', required : false)
etcd_inc_path = get_option('etcd_inc_path')
etcd_lib_path = get_option('etcd_lib_path')
if not etcd_dep.found() and etcd_lib_path != ''
etcd_lib = cpp.find_library('etcd-cpp-api', dirs: etcd_lib_path)
if etcd_lib.found()
if cpp.has_header('Client.hpp', args : '-I' + etcd_inc_path)
etcd_inc = include_directories(etcd_inc_path, is_system: true)
etcd_dep = declare_dependency(
include_directories : etcd_inc,
dependencies : etcd_lib)
break
endif
endif
endif
if etcd_dep.found()
add_project_arguments('-DHAVE_ETCD', language: 'cpp')
else
message('ETCD CPP API library not found, will disable etcd support')
endif
prefix_path = get_option('prefix')
prefix_inc = prefix_path + '/include'
ucx_path = get_option('ucx_path')
if ucx_path != ''
ucx_lib_path = ucx_path + '/lib'
ucx_inc_path = ucx_path + '/include'
# Check if path is absolute
if ucx_inc_path.startswith('/')
ucx_dep = declare_dependency(
link_args : ['-L' + ucx_lib_path, '-lucp', '-lucs', '-luct'],
compile_args : ['-I' + ucx_inc_path])
else
ucx_dep = declare_dependency(
link_args : ['-L' + ucx_lib_path, '-lucp', '-lucs', '-luct'],
include_directories : include_directories(ucx_inc_path))
endif
else
ucx_dep = dependency('ucx', modules: ['ucx::ucs', 'ucx::ucp', 'ucx::uct'], required: false)
endif
libfabric_path = get_option('libfabric_path')
if libfabric_path != ''
libfabric_lib_path = libfabric_path + '/lib'
libfabric_inc_path = libfabric_path + '/include'
# Check if path is absolute
if libfabric_inc_path.startswith('/')
libfabric_dep = declare_dependency(
link_args : ['-L' + libfabric_lib_path, '-lfabric'],
compile_args : ['-I' + libfabric_inc_path])
else
libfabric_dep = declare_dependency(
link_args : ['-L' + libfabric_lib_path, '-lfabric'],
include_directories : include_directories(libfabric_inc_path))
endif
else
libfabric_dep = dependency('libfabric', required: false)
endif
# UCX GPU device API detection
nvcc_prog = find_program('nvcc', required: false)
ucx_gpu_device_api_available = false
if ucx_dep.found() and cuda_dep.found() and nvcc_prog.found()
cuda = meson.get_compiler('cuda')
# TODO: Expose doca_gpunetio_dep through UCX
have_gpu_side = cuda.compiles('''
#include <ucp/api/device/ucp_device_impl.h>
int main() { return 0; }
''', dependencies : [ucx_dep, doca_gpunetio_dep], args: nvcc_flags)
have_host_side = cpp.has_function('ucp_device_remote_mem_list_create',
prefix: '#include <ucp/api/device/ucp_host.h>',
dependencies: ucx_dep)
if have_gpu_side and have_host_side
ucx_gpu_device_api_available = true
add_project_arguments('-DHAVE_UCX_GPU_DEVICE_API', language: ['cpp', 'cuda'])
endif
summary({
'UCX GPU Device API' : ucx_gpu_device_api_available,
'GPU-side compile' : have_gpu_side,
'Host-side compile' : have_host_side,
'nvcc available' : nvcc_prog.found(),
'DOCA GPUNETIO found' : doca_gpunetio_dep.found(),
}, section: 'UCX GPU Device API', bool_yn: true)
endif
if get_option('disable_gds_backend')
add_project_arguments('-DDISABLE_GDS_BACKEND', language: 'cpp')
endif
# Configure NDEBUG for release builds
if get_option('buildtype') == 'release'
# Used by Abseil to strip DCHECK assertions and DVLOG at compile time
add_project_arguments('-DNDEBUG', language: 'cpp')
endif
static_plugins = []
# Check for static plugins, then set compiler flags to enable
if get_option('static_plugins') != ''
static_plugins = get_option('static_plugins').split(',')
foreach p : static_plugins
flagname = '-DSTATIC_PLUGIN_' + p
add_project_arguments(flagname, language: 'cpp')
endforeach
endif
# Define a specific plugin directory
plugin_install_dir = join_paths(get_option('libdir'), 'plugins')
plugin_build_dir = meson.current_build_dir()
# Add to global args so plugin managers can find it
if get_option('buildtype') == 'debug'
add_project_arguments('-DNIXL_USE_PLUGIN_FILE="' + plugin_build_dir + '/pluginlist"', language: 'cpp')
plugfile = join_paths(plugin_build_dir, 'pluginlist')
run_command('truncate', '-s 0', plugfile, check: true)
endif
nixl_inc_dirs = include_directories('src/api/cpp', 'src/api/cpp/backend', 'src/infra', 'src/core', 'src/core/telemetry')
nixl_gpu_inc_dirs = include_directories('src/api/gpu/ucx')
plugins_inc_dirs = include_directories('src/plugins')
utils_inc_dirs = include_directories('src/utils')
subdir('src')
if get_option('build_tests') and get_option('buildtype') != 'release'
subdir('test')
endif
# nixl_ep currently lives under examples/device/ep. Build that subtree when
# either full examples are requested or nixl_ep is explicitly requested.
if get_option('build_examples') or get_option('build_nixl_ep')
subdir('examples')
endif
if get_option('install_headers')
install_headers('src/api/cpp/nixl.h', install_dir: prefix_inc)
install_headers('src/api/cpp/nixl_types.h', install_dir: prefix_inc)
install_headers('src/api/cpp/nixl_params.h', install_dir: prefix_inc)
install_headers('src/api/cpp/nixl_descriptors.h', install_dir: prefix_inc)
install_headers('src/utils/serdes/serdes.h', install_dir: prefix_inc + '/utils/serdes')
install_headers('src/utils/common/nixl_time.h', install_dir: prefix_inc + '/utils/common')
install_headers('src/utils/common/nixl_log.h', install_dir: prefix_inc + '/utils/common')
install_headers('src/api/cpp/backend/backend_engine.h', install_dir: prefix_inc + '/backend')
install_headers('src/api/cpp/backend/backend_aux.h', install_dir: prefix_inc + '/backend')
install_headers('src/api/cpp/backend/backend_plugin.h', install_dir: prefix_inc + '/backend')
install_headers('src/core/transfer_request.h', install_dir: prefix_inc)
install_headers('src/core/agent_data.h', install_dir: prefix_inc)
install_headers('src/infra/mem_section.h', install_dir: prefix_inc)
install_headers('src/core/telemetry/telemetry_event.h', install_dir: prefix_inc)
if ucx_gpu_device_api_available
install_headers('src/api/gpu/ucx/nixl_device.cuh', install_dir: prefix_inc + '/gpu/ucx')
endif
endif
# Doxygen documentation
if get_option('build_docs')
doxygen = find_program('doxygen', required: false)
if not doxygen.found()
error('Doxygen not found, but documentation requested')
endif
docs_dir = join_paths(meson.current_build_dir(), 'docs')
doxyfile = join_paths(meson.current_source_dir(), 'Doxyfile')
doxygen_output_dir = join_paths(docs_dir, 'doxygen')
# Create the output directory
run_command('mkdir', '-p', doxygen_output_dir, check: true)
# Configure Doxyfile with the correct output directory
configure_file(
input: doxyfile,
output: 'Doxyfile.configured',
configuration: {
'DOXYGEN_OUTPUT_DIR': doxygen_output_dir,
}
)
custom_target('docs',
output: 'docs',
command: [doxygen, join_paths(meson.current_build_dir(), 'Doxyfile.configured')],
install: true,
install_dir: join_paths(prefix_path),
build_by_default: true
)
endif