[CUDA] Rename member variables in CudaInstallationDetector.

Summary:
Remove the "Cuda" prefix from these variables -- it's clear that they
related to CUDA given their containing type.

Reviewers: tra

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D21868

llvm-svn: 274682
This commit is contained in:
Justin Lebar 2016-07-06 21:21:43 +00:00
parent 629076178a
commit 710c13167f
2 changed files with 38 additions and 39 deletions

View File

@ -1725,20 +1725,19 @@ void Generic_GCC::CudaInstallationDetector::init(
if (CudaPath.empty() || !D.getVFS().exists(CudaPath)) if (CudaPath.empty() || !D.getVFS().exists(CudaPath))
continue; continue;
CudaInstallPath = CudaPath; InstallPath = CudaPath;
CudaBinPath = CudaPath + "/bin"; BinPath = CudaPath + "/bin";
CudaIncludePath = CudaInstallPath + "/include"; IncludePath = InstallPath + "/include";
CudaLibDevicePath = CudaInstallPath + "/nvvm/libdevice"; LibDevicePath = InstallPath + "/nvvm/libdevice";
CudaLibPath = LibPath = InstallPath + (TargetTriple.isArch64Bit() ? "/lib64" : "/lib");
CudaInstallPath + (TargetTriple.isArch64Bit() ? "/lib64" : "/lib");
if (!(D.getVFS().exists(CudaIncludePath) && auto &FS = D.getVFS();
D.getVFS().exists(CudaBinPath) && D.getVFS().exists(CudaLibPath) && if (!(FS.exists(IncludePath) && FS.exists(BinPath) && FS.exists(LibPath) &&
D.getVFS().exists(CudaLibDevicePath))) FS.exists(LibDevicePath)))
continue; continue;
std::error_code EC; std::error_code EC;
for (llvm::sys::fs::directory_iterator LI(CudaLibDevicePath, EC), LE; for (llvm::sys::fs::directory_iterator LI(LibDevicePath, EC), LE;
!EC && LI != LE; LI = LI.increment(EC)) { !EC && LI != LE; LI = LI.increment(EC)) {
StringRef FilePath = LI->path(); StringRef FilePath = LI->path();
StringRef FileName = llvm::sys::path::filename(FilePath); StringRef FileName = llvm::sys::path::filename(FilePath);
@ -1748,24 +1747,24 @@ void Generic_GCC::CudaInstallationDetector::init(
continue; continue;
StringRef GpuArch = FileName.slice( StringRef GpuArch = FileName.slice(
LibDeviceName.size(), FileName.find('.', LibDeviceName.size())); LibDeviceName.size(), FileName.find('.', LibDeviceName.size()));
CudaLibDeviceMap[GpuArch] = FilePath.str(); LibDeviceMap[GpuArch] = FilePath.str();
// Insert map entries for specifc devices with this compute capability. // Insert map entries for specifc devices with this compute capability.
if (GpuArch == "compute_20") { if (GpuArch == "compute_20") {
CudaLibDeviceMap["sm_20"] = FilePath; LibDeviceMap["sm_20"] = FilePath;
CudaLibDeviceMap["sm_21"] = FilePath; LibDeviceMap["sm_21"] = FilePath;
} else if (GpuArch == "compute_30") { } else if (GpuArch == "compute_30") {
CudaLibDeviceMap["sm_30"] = FilePath; LibDeviceMap["sm_30"] = FilePath;
CudaLibDeviceMap["sm_32"] = FilePath; LibDeviceMap["sm_32"] = FilePath;
} else if (GpuArch == "compute_35") { } else if (GpuArch == "compute_35") {
CudaLibDeviceMap["sm_35"] = FilePath; LibDeviceMap["sm_35"] = FilePath;
CudaLibDeviceMap["sm_37"] = FilePath; LibDeviceMap["sm_37"] = FilePath;
} else if (GpuArch == "compute_50") { } else if (GpuArch == "compute_50") {
CudaLibDeviceMap["sm_50"] = FilePath; LibDeviceMap["sm_50"] = FilePath;
CudaLibDeviceMap["sm_52"] = FilePath; LibDeviceMap["sm_52"] = FilePath;
CudaLibDeviceMap["sm_53"] = FilePath; LibDeviceMap["sm_53"] = FilePath;
CudaLibDeviceMap["sm_60"] = FilePath; LibDeviceMap["sm_60"] = FilePath;
CudaLibDeviceMap["sm_61"] = FilePath; LibDeviceMap["sm_61"] = FilePath;
CudaLibDeviceMap["sm_62"] = FilePath; LibDeviceMap["sm_62"] = FilePath;
} }
} }
@ -1776,7 +1775,7 @@ void Generic_GCC::CudaInstallationDetector::init(
void Generic_GCC::CudaInstallationDetector::print(raw_ostream &OS) const { void Generic_GCC::CudaInstallationDetector::print(raw_ostream &OS) const {
if (isValid()) if (isValid())
OS << "Found CUDA installation: " << CudaInstallPath << "\n"; OS << "Found CUDA installation: " << InstallPath << "\n";
} }
namespace { namespace {

View File

@ -158,19 +158,19 @@ protected:
GCCInstallationDetector GCCInstallation; GCCInstallationDetector GCCInstallation;
// \brief A class to find a viable CUDA installation // \brief A class to find a viable CUDA installation
class CudaInstallationDetector { class CudaInstallationDetector {
bool IsValid; private:
const Driver &D; const Driver &D;
std::string CudaInstallPath; bool IsValid = false;
std::string CudaBinPath; std::string InstallPath;
std::string CudaLibPath; std::string BinPath;
std::string CudaLibDevicePath; std::string LibPath;
std::string CudaIncludePath; std::string LibDevicePath;
llvm::StringMap<std::string> CudaLibDeviceMap; std::string IncludePath;
llvm::StringMap<std::string> LibDeviceMap;
public: public:
CudaInstallationDetector(const Driver &D) : IsValid(false), D(D) {} CudaInstallationDetector(const Driver &D) : D(D) {}
void init(const llvm::Triple &TargetTriple, const llvm::opt::ArgList &Args); void init(const llvm::Triple &TargetTriple, const llvm::opt::ArgList &Args);
/// \brief Check whether we detected a valid Cuda install. /// \brief Check whether we detected a valid Cuda install.
@ -179,18 +179,18 @@ protected:
void print(raw_ostream &OS) const; void print(raw_ostream &OS) const;
/// \brief Get the detected Cuda installation path. /// \brief Get the detected Cuda installation path.
StringRef getInstallPath() const { return CudaInstallPath; } StringRef getInstallPath() const { return InstallPath; }
/// \brief Get the detected path to Cuda's bin directory. /// \brief Get the detected path to Cuda's bin directory.
StringRef getBinPath() const { return CudaBinPath; } StringRef getBinPath() const { return BinPath; }
/// \brief Get the detected Cuda Include path. /// \brief Get the detected Cuda Include path.
StringRef getIncludePath() const { return CudaIncludePath; } StringRef getIncludePath() const { return IncludePath; }
/// \brief Get the detected Cuda library path. /// \brief Get the detected Cuda library path.
StringRef getLibPath() const { return CudaLibPath; } StringRef getLibPath() const { return LibPath; }
/// \brief Get the detected Cuda device library path. /// \brief Get the detected Cuda device library path.
StringRef getLibDevicePath() const { return CudaLibDevicePath; } StringRef getLibDevicePath() const { return LibDevicePath; }
/// \brief Get libdevice file for given architecture /// \brief Get libdevice file for given architecture
std::string getLibDeviceFile(StringRef Gpu) const { std::string getLibDeviceFile(StringRef Gpu) const {
return CudaLibDeviceMap.lookup(Gpu); return LibDeviceMap.lookup(Gpu);
} }
}; };