Commit Graph

119 Commits

Author SHA1 Message Date
Kitware Robot
0b96ae1f6a Revise C++ coding style using clang-format with "east const"
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`, now with "east const" enforcement.
Use `clang-format` version 18.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.

Issue: #26123
2025-01-23 13:09:50 -05:00
Alex Turbov
bc8621d999
Fix: A lot of typos in code found by typos
Yet another great code spellchecker: https://github.com/crate-ci/typos/

(Will be added later as a `pre-commit` hook)
2025-01-12 18:49:34 +04:00
Brad King
7d41427968 Merge topic 'test-cuda-bin2c-null'
0c1d290090 Tests: Ensure CUDA bin2c output is null terminated

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9917
2024-10-19 14:49:48 -04:00
Robert Maynard
0c1d290090 Tests: Ensure CUDA bin2c output is null terminated
The default behavior of bin2c is to create binary arrays that have no
null termination.  So to use it as a C array we need to explicitly tell
it to create valid null terminated strings.

This will safely allow us to run PTX tests across all CUDA drivers.
2024-10-18 11:05:10 -04:00
Brad King
eb00926123 Merge topic 'test-cuda-simplify-kernels'
ee9e2216ec Tests: Simplify CUDA kernels avoid crash with nvidia driver 550

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9913
2024-10-18 07:35:59 -04:00
Robert Maynard
ee9e2216ec Tests: Simplify CUDA kernels avoid crash with nvidia driver 550
Avoid having two identical kernels in PTX.  We don't need a second
kernel anyway.
2024-10-17 20:18:24 -04:00
Brad King
f93640b4c0 Merge topic 'test-cuda-optixir-includes'
c75e873564 CUDA: OptiXIR test includes all required headers

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9884
2024-10-08 08:47:02 -04:00
Robert Maynard
c75e873564
CUDA: OptiXIR test includes all required headers 2024-10-07 10:23:42 -04:00
Brad King
9e3b559b6a Tests: Update cmake_minimum_required versions to 3.10 2024-10-03 14:18:16 -04:00
Brad King
33406182a5 Tests: Honor CUDAFLAGS in all CUDA tests 2024-09-25 16:30:02 -04:00
Robert Maynard
b90ae10dda
Add support for unity builds with CUDA sources
Fixes #22750
2024-08-02 13:35:53 -04:00
Brad King
88c740462c CUDA/Clang: Add support for MSVC ABI on Windows using GNU-like frontend
Fixes: #20776
2024-01-22 09:33:54 -05:00
Brad King
607d271b1f Tests: Do not expect nvToolsExt in CUDA 12 toolkit 2024-01-18 14:27:29 -05:00
Brad King
5eb26fb943 Tests: Fix CudaOnly.Toolkit coverage of npp libs 2024-01-18 14:27:29 -05:00
Brad King
af85fa7ac1 Tests: Remove unused dllexport markup from CudaOnly.DeviceLTO
The test does not use shared libraries.
2024-01-18 14:27:29 -05:00
Brad King
d40bca5a8c Tests: Remove unused iostream from CUDA sources 2024-01-18 14:27:29 -05:00
Brad King
a9bb2606c1 Tests: Fix condition adding nvcc-only flags in CudaOnly.SeparateCompilation 2024-01-18 14:27:29 -05:00
Brad King
d901c4aa95 Merge topic 'FindCUDAToolkit-cupti'
04959e0285 Tests: Verify CUDA::cupti existence on a subset of machines
09a3c8b46b CUDAToolkit: Correctly search all include paths from compiler

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9072
2023-12-15 09:32:00 -05:00
Robert Maynard
04959e0285
Tests: Verify CUDA::cupti existence on a subset of machines
When we know that the cupti library exists explicitly request the CUDA Toolkit test to verify the existence
2023-12-14 14:05:28 -05:00
Robert Maynard
d7642a7d42
CUDA: Support CMAKE_TRY_COMPILE_TARGET_TYPE of STATIC_LIBRARY 2023-11-07 10:48:32 -05:00
Robert Maynard
4316d4dcfd FindCUDAToolkit: Search all of nvcc implicit includes and library dirs
Improves the handling of CUDA layouts where we have multiple include
and library directories listed in the output of `nvcc -v`. This
updates both when the CUDA language is enabled or not.

Fixes: #24915
2023-09-27 13:28:52 -04:00
Robert Maynard
cd984261e1
CUDA: Device linking now uses TARGET_OBJECTS content
Due to an oversight in cmLinkLineDeviceComputer object
files did not get propagate to the device linking phase
when given via the `$<TARGET_OBJECTS>` generator expression.
2023-09-25 08:50:38 -04:00
Robert Maynard
6ebff6ebf8 VS: Avoid unnecessary CUDA device linking for OBJECT libraries
Without `CudaLink` fields, MSBuild tries to perform a device link step
for object libraries with CUDA_SEPARABLE_COMPILATION on them even when
not needed.  This commonly was encountered when generating PTX or
OPTIX-IR output.
2023-09-11 16:49:35 -04:00
Rafael Stahl
45584508fa CUDA/NVIDIA: fix LTO with explicit architectures 2023-05-31 11:44:10 -04:00
Robert Maynard
4f10111e95 CUDA: Cuda* tests add rpath entry only for need cuda lib directory
Found when developing https://github.com/conda-forge/cuda-nvcc-feedstock/pull/13/
We previously added RPATH entries for all implicit directories and therefore
started to load the incorrect pthread library.
2023-05-22 15:37:35 -04:00
Brad King
7dffe99ad8 Tests: Restore CudaOnly.RuntimeControls cudart verification on Windows
Since commit fa45594407 (file(GET_RUNTIME_DEPENDENCIES): Preserve casing
for Windows PE binaries, 2023-03-06) we may find the cudart runtime
library with its on-disk casing instead of always lower-case.
2023-03-27 09:27:53 -04:00
Brad King
81237523b7 Tests: Teach CudaOnly.CUBIN to tolerate toolkit not supporting native arch
Since commit 2def6a874b (CUDA: Add support for CUBIN, FATBIN, and
OPTIXIR compilation, 2023-01-27) added this test, it has failed when
executed with a CUDA toolkit that does not support the true native
architecture of the GPU.  Detect this case and skip the test.
2023-03-16 10:55:36 -04:00
Brad King
35a3de7ab0 Tests: Add missing exit code to CudaOnly.{CUBIN,Fatbin} 2023-03-16 10:51:56 -04:00
Robert Maynard
2def6a874b CUDA: Add support for CUBIN, FATBIN, and OPTIXIR compilation 2023-03-13 09:54:00 -04:00
Robert Maynard
0c56bdf91e CUDA: device linking obeys CMAKE_CUDA_VISIBILITY_PRESET setting
Fixes #24272
2023-01-16 11:27:13 -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
f72c405d4e Merge topic 'ci-nvhpc'
16a5c36795 gitlab-ci: add nightly job testing NVHPC with Ninja on Linux
9474d02386 Tests: Clarify CudaOnly.SeparateCompilationPTX output

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7946
2022-11-29 10:39:40 -05:00
Robert Maynard
54d8044084 Tests: Don't presume that Linux CUDA Toolkits provide static libs 2022-11-23 09:27:42 -05:00
Brad King
9474d02386 Tests: Clarify CudaOnly.SeparateCompilationPTX output 2022-11-23 07:52:19 -05:00
Robert Maynard
62f13ed588 FindCUDAToolkit: Restore usage from multiple directories
Fixes #24119
2022-11-02 12:23:30 -04:00
Robert Maynard
d0e52219eb CUDA: Revert "Always mark cuda toolkit as system include"
We need to revert this change as it can disable error messages
when compiling invalid CUDA code.

This reverts commit ea659b155d (CUDA: Always mark cuda toolkit as system
include, 2022-06-27, v3.25.0-rc1~269^2).
2022-10-17 10:17:33 -04:00
Robert Maynard
ea659b155d CUDA: Always mark cuda toolkit as system include
Fixes: #23731
2022-08-18 10:37:06 -04:00
Robert Maynard
96bc59b1ca CUDA: Add Device LTO support for nvcc
Fixes #22200
2022-07-22 10:34:45 -04:00
Robert Maynard
e8591f1516 CUDA: native/all/all-major generates minimal set of ptx code
Fixes #23459
2022-05-03 11:52:23 -04:00
Brad King
8ef1fffa45 Merge topic 'ninja_compile_database_understand_new_cuda_lang_variables'
f7c6b9833c CUDA: Ninja generator generates valid compile database

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !7129
2022-03-31 08:47:25 -04:00
Robert Maynard
f7c6b9833c CUDA: Ninja generator generates valid compile database
The ninja generator has been updated to poperly write the compile
database when the CUDA language has been enabled.

Fixes #23368
2022-03-30 15:16:43 -04:00
Brad King
d1b48bfabd CUDA: Add support for CUDA_ARCHITECTURES=native
CUDA 11.6 added the `nvcc -arch=native` flag to automatically compile
for the host GPUs' architectures.  Add support for specifying this
special `native` value in `CMAKE_CUDA_ARCHITECTURES` and
`CUDA_ARCHITECTURES`.  During the compiler ABI detection step,
detect the native architectures so we can pass them explicitly
when using Clang or older versions of nvcc.

Fixes: #22375
2022-03-10 09:27:29 -05:00
Brad King
45e9ab0372 Tests: Rename CudaOnly.{All => ArchSpecial}
The purpose of the test is to cover special values of
`CMAKE_CUDA_ARCHITECTURES`.  Prepare to add more than
just `all` and `all-major`.

While at it, fix the `project()` name in the test to
match what we pass to `ctest` with `--build-project`.
2022-03-10 09:26:13 -05:00
Brad King
a7ef59c9c4 Tests: Fix CudaOnly.SeparateCompilationPTX test project name
Fix the test added by commit 61b9764b03 (CUDA: Allow both
CUDA_SEPARABLE_COMPILATION and CUDA_PTX_COMPILATION, 2021-09-17,
v3.23.0-rc1~516^2) to have a `project()` name matching what
is passed to CTest's `--build-project` option.  Otherwise, on
VS builds, MSBuild warns:

    MSBUILD : error MSB1009: Project file does not exist.

Other CUDA tests use a matching project name already.
2022-02-16 09:21:59 -05: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
unknown
574b492b47 CUDA: Visual Studio Generator propagates definitions for PTX files
From CUDA 9.0 to CUDA 11.4 the CUDA Visual Studio integration
defines omitted user defines from PTX generation.

With CUDA 11.5 this has been resolved, so we backport the fix
to allow for consistent behavior when using CMake
2021-12-14 14:55:48 -05:00
Robert Maynard
14d8a2768d CUDA: Support nvcc 11.5 new -arch=all|all-major flags 2021-11-01 14:57:58 -04:00
Robert Maynard
61b9764b03 CUDA: Allow both CUDA_SEPARABLE_COMPILATION and CUDA_PTX_COMPILATION
The target properties `CUDA_SEPARABLE_COMPILATION` and `CUDA_PTX_COMPILATION`
now aren't mutually exclusive and can now be used together on the same
target.
2021-10-20 11:18:06 -04:00
root
0b1cea66cd CUDA/Clang: Fix separable compilation in non-root directories with Makefiles
Seems the relative paths were wrong basically all around such that only
compiling files in the top-level directory would work. I've modified
CudaOnly.SeparateCompilation to cover this.

Fixes #22482.
2021-07-29 13:19:37 +03:00