Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/markdown/Dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,11 @@ set the path using `CUDA_PATH` explicitly.
Cuda does not honor the `prefer_static` option, and will link statically unless
the `static` keyword argument is set to `false`.

A special set of modules called `cudart`, `cudart_static` and `cudart_none` can
be used to control the Cuda Runtime used. If none of these are passed
`cudart_static` is automatically added unless the `static` keyword argument is
set to `false`, then `cudart` is chosen.

## CUPS

`method` may be `auto`, `config-tool`, `pkg-config`, `cmake` or `extraframework`.
Expand Down
4 changes: 4 additions & 0 deletions docs/markdown/snippets/cuda_dep_no_runtime.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## Cuda dependency with cudart_none

The Cuda dependency can now be initialize as `dependency('cuda', modules : ['cudart_none'])`,
which will result in no runtime. This is equivalent to `--cudart none` on the command line.
11 changes: 10 additions & 1 deletion mesonbuild/dependencies/cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .base import DependencyException, SystemDependency
from .detect import packages
from ..mesonlib import LibType
from ..interpreterbase import FeatureNew

if T.TYPE_CHECKING:
from ..environment import Environment
Expand All @@ -40,7 +41,10 @@ def __init__(self, environment: 'Environment', kwargs: DependencyObjectKWs) -> N
super().__init__('cuda', environment, kwargs, language=language)
self.lib_modules: T.Dict[str, T.List[str]] = {}
self.requested_modules = kwargs.get('modules', [])
if not any(runtime in self.requested_modules for runtime in ['cudart', 'cudart_static']):
if 'cudart_none' in self.requested_modules:
self.featurechecks.append(FeatureNew('Cuda module cudart_none', '1.10'))

if not any(runtime in self.requested_modules for runtime in ['cudart', 'cudart_static', 'cudart_none']):
# By default, we prefer to link the static CUDA runtime, since this is what nvcc also does by default:
# https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#cudart-none-shared-static-cudart
req_modules = ['cudart']
Expand Down Expand Up @@ -273,6 +277,10 @@ def _find_requested_libraries(self) -> bool:
all_found = True

for module in self.requested_modules:
if module == 'cudart_none':
self.lib_modules[module] = []
continue

# You should only ever link to libraries inside the cuda tree, nothing outside of it.
# For instance, there is a
#
Expand Down Expand Up @@ -319,6 +327,7 @@ def get_link_args(self, language: T.Optional[str] = None, raw: bool = False) ->
REWRITE_MODULES = {
'cudart': ['-cudart', 'shared'],
'cudart_static': ['-cudart', 'static'],
'cudart_none': ['-cudart', 'none'],
'cudadevrt': ['-cudadevrt'],
}

Expand Down
Loading