Skip to content

Commit 01da329

Browse files
committed
BUILD: add nvcc_gencode option for CUDA architectures
1 parent 787dd7b commit 01da329

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

meson.build

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,20 @@ if cuda_dep.found()
6767
cuda = import('unstable-cuda')
6868
nvcc = meson.get_compiler('cuda')
6969

70-
# Please extend with your arch if not present in the list
7170
nvcc_flags = []
72-
nvcc_flags += ['-gencode', 'arch=compute_80,code=sm_80']
73-
nvcc_flags += ['-gencode', 'arch=compute_90,code=sm_90']
71+
nvcc_flags_link = []
72+
if get_option('nvcc_gencode') != ''
73+
foreach p : get_option('nvcc_gencode').split(' ')
74+
nvcc_flags += p
75+
nvcc_flags_link += p
76+
endforeach
77+
endif
7478
add_project_arguments(nvcc_flags, language: 'cuda')
79+
add_project_link_arguments(nvcc_flags_link, language: 'cuda')
7580

7681
# Refer to https://mesonbuild.com/Cuda-module.html
7782
add_project_arguments('-forward-unknown-to-host-compiler', language: 'cuda')
7883
add_project_arguments('-rdc=true', language: 'cuda')
79-
80-
nvcc_flags_link = []
81-
nvcc_flags_link += ['-gencode=arch=compute_80,code=sm_80']
82-
nvcc_flags_link += ['-gencode=arch=compute_90,code=sm_90']
83-
add_project_link_arguments(nvcc_flags_link, language: 'cuda')
8484
endif
8585

8686
# DOCA

meson_options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ option('gds_path', type: 'string', value: '/usr/local/cuda/', description: 'Path
2323
option('cudapath_inc', type: 'string', value: '', description: 'Include path for CUDA')
2424
option('cudapath_lib', type: 'string', value: '', description: 'Library path for CUDA')
2525
option('cudapath_stub', type: 'string', value: '', description: 'Extra Stub path for CUDA')
26+
option('nvcc_gencode', type: 'string', value: '-gencode=arch=compute_80,code=sm_80 -gencode=arch=compute_90,code=sm_90',
27+
description: 'NVCC GPU architectures to target (space-separated -gencode flags)')
2628
option('static_plugins', type: 'string', value: '', description: 'Plugins to be built-in, comma-separated')
2729
option('build_docs', type: 'boolean', value: false, description: 'Build Doxygen documentation')
2830
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)')

0 commit comments

Comments
 (0)