@@ -1774,8 +1774,7 @@ void Generic_GCC::CudaInstallationDetector::init(
1774
1774
Args.getLastArgValue (options::OPT_cuda_path_EQ));
1775
1775
else {
1776
1776
CudaPathCandidates.push_back (D.SysRoot + " /usr/local/cuda" );
1777
- // FIXME: Uncomment this once we can compile the cuda 8 headers.
1778
- // CudaPathCandidates.push_back(D.SysRoot + "/usr/local/cuda-8.0");
1777
+ CudaPathCandidates.push_back (D.SysRoot + " /usr/local/cuda-8.0" );
1779
1778
CudaPathCandidates.push_back (D.SysRoot + " /usr/local/cuda-7.5" );
1780
1779
CudaPathCandidates.push_back (D.SysRoot + " /usr/local/cuda-7.0" );
1781
1780
}
@@ -1795,6 +1794,16 @@ void Generic_GCC::CudaInstallationDetector::init(
1795
1794
FS.exists (LibDevicePath)))
1796
1795
continue ;
1797
1796
1797
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> VersionFile =
1798
+ FS.getBufferForFile (InstallPath + " /version.txt" );
1799
+ if (!VersionFile) {
1800
+ // CUDA 7.0 doesn't have a version.txt, so guess that's our version if
1801
+ // version.txt isn't present.
1802
+ Version = CudaVersion::CUDA_70;
1803
+ } else {
1804
+ Version = ParseCudaVersionFile ((*VersionFile)->getBuffer ());
1805
+ }
1806
+
1798
1807
std::error_code EC;
1799
1808
for (llvm::sys::fs::directory_iterator LI (LibDevicePath, EC), LE;
1800
1809
!EC && LI != LE; LI = LI.increment (EC)) {
@@ -1807,46 +1816,35 @@ void Generic_GCC::CudaInstallationDetector::init(
1807
1816
StringRef GpuArch = FileName.slice (
1808
1817
LibDeviceName.size (), FileName.find (' .' , LibDeviceName.size ()));
1809
1818
LibDeviceMap[GpuArch] = FilePath.str ();
1810
- // Insert map entries for specifc devices with this compute capability.
1811
- // NVCC's choice of libdevice library version is rather peculiar:
1812
- // http://docs.nvidia.com/cuda/libdevice-users-guide/basic-usage.html#version-selection
1813
- // TODO: this will need to be updated once CUDA-8 is released.
1819
+ // Insert map entries for specifc devices with this compute
1820
+ // capability. NVCC's choice of the libdevice library version is
1821
+ // rather peculiar and depends on the CUDA version.
1814
1822
if (GpuArch == " compute_20" ) {
1815
1823
LibDeviceMap[" sm_20" ] = FilePath;
1816
1824
LibDeviceMap[" sm_21" ] = FilePath;
1817
1825
LibDeviceMap[" sm_32" ] = FilePath;
1818
1826
} else if (GpuArch == " compute_30" ) {
1819
1827
LibDeviceMap[" sm_30" ] = FilePath;
1820
- // compute_30 is the fallback libdevice variant for sm_30+,
1821
- // unless CUDA specifies different version for specific GPU
1822
- // arch.
1823
- LibDeviceMap[" sm_50" ] = FilePath;
1824
- LibDeviceMap[" sm_52" ] = FilePath;
1825
- LibDeviceMap[" sm_53" ] = FilePath;
1826
- // sm_6? are currently all aliases for sm_53 in LLVM and
1827
- // should use compute_30.
1828
+ if (Version < CudaVersion::CUDA_80) {
1829
+ LibDeviceMap[" sm_50" ] = FilePath;
1830
+ LibDeviceMap[" sm_52" ] = FilePath;
1831
+ LibDeviceMap[" sm_53" ] = FilePath;
1832
+ }
1828
1833
LibDeviceMap[" sm_60" ] = FilePath;
1829
1834
LibDeviceMap[" sm_61" ] = FilePath;
1830
1835
LibDeviceMap[" sm_62" ] = FilePath;
1831
1836
} else if (GpuArch == " compute_35" ) {
1832
1837
LibDeviceMap[" sm_35" ] = FilePath;
1833
1838
LibDeviceMap[" sm_37" ] = FilePath;
1834
1839
} else if (GpuArch == " compute_50" ) {
1835
- // NVCC does not use compute_50 libdevice at all at the moment.
1836
- // The version that's shipped with CUDA-7.5 is a copy of compute_30.
1840
+ if (Version >= CudaVersion::CUDA_80) {
1841
+ LibDeviceMap[" sm_50" ] = FilePath;
1842
+ LibDeviceMap[" sm_52" ] = FilePath;
1843
+ LibDeviceMap[" sm_53" ] = FilePath;
1844
+ }
1837
1845
}
1838
1846
}
1839
1847
1840
- llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> VersionFile =
1841
- FS.getBufferForFile (InstallPath + " /version.txt" );
1842
- if (!VersionFile) {
1843
- // CUDA 7.0 doesn't have a version.txt, so guess that's our version if
1844
- // version.txt isn't present.
1845
- Version = CudaVersion::CUDA_70;
1846
- } else {
1847
- Version = ParseCudaVersionFile ((*VersionFile)->getBuffer ());
1848
- }
1849
-
1850
1848
IsValid = true ;
1851
1849
break ;
1852
1850
}
0 commit comments