Lines 32-55
using namespace llvm::opt;
Link Here
|
32 |
|
32 |
|
33 |
// Parses the contents of version.txt in an CUDA installation. It should |
33 |
// Parses the contents of version.txt in an CUDA installation. It should |
34 |
// contain one line of the from e.g. "CUDA Version 7.5.2". |
34 |
// contain one line of the from e.g. "CUDA Version 7.5.2". |
35 |
static CudaVersion ParseCudaVersionFile(const Driver &D, llvm::StringRef V) { |
35 |
void CudaInstallationDetector::ParseCudaVersionFile(llvm::StringRef V) { |
|
|
36 |
Version = CudaVersion::UNKNOWN; |
36 |
if (!V.startswith("CUDA Version ")) |
37 |
if (!V.startswith("CUDA Version ")) |
37 |
return CudaVersion::UNKNOWN; |
38 |
return; |
38 |
V = V.substr(strlen("CUDA Version ")); |
39 |
V = V.substr(strlen("CUDA Version ")); |
39 |
SmallVector<StringRef,4> VersionParts; |
40 |
SmallVector<StringRef,4> VersionParts; |
40 |
V.split(VersionParts, '.'); |
41 |
V.split(VersionParts, '.'); |
41 |
if (VersionParts.size() < 2) |
42 |
if (VersionParts.size() < 2) |
42 |
return CudaVersion::UNKNOWN; |
43 |
return; |
43 |
std::string MajorMinor = join_items(".", VersionParts[0], VersionParts[1]); |
44 |
DetectedVersion = join_items(".", VersionParts[0], VersionParts[1]); |
44 |
CudaVersion Version = CudaStringToVersion(MajorMinor); |
45 |
Version = CudaStringToVersion(DetectedVersion); |
45 |
if (Version != CudaVersion::UNKNOWN) |
46 |
if (Version != CudaVersion::UNKNOWN) |
46 |
return Version; |
47 |
return; |
47 |
|
48 |
|
48 |
// Issue a warning and assume that the version we've found is compatible with |
49 |
Version = CudaVersion::LATEST; |
49 |
// the latest version we support. |
50 |
DetectedVersionIsNotSupported = true; |
50 |
D.Diag(diag::warn_drv_unknown_cuda_version) |
51 |
} |
51 |
<< MajorMinor << CudaVersionToString(CudaVersion::LATEST); |
52 |
|
52 |
return CudaVersion::LATEST; |
53 |
void CudaInstallationDetector::WarnIfUnsupportedVersion() { |
|
|
54 |
if (DetectedVersionIsNotSupported) |
55 |
D.Diag(diag::warn_drv_unknown_cuda_version) |
56 |
<< DetectedVersion << CudaVersionToString(Version); |
53 |
} |
57 |
} |
54 |
|
58 |
|
55 |
CudaInstallationDetector::CudaInstallationDetector( |
59 |
CudaInstallationDetector::CudaInstallationDetector( |
Lines 147-153
CudaInstallationDetector::CudaInstallationDetector(
Link Here
|
147 |
// version.txt isn't present. |
151 |
// version.txt isn't present. |
148 |
Version = CudaVersion::CUDA_70; |
152 |
Version = CudaVersion::CUDA_70; |
149 |
} else { |
153 |
} else { |
150 |
Version = ParseCudaVersionFile(D, (*VersionFile)->getBuffer()); |
154 |
ParseCudaVersionFile((*VersionFile)->getBuffer()); |
151 |
} |
155 |
} |
152 |
|
156 |
|
153 |
if (Version >= CudaVersion::CUDA_90) { |
157 |
if (Version >= CudaVersion::CUDA_90) { |
Lines 565-572
CudaToolChain::CudaToolChain(const Driver &D, const llvm::Triple &Triple,
Link Here
|
565 |
const Action::OffloadKind OK) |
569 |
const Action::OffloadKind OK) |
566 |
: ToolChain(D, Triple, Args), HostTC(HostTC), |
570 |
: ToolChain(D, Triple, Args), HostTC(HostTC), |
567 |
CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) { |
571 |
CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) { |
568 |
if (CudaInstallation.isValid()) |
572 |
if (CudaInstallation.isValid()) { |
|
|
573 |
CudaInstallation.WarnIfUnsupportedVersion(); |
569 |
getProgramPaths().push_back(CudaInstallation.getBinPath()); |
574 |
getProgramPaths().push_back(CudaInstallation.getBinPath()); |
|
|
575 |
} |
570 |
// Lookup binaries into the driver directory, this is used to |
576 |
// Lookup binaries into the driver directory, this is used to |
571 |
// discover the clang-offload-bundler executable. |
577 |
// discover the clang-offload-bundler executable. |
572 |
getProgramPaths().push_back(getDriver().Dir); |
578 |
getProgramPaths().push_back(getDriver().Dir); |