forked from OSchip/llvm-project
[CUDA] Improve clang's ability to detect recent CUDA versions.
CUDA-11.1 does not carry version.txt which causes clang to assume that it's CUDA-7.0, which used to be the only CUDA version w/o version.txt. In order to tell CUDA-7.0 apart from the new versions, clang now probes for the presence of libdevice.10.bc which is not present in the old CUDA versions. This should keep Clang working for CUDA-11.1. PR47332: https://bugs.llvm.org/show_bug.cgi?id=47332 Differential Revision: https://reviews.llvm.org/D89752
This commit is contained in:
parent
de346cf2ac
commit
65d206484c
|
@ -155,9 +155,14 @@ CudaInstallationDetector::CudaInstallationDetector(
|
|||
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> VersionFile =
|
||||
FS.getBufferForFile(InstallPath + "/version.txt");
|
||||
if (!VersionFile) {
|
||||
// CUDA 7.0 doesn't have a version.txt, so guess that's our version if
|
||||
// version.txt isn't present.
|
||||
Version = CudaVersion::CUDA_70;
|
||||
// CUDA 7.0 and CUDA 11.1+ do not have version.txt file.
|
||||
// Use libdevice file to distinguish 7.0 from the new versions.
|
||||
if (FS.exists(LibDevicePath + "/libdevice.10.bc")) {
|
||||
Version = CudaVersion::LATEST;
|
||||
DetectedVersionIsNotSupported = Version > CudaVersion::LATEST_SUPPORTED;
|
||||
} else {
|
||||
Version = CudaVersion::CUDA_70;
|
||||
}
|
||||
} else {
|
||||
ParseCudaVersionFile((*VersionFile)->getBuffer());
|
||||
}
|
||||
|
|
|
@ -10,6 +10,11 @@
|
|||
// RUN: FileCheck %s --check-prefix=OK
|
||||
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
|
||||
// RUN: FileCheck %s --check-prefix=UNKNOWN_VERSION
|
||||
// CUDA versions after 11.0 (update 1) do not carry version.txt file. Make sure
|
||||
// we still detect them as a new version and handle them the same as we handle
|
||||
// other new CUDA versions.
|
||||
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA_111/usr/local/cuda 2>&1 %s | \
|
||||
// RUN: FileCheck %s --check-prefix=UNKNOWN_VERSION
|
||||
// Make sure that we don't warn about CUDA version during C++ compilation.
|
||||
// RUN: %clang --target=x86_64-linux -v -### -x c++ --cuda-gpu-arch=sm_60 \
|
||||
// RUN: --cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
|
||||
|
@ -65,5 +70,5 @@
|
|||
// ERR_SM61: error: GPU arch sm_61 {{.*}}
|
||||
// ERR_SM61-NOT: error: GPU arch sm_61
|
||||
|
||||
// UNKNOWN_VERSION: Unknown CUDA version 999.999. Assuming the latest supported version
|
||||
// UNKNOWN_VERSION: Unknown CUDA version {{.*}}. Assuming the latest supported version
|
||||
// UNKNOWN_VERSION_CXX-NOT: Unknown CUDA version
|
||||
|
|
Loading…
Reference in New Issue