Commit Graph

30 Commits

Author SHA1 Message Date
Robert Maynard
95700be52d CUDA: Teach CMake that NVCC 11 supports cuda_std_17 2020-06-10 13:27:51 -04:00
Brad King
d8eee80e30 Merge branch 'backport-cuda-default-runtime' into cuda-default-runtime 2020-05-22 06:50:19 -04:00
Robert Maynard
e55b21e24e CUDA: Compute CMAKE_CUDA_RUNTIME_LIBRARY default from toolchain
Since commit 0d0145138f (CUDA: Add abstraction for cuda runtime
selection, 2019-11-29, v3.17.0-rc1~83^2) we add CUDA runtime library
selection flags by default.

To maintain backwards compatibility the default CUDA runtime
library needs to be computed based on what libraries are found
on the initial compiler invocation. For example a toolchain
could establish initial flags that have all CUDA compilations
using the runtime version, and if we don't detect this we will
try to link to both the static and shared runtime.

Co-Author: Brad King <brad.king@kitware.com>
Fixes: #20708
2020-05-21 11:15:03 -04:00
Raul Tambre
5df21adf46 CUDA: Add support for Clang compiler
When crosscompiling we pass the sysroot.

We need to try various architecture flags. Clang doesn't automatically
select one that works.  First try the ones that are more likely to work
for modern installations:

* <=sm_50 is deprecated since CUDA 10.2, try sm_52 first for
          future compatibility.
* <=sm_20 is removed since CUDA 9.0, try sm_30.

Otherwise fallback to Clang's current default. Currently that's `sm_20`,
the lowest it supports.

Separable compilation isn't supported yet.

Fixes: #16586
2020-05-15 17:46:51 +03:00
Marc Chevrier
4248bb452a CUDA: Device linking use now link options
properties LINK_OPTIONS and INTERFACE_LINK_OPTIONS are propagated
to the device link step.

To control which options are selected for normal link and device link steps,
the $<DEVICE_LINK> and $<HOST_LINK> generator expressions can be used.

Fixes: #18265
2020-04-19 15:53:11 +02:00
Marc Chevrier
ec48e023f6 CUDA: Add information for LINKER: pattern translation 2020-04-19 15:04:56 +02:00
Raul Tambre
5f02add366 CUDA: Refactor PTX compilation flag into compiler modules 2020-04-07 09:33:25 -04:00
Raul Tambre
f75bea1071 CUDA: Abstract language flag to compiler modules
Separate this detail out into compiler-specific modules.
Required for Clang support, as it uses slightly different language flags.
2020-03-11 21:30:09 +02:00
Brad King
7da2c8c543 Merge branch 'backport-cuda-non-device-link' 2020-02-24 13:34:13 -05:00
Francisco Facioni
738f3f23aa Ninja: Do not use nvcc response files with non-nvcc tools
Since commit d91b5a72cd (Ninja: Add support for CUDA nvcc response
files, 2019-05-30, v3.15.0-rc1~8^2) we use NVCC's `--options-file`
option to avoid long link command lines via a response file.  However,
for non-device linking the host tools are used and the option does not
make sense.  Update the logic to use `--options-file` only for device
linking.  Linking with the host tools already has its own logic for
response files.

Fixes: #19954
2020-02-24 13:31:33 -05:00
Robert Maynard
0d0145138f CUDA: Add abstraction for cuda runtime selection
Fixes #17559
Replace our hard-coded default of cudart=static with a first-class abstraction to select the runtime library from an enumeration of logical names.
2020-01-27 16:02:26 -05:00
Raul Tambre
7560c68f2c CUDA: Fix compiler option version checks for nvcc 10.2.19 2020-01-03 14:15:03 +02:00
Robert Maynard
2467a2b318 CUDA: Add cuda meta-features (e.g. `cuda_std_11`) support 2019-12-10 17:56:48 -05:00
Robert Maynard
5341f5e4a1 CUDA: get header deps from compiler invocation when possible
Before CUDA 10.2 `nvcc` didn't support providing header dependency
information while compiling.
2019-11-29 14:21:35 -05:00
Robert Maynard
7f15c99851 CUDA: forward unknown flags to host compiler when possible.
Starting with CUDA 10.2 the nvcc compiler has gained support
to automatically forward unknown flags to the host compiler.

