91 Commits

Author SHA1 Message Date
Robert Maynard
587c0443cc FindCUDAToolkit: Support CUDA version extraction from version.json
Fixes: #24858
2023-05-04 12:26:04 -04:00
Brad King
b548c7efa6 Merge topic 'FindCUDAToolkit-static-deps' into release-3.26
1d6c343661 FindCUDAToolkit: Add missing static library dependencies on pthread and libdl

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8422
2023-04-26 10:22:26 -04:00
Robert Maynard
1d6c343661 FindCUDAToolkit: Add missing static library dependencies on pthread and libdl
Discourse-topic: https://discourse.cmake.org/t/7946
2023-04-26 10:19:59 -04:00
Robert Maynard
11a9f88bdf FindCUDAToolkit: Fix nvrtc_static dependencies on Windows
Required for CUDA toolkit 11.5:

* https://docs.nvidia.com/cuda/archive/11.5.0/nvrtc/index.html#build-instruction
2023-04-25 13:37:19 -04:00
Brad King
038cd7f620 Merge topic 'FindCUDAToolkit-nvptxcompiler_static-deps' into release-3.26
8711231739 FindCUDAToolkit: nvptxcompiler_static correctly specify dependencies

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8395
2023-04-06 09:05:49 -04:00
Robert Maynard
516d807423 FindCUDAToolkit: Add dependency between cusparse and nvJitLink
Starting in CUDA 12.0 cusparse uses nvJitLink. As part of verifying this PR I also corrected the nvJitLink dependencies
2023-04-05 11:37:06 -04:00
Robert Maynard
8711231739 FindCUDAToolkit: nvptxcompiler_static correctly specify dependencies
Avoids linking to `Threads::Threads` on non-unix systems where it isn't needed. In addition ensures that dlopen symbols are resolved.
2023-04-05 10:57:55 -04:00
Paul Taylor
9688a8ebc2 FindCUDAToolkit: Fix nvrtc_builtins_static library name
Update the change from commit 2a94c762ed (FindCUDAToolkit: Add support
for CUDA::nvrtc_static, 2023-01-20, v3.26.0-rc1~55^2).  The lib is named
`libnvrtc-builtins_static.a`, not `libnvrtc_builtins_static.a`.
2023-02-06 09:36:43 -05:00
Robert Maynard
2a94c762ed FindCUDAToolkit: Add support for CUDA::nvrtc_static 2023-01-20 12:05:43 -05:00
Robert Maynard
743d4181b4 FindCUDAToolkit: Support cross-compilation to sbsa-linux
Fixes #24192
2023-01-11 11:27:37 -05:00
Robert Maynard
e60fa80fbe FindCUDAToolkit: Handle CUDA::nvToolsExt not existing 2023-01-11 11:27:37 -05:00
Robert Maynard
d37d9c098c FindCUDAToolkit: Support the new nvJitLink library in CUDA 12 2022-12-12 13:28:50 -05:00
Robert Maynard
9d012b1f69 FindCUDAToolkit: Ensure that paths provided have no symlinks
Fixes: #24188
2022-11-30 16:39:00 -05:00
Brad King
9b9a421668 Merge topic 'find_cuda_toolkit_support_symlink_math_dirs'
989d50d7fc FindCUDAToolkit: Support nvhpc splayed layouts without symlinks
207518b6e8 FindCUDAToolkit: Handle CUDAToolkit_TARGET_DIR dir being a symlink

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7945
2022-11-23 07:11:59 -05:00
Robert Maynard
989d50d7fc FindCUDAToolkit: Support nvhpc splayed layouts without symlinks 2022-11-22 09:02:08 -05:00
Brad King
66b64b5984 Merge topic 'FindCUDAToolkit_handle_nvptxcompiler_static_not_existing'
c7ece269da FindCUDAToolkit: Handle toolkits that don't provide nvptxcompiler

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7932
2022-11-18 09:23:36 -05:00
Robert Maynard
207518b6e8 FindCUDAToolkit: Handle CUDAToolkit_TARGET_DIR dir being a symlink 2022-11-18 08:42:04 -05:00
Robert Maynard
c7ece269da FindCUDAToolkit: Handle toolkits that don't provide nvptxcompiler
Some versions of the CUDA toolkit don't provide any static
libraries, and therefore we need to handle that `nvptxcompiler_static`
might not be found
2022-11-17 13:41:11 -05:00
Robert Maynard
6f707ab541 FindCUDAToolkit: Support math_libs directory being a symlink
Fixes #24140
2022-11-09 16:04:00 -05:00
Robert Maynard
62f13ed588 FindCUDAToolkit: Restore usage from multiple directories
Fixes #24119
2022-11-02 12:23:30 -04:00
Robert Maynard
301815eb62 FindCUDAToolkit: Add nvptxcompiler_static dependency on Threads::Threads 2022-10-31 11:48:09 -04:00
Robert Maynard
eefba0fb02 FindCUDAToolkit: cuFile_rdma_static needs to link to cuFile_static 2022-10-12 13:26:05 -04:00
Brad King
9adb3fb733 Merge topic 'add_nvptx_compiler_to_findCUDAToolkit' into release-3.25
01cfd0163d FindCUDAToolkit: Add support for the nvptx compiler library

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7779
2022-10-12 09:22:11 -04:00
Robert Maynard
01cfd0163d FindCUDAToolkit: Add support for the nvptx compiler library
Fixes #23892
2022-10-11 10:35:50 -04:00
Robert Maynard
ce6de038d9 FindCUDAToolkit: Add support for the cuFile library 2022-10-11 09:27:26 -04:00
Brad King
f6813c4159 Merge topic 'findCUDAToolkit_declare_deps_for_targets_once'
f0918fe505 FindCUDAToolkit: Correctly state cusolver and cublas dependencies

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7633
2022-09-07 09:38:01 -04:00
Robert Maynard
f0918fe505 FindCUDAToolkit: Correctly state cusolver and cublas dependencies
Fixes #23920
2022-09-02 12:24:40 -04:00
Craig Scott
7198d12d5e Merge topic 'correct_cupti_search_paths'
1f3c3589f1 FindCUDAToolkit: Search the cuda toolkit include path for cupti

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7608
2022-08-26 06:50:40 -04:00
Robert Maynard
1f3c3589f1 FindCUDAToolkit: Search the cuda toolkit include path for cupti 2022-08-24 09:49:10 -04:00
Raul Tambre
cd200c6c2d FindCUDAToolkit: nvtx3 target
nvtx3 is a header-only replacement for the previous shared library
implementations.

