From 0bc66721b723d8883af84d1f21b7d7b7171b2b8b Mon Sep 17 00:00:00 2001 From: Michal Shalev Date: Sun, 24 Aug 2025 11:21:19 +0300 Subject: [PATCH 1/6] BUILD: add nvcc_gencode option for CUDA architectures --- meson.build | 16 ++++++++-------- meson_options.txt | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/meson.build b/meson.build index 658fe97cd..f17f2cf6f 100644 --- a/meson.build +++ b/meson.build @@ -67,20 +67,20 @@ if cuda_dep.found() cuda = import('unstable-cuda') nvcc = meson.get_compiler('cuda') - # Please extend with your arch if not present in the list nvcc_flags = [] - nvcc_flags += ['-gencode', 'arch=compute_80,code=sm_80'] - nvcc_flags += ['-gencode', 'arch=compute_90,code=sm_90'] + nvcc_flags_link = [] + if get_option('nvcc_gencode') != '' + foreach p : get_option('nvcc_gencode').split(' ') + nvcc_flags += p + nvcc_flags_link += p + endforeach + endif add_project_arguments(nvcc_flags, language: 'cuda') + add_project_link_arguments(nvcc_flags_link, 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 = [] - nvcc_flags_link += ['-gencode=arch=compute_80,code=sm_80'] - nvcc_flags_link += ['-gencode=arch=compute_90,code=sm_90'] - add_project_link_arguments(nvcc_flags_link, language: 'cuda') endif # DOCA diff --git a/meson_options.txt b/meson_options.txt index 08c5785e4..b8fe8d97e 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -23,6 +23,8 @@ option('gds_path', type: 'string', value: '/usr/local/cuda/', description: 'Path option('cudapath_inc', type: 'string', value: '', description: 'Include path for CUDA') option('cudapath_lib', type: 'string', value: '', description: 'Library path for CUDA') option('cudapath_stub', type: 'string', value: '', description: 'Extra Stub path for CUDA') +option('nvcc_gencode', type: 'string', value: '-gencode=arch=compute_80,code=sm_80 -gencode=arch=compute_90,code=sm_90', + description: 'NVCC GPU architectures to target (space-separated -gencode flags)') option('static_plugins', type: 'string', value: '', description: 'Plugins to be built-in, comma-separated') option('build_docs', type: 'boolean', value: false, description: 'Build Doxygen documentation') option('log_level', type: 'combo', choices: ['trace', 'debug', 'info', 'warning', 'error', 'fatal', 'auto'], value: 'auto', description: 'Log Level (auto: auto-detect based on build type: trace for debug builds, info for release builds)') From 07321e70741e29975573b5b092ee69ecf5f6e996 Mon Sep 17 00:00:00 2001 From: Michal Shalev Date: Tue, 26 Aug 2025 01:24:56 +0300 Subject: [PATCH 2/6] make nvcc_gencode an array of flags --- meson.build | 11 ++--------- meson_options.txt | 9 +++++++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/meson.build b/meson.build index f17f2cf6f..dcf85a004 100644 --- a/meson.build +++ b/meson.build @@ -67,16 +67,9 @@ if cuda_dep.found() cuda = import('unstable-cuda') nvcc = meson.get_compiler('cuda') - nvcc_flags = [] - nvcc_flags_link = [] - if get_option('nvcc_gencode') != '' - foreach p : get_option('nvcc_gencode').split(' ') - nvcc_flags += p - nvcc_flags_link += p - endforeach - endif + nvcc_flags = get_option('nvcc_gencode') add_project_arguments(nvcc_flags, language: 'cuda') - add_project_link_arguments(nvcc_flags_link, language: 'cuda') + add_project_link_arguments(nvcc_flags, language: 'cuda') # Refer to https://mesonbuild.com/Cuda-module.html add_project_arguments('-forward-unknown-to-host-compiler', language: 'cuda') diff --git a/meson_options.txt b/meson_options.txt index b8fe8d97e..2daefdce6 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -23,8 +23,13 @@ option('gds_path', type: 'string', value: '/usr/local/cuda/', description: 'Path option('cudapath_inc', type: 'string', value: '', description: 'Include path for CUDA') option('cudapath_lib', type: 'string', value: '', description: 'Library path for CUDA') option('cudapath_stub', type: 'string', value: '', description: 'Extra Stub path for CUDA') -option('nvcc_gencode', type: 'string', value: '-gencode=arch=compute_80,code=sm_80 -gencode=arch=compute_90,code=sm_90', - description: 'NVCC GPU architectures to target (space-separated -gencode flags)') +option('nvcc_gencode', + type : 'array', + value : [ + '-gencode=arch=compute_80,code=sm_80', + '-gencode=arch=compute_90,code=sm_90', + ], + description : 'NVCC GPU architectures to target (list of -gencode flags)') option('static_plugins', type: 'string', value: '', description: 'Plugins to be built-in, comma-separated') option('build_docs', type: 'boolean', value: false, description: 'Build Doxygen documentation') option('log_level', type: 'combo', choices: ['trace', 'debug', 'info', 'warning', 'error', 'fatal', 'auto'], value: 'auto', description: 'Log Level (auto: auto-detect based on build type: trace for debug builds, info for release builds)') From e81b1feac15b79c6b84fd35cceaaa641c8b5b9a8 Mon Sep 17 00:00:00 2001 From: Michal Shalev Date: Wed, 17 Sep 2025 12:07:21 +0300 Subject: [PATCH 3/6] Replace custom nvcc_gencode option with meson built-in cuda_args support Signed-off-by: Michal Shalev --- README.md | 30 ++++++++++++++++++++++++++++++ meson.build | 25 ++++++++++++++++++++++--- meson_options.txt | 7 ------- 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 60562389d..5d1ddce78 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,11 @@ $ meson setup \ -Ducx_path=/path/to/ucx \ # Custom UCX installation path -Dinstall_headers=true \ # Install development headers -Ddisable_gds_backend=false # Enable GDS backend + +# CUDA GPU architecture targeting (example) +$ meson setup \ + -Dcuda_args="-gencode=arch=compute_80,code=sm_80,-gencode=arch=compute_90,code=sm_90" \ + -Dcuda_link_args="-gencode=arch=compute_80,code=sm_80,-gencode=arch=compute_90,code=sm_90" ``` Common build options: @@ -135,6 +140,31 @@ Common build options: - `disable_gds_backend`: Disable GDS backend (default: false) - `cudapath_inc`, `cudapath_lib`: Custom CUDA paths - `static_plugins`: Comma-separated list of plugins to build statically +- `cuda_args`: CUDA compiler arguments (default: targets compute_80 and compute_90) +- `cuda_link_args`: CUDA linker arguments (default: targets compute_80 and compute_90) + +### CUDA GPU Architecture Configuration + +NIXL automatically targets CUDA compute capabilities 8.0 (Ampere) and 9.0 (Hopper) by default. To target specific GPU architectures or add additional ones, use the `cuda_args` and `cuda_link_args` options: + +```bash +# Target specific architectures +$ meson setup build \ + -Dcuda_args="-gencode=arch=compute_75,code=sm_75" \ + -Dcuda_link_args="-gencode=arch=compute_75,code=sm_75" + +# Target multiple architectures +$ meson setup build \ + -Dcuda_args="-gencode=arch=compute_75,code=sm_75,-gencode=arch=compute_80,code=sm_80,-gencode=arch=compute_90,code=sm_90" \ + -Dcuda_link_args="-gencode=arch=compute_75,code=sm_75,-gencode=arch=compute_80,code=sm_80,-gencode=arch=compute_90,code=sm_90" +``` + +Common CUDA compute capabilities: +- `compute_75,code=sm_75`: NVIDIA Turing (RTX 20xx, Tesla T4) +- `compute_80,code=sm_80`: NVIDIA Ampere (A100, RTX 30xx) +- `compute_86,code=sm_86`: NVIDIA Ampere (RTX 30xx consumer) +- `compute_89,code=sm_89`: NVIDIA Ada Lovelace (RTX 40xx) +- `compute_90,code=sm_90`: NVIDIA Hopper (H100) ### Building Documentation diff --git a/meson.build b/meson.build index dcf85a004..031249f06 100644 --- a/meson.build +++ b/meson.build @@ -67,9 +67,28 @@ if cuda_dep.found() cuda = import('unstable-cuda') nvcc = meson.get_compiler('cuda') - nvcc_flags = get_option('nvcc_gencode') - add_project_arguments(nvcc_flags, language: 'cuda') - add_project_link_arguments(nvcc_flags, language: 'cuda') + # Set default CUDA architectures if not specified by user + # Users can override with: -Dcuda_args="-gencode=arch=compute_XX,code=sm_XX" + default_cuda_args = [ + '-gencode=arch=compute_80,code=sm_80', + '-gencode=arch=compute_90,code=sm_90' + ] + default_cuda_link_args = [ + '-gencode=arch=compute_80,code=sm_80', + '-gencode=arch=compute_90,code=sm_90' + ] + + # Apply defaults only if user hasn't specified custom args + cuda_args_option = get_option('cuda_args') + cuda_link_args_option = get_option('cuda_link_args') + + if cuda_args_option == [] + add_project_arguments(default_cuda_args, language: 'cuda') + endif + + if cuda_link_args_option == [] + add_project_link_arguments(default_cuda_link_args, language: 'cuda') + endif # Refer to https://mesonbuild.com/Cuda-module.html add_project_arguments('-forward-unknown-to-host-compiler', language: 'cuda') diff --git a/meson_options.txt b/meson_options.txt index 2daefdce6..08c5785e4 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -23,13 +23,6 @@ option('gds_path', type: 'string', value: '/usr/local/cuda/', description: 'Path option('cudapath_inc', type: 'string', value: '', description: 'Include path for CUDA') option('cudapath_lib', type: 'string', value: '', description: 'Library path for CUDA') option('cudapath_stub', type: 'string', value: '', description: 'Extra Stub path for CUDA') -option('nvcc_gencode', - type : 'array', - value : [ - '-gencode=arch=compute_80,code=sm_80', - '-gencode=arch=compute_90,code=sm_90', - ], - description : 'NVCC GPU architectures to target (list of -gencode flags)') option('static_plugins', type: 'string', value: '', description: 'Plugins to be built-in, comma-separated') option('build_docs', type: 'boolean', value: false, description: 'Build Doxygen documentation') option('log_level', type: 'combo', choices: ['trace', 'debug', 'info', 'warning', 'error', 'fatal', 'auto'], value: 'auto', description: 'Log Level (auto: auto-detect based on build type: trace for debug builds, info for release builds)') From ad6e1e9c8fde26b45c65e7982b96c39b7f6b1a09 Mon Sep 17 00:00:00 2001 From: Michal Shalev Date: Wed, 1 Oct 2025 04:27:05 +0300 Subject: [PATCH 4/6] PR fixes Signed-off-by: Michal Shalev --- README.md | 7 ++++--- meson.build | 21 +++++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 9b3352f09..c23a6c06a 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,8 @@ Common build options: ### CUDA GPU Architecture Configuration -NIXL automatically targets CUDA compute capabilities 8.0 (Ampere) and 9.0 (Hopper) by default. To target specific GPU architectures or add additional ones, use the `cuda_args` and `cuda_link_args` options: +NIXL automatically targets CUDA compute capabilities 8.0 (Ampere) and 9.0 (Hopper) by default. +To target specific GPU architectures or add additional ones, use the `cuda_args` and `cuda_link_args` options: ```bash # Target specific architectures @@ -143,8 +144,8 @@ $ meson setup build \ # Target multiple architectures $ meson setup build \ - -Dcuda_args="-gencode=arch=compute_75,code=sm_75,-gencode=arch=compute_80,code=sm_80,-gencode=arch=compute_90,code=sm_90" \ - -Dcuda_link_args="-gencode=arch=compute_75,code=sm_75,-gencode=arch=compute_80,code=sm_80,-gencode=arch=compute_90,code=sm_90" + -Dcuda_args="-gencode=arch=compute_75,code=sm_75 -gencode=arch=compute_80,code=sm_80 -gencode=arch=compute_90,code=sm_90" \ + -Dcuda_link_args="-gencode=arch=compute_75,code=sm_75 -gencode=arch=compute_80,code=sm_80 -gencode=arch=compute_90,code=sm_90" ``` Common CUDA compute capabilities: diff --git a/meson.build b/meson.build index bd99040cf..1bdeaee27 100644 --- a/meson.build +++ b/meson.build @@ -82,31 +82,32 @@ else endif if cuda_dep.found() - add_languages('CUDA') + add_languages('cuda') cuda = import('unstable-cuda') nvcc = meson.get_compiler('cuda') # Set default CUDA architectures if not specified by user - # Users can override with: -Dcuda_args="-gencode=arch=compute_XX,code=sm_XX" - default_cuda_args = [ + # Users can override with cuda_args and cuda_link_args options + # See README.md for details and examples + cuda_args_option = get_option('cuda_args') + cuda_link_args_option = get_option('cuda_link_args') + + cuda_args = [ '-gencode=arch=compute_80,code=sm_80', '-gencode=arch=compute_90,code=sm_90' ] - default_cuda_link_args = [ + cuda_link_args = [ '-gencode=arch=compute_80,code=sm_80', '-gencode=arch=compute_90,code=sm_90' ] # Apply defaults only if user hasn't specified custom args - cuda_args_option = get_option('cuda_args') - cuda_link_args_option = get_option('cuda_link_args') - if cuda_args_option == [] - add_project_arguments(default_cuda_args, language: 'cuda') + add_project_arguments(cuda_args, language: 'cuda') endif if cuda_link_args_option == [] - add_project_link_arguments(default_cuda_link_args, language: 'cuda') + add_project_link_arguments(cuda_link_args, language: 'cuda') endif # Refer to https://mesonbuild.com/Cuda-module.html @@ -182,7 +183,7 @@ if ucx_dep.found() and cuda_dep.found() and nvcc_prog.found() have_gpu_side = cuda.compiles(''' #include int main() { return 0; } - ''', dependencies : ucx_dep, args: nvcc_flags) + ''', dependencies : ucx_dep, args: cuda_args) have_host_side = cpp.compiles(''' #include From addcabd85e93775fe2feae841e402f261b39e9b7 Mon Sep 17 00:00:00 2001 From: Michal Shalev Date: Wed, 1 Oct 2025 04:33:41 +0300 Subject: [PATCH 5/6] PR fixes 2.0 Signed-off-by: Michal Shalev --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c23a6c06a..2108a0062 100644 --- a/README.md +++ b/README.md @@ -117,8 +117,8 @@ $ meson setup \ # CUDA GPU architecture targeting (example) $ meson setup \ - -Dcuda_args="-gencode=arch=compute_80,code=sm_80,-gencode=arch=compute_90,code=sm_90" \ - -Dcuda_link_args="-gencode=arch=compute_80,code=sm_80,-gencode=arch=compute_90,code=sm_90" + -Dcuda_args="-gencode=arch=compute_80,code=sm_80 -gencode=arch=compute_90,code=sm_90" \ + -Dcuda_link_args="-gencode=arch=compute_80,code=sm_80 -gencode=arch=compute_90,code=sm_90" ``` Common build options: From 807c8e8efcb32b8db4660a19c751bdd88b410694 Mon Sep 17 00:00:00 2001 From: Michal Shalev Date: Mon, 6 Oct 2025 13:44:01 +0300 Subject: [PATCH 6/6] Fix meson build default logic and update sm90 in README Signed-off-by: Michal Shalev --- README.md | 2 +- meson.build | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2108a0062..9dd30f804 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ Common CUDA compute capabilities: - `compute_80,code=sm_80`: NVIDIA Ampere (A100, RTX 30xx) - `compute_86,code=sm_86`: NVIDIA Ampere (RTX 30xx consumer) - `compute_89,code=sm_89`: NVIDIA Ada Lovelace (RTX 40xx) -- `compute_90,code=sm_90`: NVIDIA Hopper (H100) +- `compute_90,code=sm_90`: NVIDIA Hopper (H100, H800, H200) ### Building Documentation diff --git a/meson.build b/meson.build index 148ae4b96..4c5ae1fa6 100644 --- a/meson.build +++ b/meson.build @@ -92,22 +92,29 @@ if cuda_dep.found() cuda_args_option = get_option('cuda_args') cuda_link_args_option = get_option('cuda_link_args') - cuda_args = [ + # Define default architectures + default_cuda_args = [ '-gencode=arch=compute_80,code=sm_80', '-gencode=arch=compute_90,code=sm_90' ] - cuda_link_args = [ + default_cuda_link_args = [ '-gencode=arch=compute_80,code=sm_80', '-gencode=arch=compute_90,code=sm_90' ] # Apply defaults only if user hasn't specified custom args if cuda_args_option == [] + cuda_args = default_cuda_args add_project_arguments(cuda_args, language: 'cuda') + else + cuda_args = [] endif if cuda_link_args_option == [] + cuda_link_args = default_cuda_link_args add_project_link_arguments(cuda_link_args, language: 'cuda') + else + cuda_link_args = [] endif # Refer to https://mesonbuild.com/Cuda-module.html