This behavior is highly desired as projcts that mix CUDA, C, C++
run into situation where flags such as `-pthread` which aren't
supported by nvcc, are being applied to all source files and
therefore break CUDA compilation.
2019-11-29 14:21:35 -05:00
Robert Maynard
a233e4e7d9 CUDA: Compilers can now state they don't require a device linking step 2019-08-06 15:44:15 -04:00
Francisco Facioni
d91b5a72cd Ninja: Add support for CUDA nvcc response files 2019-06-03 11:53:27 -04:00
Brad King
c765ae495a CMakeDetermineCompilerABI: pass verbose flag during compilation
Default to the same flag that is used for verbose link information, but
provide another internal platform information variable to use a
compilation-specific variant.  Populate it for CUDA where we use a
different compiler for compilation and linking and therefore need
different flags.

Co-Author: Chuck Cranor <chuck@ece.cmu.edu>
2019-01-21 11:14:08 -05:00
Brad King
f64732f59b CUDA: Do not pass unsupported @rspfile arguments to NVCC
The nvcc compiler does not support `@<rspfile>` arguments.  It does
offer a `--options-file` argument that can be investigated later.

Fixes: #17797
2018-03-07 10:30:35 -05:00
Robert Maynard
fe37b99473 CUDA: Add support for requesting C++98 under CUDA 9
Starting in CUDA 9 the default compilation mode is C++14, and you need
to explicitly enable C++98/03 mode.

While at it, document `14` among the values for `CUDA_STANDARD`.  This
was accidentally left out of commit v3.9.0-rc1~118^2 (CUDA: Add support
for the C++14 standard flag, 2017-05-11).
2017-09-26 11:08:09 -04:00
Robert Maynard
036ffe815a CUDA: Add support for the C++14 standard flag.
CUDA 9 toolkit has announced support for C++14 flag, so lets allow users
to use it.
2017-05-11 13:42:42 -04:00
Brad King
55fb46d273 CUDA: Fix default compiler flags on Windows
Fix the default values of `CMAKE_CUDA_FLAGS[_<CONFIG>]` on Windows to
make the host compiler flags match those produced for C++ by the
`Platform/Windows-MSVC` module.  This makes the flags consistent with
those used for C++.
2017-02-15 11:12:12 -05:00
Brad King
59ed323d46 CUDA: Do not use non-existent -Os flag for nvcc
Fix the CUDA MinSizeRel configuration flags to avoid using the `-Os`
flag that nvcc does not support.
2017-02-14 14:49:53 -05:00
Brad King
1155170230 CUDA: Populate NVIDIA compiler information on Windows
Port Windows-specific compilation and linking rules over from the
`Platform/Windows-MSVC` module and adapt it for NVIDIA CUDA.  On Windows
nvcc and its host compiler (MSVC) do not understand or use options like
`-fPIC` or `-std=`, so condition those out.
2017-01-12 10:39:04 -05:00
Brad King
7552d16d1a CUDA: Fix default compiler flag initialization
Since commit v3.7.0-rc1~392^2 (Honor CMAKE_<LANG>_FLAGS[_<CONFIG>]_INIT
set in toolchain files, 2016-07-05) our convention is to initialize
compiler flag variables via `string(APPEND)` rather than `set()`.
Fix the convention for `CMAKE_CUDA_FLAGS[_<CONFIG>]_INIT`.
2016-12-09 14:19:22 -05:00
Robert Maynard
5dec403103 CUDA: Refactor CMakeCUDAInformation to prepare for separable compilation. 2016-11-14 11:36:45 -05:00
Robert Maynard
489c52ce68 CUDA: Use the host compiler for linking CUDA executables and shared libs. 2016-11-14 11:36:44 -05:00
Robert Maynard
4f5155f6ab CUDA: We now properly perform CUDA compiler identification. 2016-11-14 11:36:43 -05:00
Robert Maynard
ce4ec876ce CUDA: Add support language levels (98/11) 2016-11-14 11:36:43 -05:00
Robert Maynard
f8aac21947 CUDA: Add basic CUDA language support for *NIX systems. 2016-11-14 11:36:42 -05:00