I implemented it as a separate target since while the header names match and
ideally it should be API compatible, forcing its include directory into the old
target would lengthen the include search path and could cause confusion or
possible build differences for projects using multiple build systems. This
keeps it explicit as a developer opt-in.

Implements: #21377
Resolves: #23835
2022-08-13 23:52:42 +03:00
Peter Bell
e6b51a1b01 CUDAToolkit: Add include paths for CUDA::cupti
CUDA's cupti library has its headers in a seperate directory on a
standard CUDA install, but `CUDA::cupti` only adds the default cuda
include directory.

Issue: #22761
2022-04-26 13:48:02 -04:00
Robert Maynard
3e7113e644 FindCUDAToolkit: Add missing cufftw_static target
Fixes #23347
2022-03-21 09:40:17 -04:00
Raul Tambre
8f64df0a7c CUDA: Generic all and all-major support
Commit 14d8a276 (CUDA: Support nvcc 11.5 new -arch=all|all-major flags,
2021-08-17) added all and all-major options to CUDA_ARCHITECTURES. These are
fairly generic and likely to see real-world use by distributors. Thus it's
desirable to support these also for Clang and older NVCC versions.

The supported architectures are dependent on the toolkit version. We determine
the toolkit version prior to compiler detection. For NVCC we get the version
from the vendor identification output, but for Clang we need to invoke NVCC
separately.

The architecture information is mostly based on the Wikipedia list with the
earliest supported version being CUDA 7.0. This could be documented and
expanded in the future to allow projects to query CUDA toolkit version and
architecture information.
For Clang we additionally constrain based on its support.

Additionally the architecture mismatch detection logic is fixed, improved and
updated for generic support:
* Commit 01428c55 (CUDA: Fail fast if CMAKE_CUDA_ARCHITECTURES doesn't work
  during detection, 2020-08-29) enabled CMAKE_CUDA_COMPILER_ID_REQUIRE_SUCCESS
  if CMAKE_CUDA_ARCHITECTURES is specified. This results in
  CMakeDetermineCompilerID.cmake printing the compiler error and our code for
  presenting the mismatch in a user-friendly way being useless. The custom
  logic seems preferable so go back to not enabling it.
* Commit 14d8a276 (CUDA: Support nvcc 11.5 new -arch=all|all-major flags,
  2021-08-17) tried to support CMP0054 but forgot to add x to the interpolated
  result. Thus the conditions would always evaluate to false. This is fixed as
  a byproduct of removing NVIDIA specific checks, improving the error message
  and replacing architectures_mode with a simpler architectures_explicit.

Visual Studio support omits testing the flags during detection due to
complexities in determining the toolkit version when using it.
A long-term proper implementation would be #23161.

