Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 713530
Collapse All | Expand All

(-)a/clang/lib/Driver/ToolChains/Cuda.cpp (-13 / +19 lines)
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);
(-)a/clang/lib/Driver/ToolChains/Cuda.h (+6 lines)
Lines 30-35 private: Link Here
30
  const Driver &D;
30
  const Driver &D;
31
  bool IsValid = false;
31
  bool IsValid = false;
32
  CudaVersion Version = CudaVersion::UNKNOWN;
32
  CudaVersion Version = CudaVersion::UNKNOWN;
33
  std::string DetectedVersion;
34
  bool DetectedVersionIsNotSupported = false;
33
  std::string InstallPath;
35
  std::string InstallPath;
34
  std::string BinPath;
36
  std::string BinPath;
35
  std::string LibPath;
37
  std::string LibPath;
Lines 75-80 public: Link Here
75
  std::string getLibDeviceFile(StringRef Gpu) const {
77
  std::string getLibDeviceFile(StringRef Gpu) const {
76
    return LibDeviceMap.lookup(Gpu);
78
    return LibDeviceMap.lookup(Gpu);
77
  }
79
  }
80
  void WarnIfUnsupportedVersion();
81
82
private:
83
  void ParseCudaVersionFile(llvm::StringRef V);
78
};
84
};
79
85
80
namespace tools {
86
namespace tools {
(-)a/clang/test/Driver/cuda-version-check.cu (-1 / +5 lines)
Lines 10-15 Link Here
10
// RUN:    FileCheck %s --check-prefix=OK
10
// RUN:    FileCheck %s --check-prefix=OK
11
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
11
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
12
// RUN:    FileCheck %s --check-prefix=UNKNOWN_VERSION
12
// RUN:    FileCheck %s --check-prefix=UNKNOWN_VERSION
13
// Make sure that we don't warn about CUDA version during C++ compilation.
14
// RUN: %clang --target=x86_64-linux -v -### -x c++ --cuda-gpu-arch=sm_60 \
15
// RUN:    --cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
16
// RUN:    FileCheck %s --check-prefix=UNKNOWN_VERSION_CXX
13
17
14
// The installation at Inputs/CUDA is CUDA 7.0, which doesn't support sm_60.
18
// The installation at Inputs/CUDA is CUDA 7.0, which doesn't support sm_60.
15
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 %s | \
19
// RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 %s | \
Lines 62-64 Link Here
62
// ERR_SM61-NOT: error: GPU arch sm_61
66
// ERR_SM61-NOT: error: GPU arch sm_61
63
67
64
// UNKNOWN_VERSION: Unknown CUDA version 999.999. Assuming the latest supported version
68
// UNKNOWN_VERSION: Unknown CUDA version 999.999. Assuming the latest supported version
65
- 
69
// UNKNOWN_VERSION_CXX-NOT: Unknown CUDA version

Return to bug 713530