[PATCH] D89752: [CUDA] Improve clang's ability to detect recent CUDA versions.
Artem Belevich via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 19 16:48:54 PDT 2020
tra created this revision.
tra added reviewers: yaxunl, emankov, hans.
Herald added a subscriber: bixia.
Herald added a project: clang.
tra requested review of this revision.
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.
Bug: https://bugs.llvm.org/show_bug.cgi?id=47332
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D89752
Files:
clang/lib/Driver/ToolChains/Cuda.cpp
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -155,9 +155,14 @@
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());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89752.299218.patch
Type: text/x-patch
Size: 986 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201019/65e65122/attachment.bin>
More information about the cfe-commits
mailing list