r316611 - [CUDA] Print an error if you try to compile with < sm_30 on CUDA 9.
Justin Lebar via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 25 14:32:07 PDT 2017
Author: jlebar
Date: Wed Oct 25 14:32:06 2017
New Revision: 316611
URL: http://llvm.org/viewvc/llvm-project?rev=316611&view=rev
Log:
[CUDA] Print an error if you try to compile with < sm_30 on CUDA 9.
Summary:
CUDA 9's minimum sm is sm_30.
Ideally we should also make sm_30 the default when compiling with CUDA
9, but that seems harder than it should be.
Subscribers: sanjoy
Differential Revision: https://reviews.llvm.org/D39109
Added:
cfe/trunk/test/Driver/Inputs/CUDA_90/
cfe/trunk/test/Driver/Inputs/CUDA_90/usr/
cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/
cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/
cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/bin/
cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/bin/.keep
cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/include/
cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/include/.keep
cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/lib/
cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/lib/.keep
cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/lib64/
cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/lib64/.keep
cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/nvvm/
cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/nvvm/libdevice/
cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/nvvm/libdevice/libdevice.10.bc
cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/version.txt
Modified:
cfe/trunk/include/clang/Basic/Cuda.h
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Basic/Cuda.cpp
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/lib/Driver/ToolChains/Cuda.h
cfe/trunk/test/Driver/cuda-bad-arch.cu
Modified: cfe/trunk/include/clang/Basic/Cuda.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Cuda.h?rev=316611&r1=316610&r2=316611&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Cuda.h (original)
+++ cfe/trunk/include/clang/Basic/Cuda.h Wed Oct 25 14:32:06 2017
@@ -22,6 +22,7 @@ enum class CudaVersion {
CUDA_75,
CUDA_80,
CUDA_90,
+ LATEST = CUDA_90,
};
const char *CudaVersionToString(CudaVersion V);
@@ -75,6 +76,9 @@ CudaVirtualArch VirtualArchForCudaArch(C
/// Get the earliest CudaVersion that supports the given CudaArch.
CudaVersion MinVersionForCudaArch(CudaArch A);
+/// Get the latest CudaVersion that supports the given CudaArch.
+CudaVersion MaxVersionForCudaArch(CudaArch A);
+
} // namespace clang
#endif
Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=316611&r1=316610&r2=316611&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Wed Oct 25 14:32:06 2017
@@ -29,9 +29,10 @@ def err_drv_no_cuda_installation : Error
def err_drv_no_cuda_libdevice : Error<
"cannot find libdevice for %0. Provide path to different CUDA installation "
"via --cuda-path, or pass -nocudalib to build without linking with libdevice.">;
-def err_drv_cuda_version_too_low : Error<
- "GPU arch %1 requires CUDA version at least %3, but installation at %0 is %2. "
- "Use --cuda-path to specify a different CUDA install, or pass "
+def err_drv_cuda_version_unsupported : Error<
+ "GPU arch %0 is supported by CUDA versions between %1 and %2 (inclusive), "
+ "but installation at %3 is %4. Use --cuda-path to specify a different CUDA "
+ "install, pass a different GPU arch with --cuda-gpu-arch, or pass "
"--no-cuda-version-check.">;
def err_drv_cuda_nvptx_host : Error<"unsupported use of NVPTX for host compilation.">;
def err_drv_invalid_thread_model_for_target : Error<
Modified: cfe/trunk/lib/Basic/Cuda.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Cuda.cpp?rev=316611&r1=316610&r2=316611&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Cuda.cpp (original)
+++ cfe/trunk/lib/Basic/Cuda.cpp Wed Oct 25 14:32:06 2017
@@ -180,4 +180,16 @@ CudaVersion MinVersionForCudaArch(CudaAr
llvm_unreachable("invalid enum");
}
+CudaVersion MaxVersionForCudaArch(CudaArch A) {
+ switch (A) {
+ case CudaArch::UNKNOWN:
+ return CudaVersion::UNKNOWN;
+ case CudaArch::SM_20:
+ case CudaArch::SM_21:
+ return CudaVersion::CUDA_80;
+ default:
+ return CudaVersion::LATEST;
+ }
+}
+
} // namespace clang
Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=316611&r1=316610&r2=316611&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Wed Oct 25 14:32:06 2017
@@ -205,15 +205,17 @@ void CudaInstallationDetector::AddCudaIn
void CudaInstallationDetector::CheckCudaVersionSupportsArch(
CudaArch Arch) const {
if (Arch == CudaArch::UNKNOWN || Version == CudaVersion::UNKNOWN ||
- ArchsWithVersionTooLowErrors.count(Arch) > 0)
+ ArchsWithBadVersion.count(Arch) > 0)
return;
- auto RequiredVersion = MinVersionForCudaArch(Arch);
- if (Version < RequiredVersion) {
- ArchsWithVersionTooLowErrors.insert(Arch);
- D.Diag(diag::err_drv_cuda_version_too_low)
- << InstallPath << CudaArchToString(Arch) << CudaVersionToString(Version)
- << CudaVersionToString(RequiredVersion);
+ auto MinVersion = MinVersionForCudaArch(Arch);
+ auto MaxVersion = MaxVersionForCudaArch(Arch);
+ if (Version < MinVersion || Version > MaxVersion) {
+ ArchsWithBadVersion.insert(Arch);
+ D.Diag(diag::err_drv_cuda_version_unsupported)
+ << CudaArchToString(Arch) << CudaVersionToString(MinVersion)
+ << CudaVersionToString(MaxVersion) << InstallPath
+ << CudaVersionToString(Version);
}
}
Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.h?rev=316611&r1=316610&r2=316611&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Cuda.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.h Wed Oct 25 14:32:06 2017
@@ -40,7 +40,7 @@ private:
// CUDA architectures for which we have raised an error in
// CheckCudaVersionSupportsArch.
- mutable llvm::SmallSet<CudaArch, 4> ArchsWithVersionTooLowErrors;
+ mutable llvm::SmallSet<CudaArch, 4> ArchsWithBadVersion;
public:
CudaInstallationDetector(const Driver &D, const llvm::Triple &HostTriple,
Added: cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/bin/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/bin/.keep?rev=316611&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/include/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/include/.keep?rev=316611&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/lib/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/lib/.keep?rev=316611&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/lib64/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/lib64/.keep?rev=316611&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/nvvm/libdevice/libdevice.10.bc
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/nvvm/libdevice/libdevice.10.bc?rev=316611&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/version.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/version.txt?rev=316611&view=auto
==============================================================================
--- cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/version.txt (added)
+++ cfe/trunk/test/Driver/Inputs/CUDA_90/usr/local/cuda/version.txt Wed Oct 25 14:32:06 2017
@@ -0,0 +1 @@
+CUDA Version 9.0.103
Modified: cfe/trunk/test/Driver/cuda-bad-arch.cu
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-bad-arch.cu?rev=316611&r1=316610&r2=316611&view=diff
==============================================================================
--- cfe/trunk/test/Driver/cuda-bad-arch.cu (original)
+++ cfe/trunk/test/Driver/cuda-bad-arch.cu Wed Oct 25 14:32:06 2017
@@ -12,6 +12,12 @@
// BAD: error: Unsupported CUDA gpu architecture
+// RUN: %clang -### -v --target=x86_64-linux-gnu --cuda-gpu-arch=sm_21 \
+// RUN: --cuda-path=%S/Inputs/CUDA_90/usr/local/cuda %s 2>&1 \
+// RUN: | FileCheck -check-prefix BAD_CUDA9 %s
+
+// BAD_CUDA9: GPU arch sm_21 is supported by CUDA versions between 7.0 and 8.0
+
// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 -c %s 2>&1 \
// RUN: | FileCheck -check-prefix OK %s
// RUN: %clang -### -target x86_64-linux-gnu --cuda-gpu-arch=sm_52 -c %s 2>&1 \
More information about the cfe-commits
mailing list