summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineCUDACompiler.cmake
Commit message (Collapse)AuthorAgeFilesLines
* CUDA: Support nvcc 11.5 new -arch=all|all-major flagsRobert Maynard2021-11-011-8/+30
|
* CUDA: Fix detection of implicit link information with CUDA 6.5samuel100u2021-09-301-2/+3
| | | | Fixes: #22701
* CUDA: Extract nvvm libdevice location from compiler verbose outputRobert Maynard2021-07-221-2/+17
| | | | | Depending on the CUDA installation the nvvm/libdevice folder can be in different locations. Since `nvcc` outputs the expected location use that when possible.
* Merge topic 'improve_cuda_toolkit_extraction_regex'Brad King2021-05-071-1/+1
|\ | | | | | | | | | | | | | | 5e931c5a97 CUDA: improve regex for CUDA Toolkit root from nvcc verbose output Acked-by: Kitware Robot <kwrobot@kitware.com> Reviewed-by: Raul Tambre <raul@tambre.ee> Merge-request: !6094
| * CUDA: improve regex for CUDA Toolkit root from nvcc verbose outputRobert Maynard2021-05-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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
| * Merge topic 'better_cuda_compiler_detection_error_messages' into release-3.20Brad King2021-02-241-5/+5
| |\ | | | | | | | | | | | | | | | | | | | | | a0fc64ac24 CUDA: Improve error messages when CUDA compiler detection fails Acked-by: Kitware Robot <kwrobot@kitware.com> Reviewed-by: Raul Tambre <raul@tambre.ee> Merge-request: !5844
* | | CUDA: Add CMAKE_CUDA_HOST_COMPILER support on Windows non-VS generatorsunknown2021-04-221-6/+9
| | |
* | | CUDA: Add support for finding nvcc in CUDA_PATHTobias Ribizel2021-03-151-0/+2
| | | | | | | | | | | | | | | | | | Previously, nvcc needed to be present in PATH or specified by CUDACXX. On Windows with vcpkg, the PATH is heavily modified, which lead to nvcc not being found with the Ninja generator.
* | | Merge topic 'better_cuda_compiler_detection_error_messages'Brad King2021-02-241-5/+5
|\ \ \ | |/ / |/| / | |/ | | | | | | | | a0fc64ac24 CUDA: Improve error messages when CUDA compiler detection fails Acked-by: Kitware Robot <kwrobot@kitware.com> Reviewed-by: Raul Tambre <raul@tambre.ee> Merge-request: !5844
| * CUDA: Improve error messages when CUDA compiler detection failsRobert Maynard2021-02-231-5/+5
| |
* | CUDA: Capture all nvcc output when extracting toolkit rootBrad King2021-02-121-3/+4
|/ | | | | | | | | 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.
* CUDA: Always extract CUDA Toolkit root from nvcc verbose outputRobert Maynard2021-02-081-13/+11
| | | | | | | | | | | | 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.
* CUDA: Support nvcc symlinking to ccacheRong Ou2021-01-111-1/+14
| | | | | | | Invoke `nvcc -v` to find the real CUDA bin directory. This is needed if `nvcc` is a symlink to `ccache` or `colornvcc`. Fixes: #21177
* CUDA: Initialize CMAKE_CUDA_ARCHITECTURES using $ENV{CUDAARCHS}Raul Tambre2020-11-301-0/+4
| | | | | | | NVCC's default architecture may be newer than the one supported by the machine's GPU. In such cases it's useful to have an environment variable for initializing CMAKE_CUDA_ARCHITECTURES to avoid specifying it for every invocation.
* CUDA: Error if can't determine toolkit library rootRaul Tambre2020-11-221-0/+2
| | | | | | | Finding the toolkit is required for Clang and is assumed to have been correctly found by FindCUDAToolkit if the CUDA language is found. Error out early with an useful error instead of failing later on due to the path not being set.
* CUDA: Clang CUDA 11.1 supportRaul Tambre2020-11-221-4/+4
| | | | | | | | | version.txt is gone from CUDA 11.1 installations, but the rest is the same. Instead of looking for version.txt look for <CUDA path>/nvvm/libdevice, which is the main thing that Clang requires (though it also checks for the existence of bin and include). Fixes #21353.
* CUDA: Clang separable compilationRaul Tambre2020-09-241-2/+14
| | | | | | | | | | | | For NVCC the compiler takes care of device linking when passed the "-dlink" flag. Clang doesn't support such magic and requires the buildsystem to do the work that NVCC does behind the scenes. The implementation is based on Bazel's device linking documentation: https://github.com/tensorflow/tensorflow/blob/7cabcdf073abad8c46e9dda62bb8fa4682d2061e/third_party/nccl/build_defs.bzl.tpl#L259 Closes: #20726
* CUDA: Support scattered installations when crosscompiling with ClangRaul Tambre2020-09-141-2/+5
| | | | | | | Previously when CMAKE_CROSSCOMPILING was ON we'd end up not setting the target directory if the non-scattered one didn't exist. Fix this by assuming a scattered installation if the target directory isn't set after the crosscompiling logic.
* CUDA: Fail fast if CMAKE_CUDA_ARCHITECTURES doesn't work during detectionRaul Tambre2020-08-291-18/+19
| | | | | Also re-ordered the code to avoid testing flags for other compilers, since we know the vendor before full detection.
* CUDA: Fail if compiler detection using the host compiler failsRaul Tambre2020-08-291-0/+4
| | | | | | | | | | | | | | | | | | | If an user specified a host compiler we should fail if we are unable to perform compiler detection with it. Previously we would try without and likely succeed and continue. Then we'd fail during ABI detection and compiler testing since we'd still try to use it. This is particularly problematic when crosscompiling since we extract the host linker from the compiler detection link line. This would result in the wrong host linker being used and a linking error due to architecture mismatch during ABI detection where other necessary flags may already be present to make the host compiler work. See #21076 for an example. Fix this by adding CMAKE_<LANG>_COMPILER_ID_REQUIRE_SUCCESS to CMakeDetermineCompilerId, which throws a fatal error if executing the compiler results in a non-zero exit code. Fixes #21120.
* Toolchain: Capture all arguments from CMAKE_<LANG>_COMPILERFred Baksik2020-07-231-1/+1
| | | | | | | | | | | Capture CMAKE_<LANG>_COMPILER_ARG1 from CMAKE_<LANG>_COMPILER in the same fashion that it is from $ENV{<LANG>}. Since get_filename_component() returns a single string of all the arguments from $ENV{<LANG>}, a single string of arguments will be constructed from the items contained in CMAKE_<LANG>_COMPILER. Fixes #20089
* Fix typos identified using codespellJean-Christophe Fillion-Robin2020-07-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | See https://github.com/codespell-project/codespell#readme The following command was used: ``` codespell -q6 --skip="\ .git,\ *.json,\ ./Copyright.txt,\ ./Help/command/foreach.rst,\ ./Help/prop_test/REQUIRED_FILES.rst,\ ./Help/variable/CTEST_COVERAGE_COMMAND.rst,\ ./Modules/CMakeCheckCompilerFlagCommonPatterns.cmake,\ ./Modules/CMakeRCInformation.cmake,\ ./Modules/Internal/CPack/NSIS.template.in,\ ./Modules/FindMatlab.cmake,\ ./Modules/MatlabTestsRedirect.cmake,\ ./Modules/Platform/Windows-Clang.cmake,\ ./Modules/Platform/Windows-Intel-Fortran.cmake,\ ./Modules/Platform/Windows-MSVC.cmake,\ ./Source/CMakeVersion.cmake,\ ./Source/cmConvertMSBuildXMLToJSON.py,\ ./Source/cmCreateTestSourceList.cxx,\ ./Source/cmGlobalVisualStudio10Generator.cxx,\ ./Source/cmExportBuildFileGenerator.cxx,\ ./Source/cmExportInstallAndroidMKGenerator.cxx,\ ./Source/cmExportInstallFileGenerator.cxx,\ ./Source/cmExportSet.cxx,\ ./Source/cmExportTryCompileFileGenerator.cxx,\ ./Source/cmFindPackageCommand.cxx,\ ./Source/cmInstallCommand.cxx,\ ./Source/cmGeneratorExpressionLexer.cxx,\ ./Source/cmLocalVisualStudio7Generator.cxx,\ ./Source/cmOrderDirectories.cxx,\ ./Source/cmTarget.cxx,\ ./Source/kwsys/*,\ ./Source/QtDialog/CMakeSetupDialog.ui,\ ./Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx,\ ./Source/CTest/cmParseCoberturaCoverage.h,\ ./Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in,\ ./Tests/RunCMake/CPack/tests/DMG_SLA/English.license.rtf,\ ./Tests/RunCMake/CPack/tests/DMG_SLA/German.license.txt,\ ./Tests/RunCMake/CPack/tests/DMG_SLA/German.menu.txt,\ ./Tests/RunCMake/GoogleTest/xml_output.cpp,\ ./Tests/RunCMake/Make/TargetMessages*,\ ./Utilities/*,\ " \ -L "\ dependees,\ endwhile,\ fo,\ filetest,\ helpfull,\ nd,\ objext,\ stoll,\ supercedes,\ superceded,\ vas,\ varn,\ " ```
* NVCC: Handle host compiler with spaces in pathRaul Tambre2020-07-141-2/+2
| | | | | | | Need to surround it with quotes otherwise the different bits are passed as separate arguments. Fixes #20954.
* CUDA: Fix CMAKE_CUDA_COMPILER_TOOLKIT_ROOT detection in Visual StudioBrad King2020-06-181-108/+121
| | | | | | | | | | When using a Visual Studio generator, we do not know the path to `CMAKE_CUDA_COMPILER` until after the compiler id detection project extracts it. However, based on the VS toolchain configuration we know that the compiler id will be NVIDIA, so use that to drive the CUDA architecture flag logic. After the main compiler id step we know `CMAKE_CUDA_COMPILER`, so `CMAKE_CUDA_COMPILER_TOOLKIT_ROOT` can then be computed.
* CUDA: Re-order some logic for determining the compilerBrad King2020-06-181-11/+9
|
* CUDA: Remove unused variables while determining compilerBrad King2020-06-181-2/+0
|
* CUDA: Simplify CMAKE_CUDA_COMPILER_TOOLKIT_ROOT computationBrad King2020-06-181-1/+1
|
* CUDA: Skip the entire search for nvcc when it is CMAKE_CUDA_COMPILERBrad King2020-06-181-80/+80
|
* CUDA: Fix NVCC executable search during compiler detectionRaul Tambre2020-06-181-7/+1
| | | | | | | | The result variable was `CUDAToolkit_NVCC_EXECUTABLE` instead of `_CUDA_NVCC_EXECUTABLE`, which the rest of the code used. Also, we can simply `set()` the `_CUDA_NVCC_EXECUTABLE` value without searching. Fixes: #20847
* CUDA: Throw error for Clang on WindowsRaul Tambre2020-06-161-0/+4
| | | | | | Supporting compiling on Windows is more complicated than initially expected, so it won't make it into CMake 3.18. Add a helpful error for users.
* Merge topic 'cuda_clang_toolkit_path' into release-3.18Brad King2020-06-151-15/+195
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | ec59fb6c31 CUDA: Determine CUDA toolkit location for NVCC 0a056246a1 CUDA: Pass toolkit path to Clang 9c43972127 FindCUDAToolkit: Avoid unnecessary temporary variable computing binary dir 9eebb5b8b2 FindCUDAToolkit: Remove unnecessary checks around searches 8f01fe7bf1 FindCUDAToolkit: Use list(SORT) to sort in natural order 8c144fe9ad FindCUDAToolkit: Compute CUDAToolkit_INCLUDE_DIR instead of searching 403f8d31e3 FindCUDAToolkit: Add CUDAToolkit_LIBRARY_ROOT 6636693134 FindCUDAToolkit: Re-unify with Internal/CUDAToolkit Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4828
| * CUDA: Determine CUDA toolkit location for NVCCRaul Tambre2020-06-121-122/+123
| | | | | | | | | | Similar to how we already do for Clang. Avoids a lot of redundant work in FindCUDAToolkit.
| * CUDA: Pass toolkit path to ClangRaul Tambre2020-06-121-120/+142
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clang isn't very good at finding the installed CUDA toolkit. The upstream recommendation is that we should pass the toolkit explicitly. Additionally: * Avoids Clang having to search for the toolkit on every invocation. * Allows the user to use a toolkit from a non-standard location by simply setting CUDAToolkit_ROOT. The same way as with FindCUDAToolkit. Clang wants the directory containing the device library and version.txt as the toolkit path. We thus pass the newly introduced CUDAToolkit_LIBRARY_ROOT as the toolkit path. We save CUDAToolkit_ROOT_DIR and CUDAToolkit_LIBRARY_ROOT on Clang to have them available in try_compile() and avoid unnecessary re-searching or a possibly different installation being found in FindCUDAToolkit. This however means that the selected toolkit can't be changed after the initial language enablement. We now determine CUDA compiler ID before doing actual detection, as we don't want to spend time finding the CUDA toolkit for NVIDIA. Implements #20754.
| * FindCUDAToolkit: Remove unnecessary checks around searchesRaul Tambre2020-06-121-6/+4
| | | | | | | | | | find_*() don't search if the result variable is already set. Remove the if()s around such cases.
| * FindCUDAToolkit: Use list(SORT) to sort in natural orderRaul Tambre2020-06-121-36/+4
| | | | | | | | | | We had a custom loop to sort in the natural order. Since CMake 3.18 this is supported natively by CMake and simplifies the code significantly.
| * FindCUDAToolkit: Compute CUDAToolkit_INCLUDE_DIR instead of searchingRaul Tambre2020-06-121-4/+7
| | | | | | | | | | | | | | We can avoid searching for this since CUDAToolkit_TARGET_DIR always contains the include/ directory. But add a warning just in case. Also apply this in CMakeDetermineCUDACompiler for Clang code.
| * FindCUDAToolkit: Add CUDAToolkit_LIBRARY_ROOTRaul Tambre2020-06-121-0/+12
| | | | | | | | | | | | | | | | | | On scattered installations version.txt and nvvm are located at this location. This may be useful to users and will allow us in the future to parse version.txt instead of invoking nvcc to figure out the CUDA toolkit version. We also add it to CMakeDetermineCUDACompiler in preparation for future use by Clang code.
| * FindCUDAToolkit: Re-unify with Internal/CUDAToolkitRaul Tambre2020-06-121-3/+179
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A portion of FindCUDAToolkit was previously split in commit dc2eae1f (FindCUDAToolkit: Factor out discovery code into a separate file, 2020-04-22) out into Internal/CUDAToolkit to allow re-use of the code in CMakeDetermineCUDACompiler for Clang support. This has turned out to be a bad solution due to Clang requiring quite a bit of special handling and special handling for NVCC leaking out from Internal/CUDAToolkit into the Clang code using it. Thus it seems better to re-unify this code and duplicate the parts of the code necessary for Clang where it's required. This will help us get logic correct for both NVCC and CUDA handling. We can still unify the common parts in the future once the code has matured.
* | CUDA: Add support for disabling CUDA_ARCHITECTURESRaul Tambre2020-06-151-1/+1
|/ | | | | | | | | | The ability to disable adding architectures completely for packaging purposes and cases requiring passing the architectures flags explicitly has been requested. Support a false value for CUDA_ARCHITECTURES and CMAKE_CUDA_ARCHITECTURES for this purpose. Implements #20821.
* CUDA: Fix checking working architectures with specifiersRaul Tambre2020-06-051-2/+10
| | | | | | | | | | | | | We don't distinguish real/virtual architectures during compiler detection. If the user passes -DCMAKE_CUDA_ARCHITECTURES="70-virtual" we'll test with only the real architecture. If it works "architectures" will end up as "70". We check equality using strings, so this fails and we incorrectly throw an error. Fix this by comparing against CMAKE_CUDA_ARCHITECTURES with the specifiers stripped. We need to deduplicate tested_architectures for the same reason in case the user specified something like "70-real;70-virtual".
* CUDA: Detect non-working user-specified architectures on NVCCRaul Tambre2020-05-291-19/+35
| | | | | | | | | | | Extend the improved error message added for Clang by commit 19cc5bc296 (CUDA: Throw error if user-specified architectures don't work, 2020-05-26) to cover NVCC as well. Also fix the error incorrectly being thrown if the user-specified list differed in order to the architectures parsed from the compiler output. Implements: #20757
* CUDA: Throw error if user-specified architectures don't workRaul Tambre2020-05-261-6/+33
| | | | | | | | | | | | | Previously if an user specified CMAKE_CUDA_ARCHITECTURES and they didn't work we would end up erroring during compiler testing. Instead check if the architectures we successfully compiled with are the same as the user-specified (if any). If they don't match, then throw a more helpful error than compiler testing would. Additionally, to make this work correctly I made it try all user-specified architectures at once instead of each separately. Implements: #20756
* CUDA: Simplify Clang implicit host linker settingsBrad King2020-05-221-14/+6
| | | | | | | | | | | | | | The purpose of `CMAKE_CUDA_HOST_IMPLICIT_LINK_*` is to capture the extra link libraries and directories that the CUDA compiler passes when invoking the host linker. We need this when using NVCC because CMake drives the host linker directly rather than through NVCC. However, this is not needed with Clang because: * Clang does not pass any CUDA libraries automatically. * We drive linking with the Clang compiler anyway. Drop the detection logic for Clang because it only gives the normal C++ runtime libraries which we do not need here.
* CUDA: Fix implicit runtime library filtering on WindowsBrad King2020-05-221-3/+3
| | | | | The CUDA runtime library names may have a `.lib` suffix. Exclude those too.
* CUDA: Refactor implicit library filteringBrad King2020-05-221-0/+18
| | | | | | Filter CMAKE_CUDA_HOST_IMPLICIT_LINK_LIBRARIES just after it is computed. Re-use the same exclusion list for filtering CMAKE_CUDA_IMPLICIT_LINK_LIBRARIES to avoid duplication.
* Merge branch 'backport-cuda-default-runtime' into cuda-default-runtimeBrad King2020-05-221-0/+28
|\
| * CUDA: Compute CMAKE_CUDA_RUNTIME_LIBRARY default from toolchainRobert Maynard2020-05-211-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | CUDA: Add support for Clang compilerRaul Tambre2020-05-151-5/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge topic 'cuda_architectures'Brad King2020-04-161-0/+11
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | 21131ca60c CUDA: Add CudaOnly.CompileFlags test f0931b0790 CUDA: Convert tests to use CUDA_ARCHITECTURES e98588aaba CUDA: Add CUDA_ARCHITECTURES target property Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Patrick Stotko <stotko@cs.uni-bonn.de> Merge-request: !4568
| * | CUDA: Add CUDA_ARCHITECTURES target propertyRaul Tambre2020-04-151-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Simplifies CUDA target architecture handling. Required for Clang support as Clang doesn't automatically select a supported architecture. We detect a supported architecture during compiler identification and set CMAKE_CUDA_ARCHITECTURES to it. Introduces CMP0104 for backwards compatibility with manually setting code generation flags with NVCC. Implements #17963.