Implements #22860.
2022-02-01 18:25:20 +02:00
Guo
5067b6b6ee FindCUDAToolkit: Remove duplicated targets in docs
Also remove an unfinished sentence.
2022-01-24 14:02:58 -05:00
Brad King
a20d9e1463 Merge topic 'cudatoolkit_find_cufft_static_nocallback'
a4126d1c01 CUDAToolkit: Add CUDA::cufft_static_nocallback target

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Raul Tambre <raul@tambre.ee>
Merge-request: !6856
2022-01-13 15:24:39 -05:00
Robert Maynard
a4126d1c01 CUDAToolkit: Add CUDA::cufft_static_nocallback target
Fixes: #23098
2022-01-12 16:04:02 -05:00
Robert Maynard
9e6c26b75c FindCUDAToolkit: depend cublas on cublasLt for CUDA 11.0+ 2022-01-12 15:06:49 -05:00
Robert Maynard
fedca357d2 FindCUDAToolkit: Correct cusparse dependencies for 10.1, 11.2.2 2021-11-19 13:54:40 -05:00
Steven Hahn
32574814c7 FindCUDAToolkit: Fix missing sibling include directory for math libraries
Fixes: #22706
2021-10-05 14:44:39 -04:00
Robert Maynard
d856aaa37d FindCUDAToolkit: Understand NVHPC versioned math library layout
The NVHPC packages bundle the CUDA math libraries in a sibling
directory (`math_libs`) instead of in with the rest of the
cuda libraries.

Depending on the NVHPC package the math_libs folder can have
versioned subdirectories, therefore we prefer finding the
same versions as the CUDA Toolkit and falling back to the
latest when not possible.
2021-07-28 13:49:44 -04:00
Brad King
1c6d09768f Merge topic 'FindCUDAToolkit-doc-version'
266fc8ada5 FindCUDAToolkit: Properly document the version support

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6320
2021-07-08 07:53:52 -04:00
Robert Maynard
266fc8ada5 FindCUDAToolkit: Properly document the version support 2021-07-07 13:42:08 -04:00
Brad King
8bfc96d5ed Merge topic 'correct_cuda_toolkit_version_typo'
0d54276c82 Correct CUDAToolkit_VERSION_MINOR variable name typo

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Raul Tambre <raul@tambre.ee>
Merge-request: !6311
2021-07-07 09:29:06 -04:00
Robert Maynard
0d54276c82 Correct CUDAToolkit_VERSION_MINOR variable name typo 2021-07-06 08:43:13 -04:00
Dan Ibanez
d930145841 FindCUDATookit: Fix ordering of libraries in imported targets
Before this a downstream code linking to `CUDA::cusparse_static` and
`CUDA::curand_static` would get a link line with `libcusparse_static.a`,
then `libculibos.a`, then `libcurand_static.a`.  Use `IMPORTED_LOCATION`
to tell CMake about the proper dependency ordering where `libculibos.a`
comes last, because the other two libraries depend on `libculibos.a`.

Fixes: #22365
2021-07-01 12:18:27 -04:00
Robert Maynard
5e931c5a97 CUDA: improve regex for CUDA Toolkit root from nvcc verbose output
The original regular expression was greedy and would match any
environment variable ending with `TOP` (like `DESKTOP`). This is an
issue on windows where `nvcc -v` would output all environment variables
before the compiler's verbose output.

To resolve this issue we use a tighter match algorithm that looks
for `#$ TOP=` instead of `TOP=`.

Fixes: #22158
2021-05-06 12:08:24 -04:00
Brad King
9ea66b2d86 CUDA: Capture all nvcc output when extracting toolkit root
Since commit fb2afef620 (CUDA: Support nvcc symlinking to ccache,
2021-01-07) and commit 3cef91a321 (CUDA: Always extract CUDA Toolkit
root from nvcc verbose output, 2021-02-03) we always run the command
`nvcc -v __cmake_determine_cuda` to look for the toolkit root in its
stderr.  On Windows, that command may print to stdout instead, so
capture that as well.
2021-02-12 07:23:48 -05:00
Brad King
bb68658e98 Merge topic 'findcudatoolkit_handle_cuda_compiler_without_enabled_lang'
cd89d1c328 FindCUDAToolkit: Robust version checks when CUDA lang is not enabled

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Raul Tambre <raul@tambre.ee>
Tested-by: Raul Tambre <raul@tambre.ee>
Merge-request: !5787
2021-02-10 07:48:50 -05:00
Robert Maynard
cd89d1c328 FindCUDAToolkit: Robust version checks when CUDA lang is not enabled
Previously if you set `CMAKE_CUDA_COMPILER` but hadn't enabled
the CUDA language, FindCUDAToolkit would not correctly compute
the version information.
2021-02-09 09:39:20 -05:00
Robert Maynard
3cef91a321 CUDA: Always extract CUDA Toolkit root from nvcc verbose output
Fixes #21750, #21763

Given that NVCC can be provided by multiple different sources (NVIDIA HPC SDK, CUDA Toolkit, distro)
each of which has a different layout, we need to extract the CUDA toolkit root from the compiler
itself, allowing us to support numerious different scattered toolkit layouts.

The NVIDIA HPC SDK specifically ships two copies of nvcc one in
`compilers/bin/` and one in `cuda/bin`. Thus when using
`compilers/bin/nvcc` the Toolkit root logic fails.
2021-02-08 12:13:01 -08:00