Skip to content

Commit 53f6553

Browse files
committed
dependencies/cuda: Add support for disabling the cuda runtime
1 parent 1e7f6f0 commit 53f6553

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

docs/markdown/Dependencies.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,11 @@ additional toolkit libraries that need to be explicitly linked to. If the
388388
CUDA Toolkit cannot be found in the default paths on your system, you can
389389
set the path using `CUDA_PATH` explicitly.
390390

391+
A special set of modules called `cudart`, `cudart_static` and `cudart_none` can
392+
be used to control the Cuda Runtime used. If none of these are passed
393+
`cudart_static` is automatically added unless the `static` keyword argument is
394+
set to `false`, then `cudart` is chosen.
395+
391396
## CUPS
392397

393398
`method` may be `auto`, `config-tool`, `pkg-config`, `cmake` or `extraframework`.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## Cuda dependency with cudart_none
2+
3+
The Cuda dependency can no be initialize as `dependency('cuda', modules : ['cudart_none'])`,
4+
which will result in no runtime. This is equivalent to `--cudart none` on the command line.

mesonbuild/dependencies/cuda.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from .base import DependencyException, SystemDependency
1515
from .detect import packages
1616
from ..mesonlib import LibType
17+
from ..interpreterbase import FeatureNew
1718

1819
if T.TYPE_CHECKING:
1920
from ..environment import Environment
@@ -39,7 +40,10 @@ def __init__(self, environment: 'Environment', kwargs: T.Dict[str, T.Any]) -> No
3940
super().__init__('cuda', environment, kwargs, language=language)
4041
self.lib_modules: T.Dict[str, T.List[str]] = {}
4142
self.requested_modules = self.get_requested(kwargs)
42-
if not any(runtime in self.requested_modules for runtime in ['cudart', 'cudart_static']):
43+
if 'cudart_none' in self.requested_modules:
44+
self.featurechecks.append(FeatureNew('Cuda module cudart_none', '1.10'))
45+
46+
if not any(runtime in self.requested_modules for runtime in ['cudart', 'cudart_static', 'cudart_none']):
4347
# By default, we prefer to link the static CUDA runtime, since this is what nvcc also does by default:
4448
# https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#cudart-none-shared-static-cudart
4549
req_modules = ['cudart']
@@ -322,6 +326,7 @@ def get_link_args(self, language: T.Optional[str] = None, raw: bool = False) ->
322326
REWRITE_MODULES = {
323327
'cudart': ['-cudart', 'shared'],
324328
'cudart_static': ['-cudart', 'static'],
329+
'cudart_none': ['-cudart', 'none'],
325330
'cudadevrt': ['-cudadevrt'],
326331
}
327332

0 commit comments

Comments
 (0)