<div dir="ltr">Sorry about that. I'll commit the fix shortly.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 2, 2016 at 4:33 PM, Bruno Cardoso Lopes <span dir="ltr"><<a href="mailto:bruno.cardoso@gmail.com" target="_blank">bruno.cardoso@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Artem,<br>
<br>
This broke <a href="http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/26856" rel="noreferrer" target="_blank">http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/26856</a>,<br>
can you take a look?<br>
<br>
Thanks,<br>
<div class="HOEnZb"><div class="h5"><br>
On Tue, Aug 2, 2016 at 4:12 PM, Artem Belevich via cfe-commits<br>
<<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
> Author: tra<br>
> Date: Tue Aug 2 18:12:51 2016<br>
> New Revision: 277542<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=277542&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=277542&view=rev</a><br>
> Log:<br>
> [CUDA] Fix libdevice selection.<br>
><br>
> This makes clang's libdevice selection match that of NVCC as described in<br>
> <a href="http://docs.nvidia.com/cuda/libdevice-users-guide/basic-usage.html#version-selection" rel="noreferrer" target="_blank">http://docs.nvidia.com/cuda/libdevice-users-guide/basic-usage.html#version-selection</a><br>
><br>
> If required libdevice variant is not found, driver now fails with an error.<br>
><br>
> Differential Revision: <a href="https://reviews.llvm.org/D23037" rel="noreferrer" target="_blank">https://reviews.llvm.org/D23037</a><br>
><br>
> Added:<br>
> cfe/trunk/test/Driver/Inputs/CUDA_80/usr/local/cuda/nvvm/libdevice/libdevice.compute_30.10.bc<br>
> Modified:<br>
> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td<br>
> cfe/trunk/lib/Driver/ToolChains.cpp<br>
> cfe/trunk/test/Driver/<a href="http://cuda-detect.cu" rel="noreferrer" target="_blank">cuda-detect.cu</a><br>
><br>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=277542&r1=277541&r2=277542&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=277542&r1=277541&r2=277542&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)<br>
> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Aug 2 18:12:51 2016<br>
> @@ -26,6 +26,9 @@ def err_drv_cuda_bad_gpu_arch : Error<"U<br>
> def err_drv_no_cuda_installation : Error<<br>
> "cannot find CUDA installation. Provide its path via --cuda-path, or pass "<br>
> "-nocudainc to build without CUDA includes.">;<br>
> +def err_drv_no_cuda_libdevice : Error<<br>
> + "cannot find libdevice for %0. Provide path to different CUDA installation "<br>
> + "via --cuda-path, or pass -nocudalib to build without linking with libdevice.">;<br>
> def err_drv_cuda_version_too_low : Error<<br>
> "GPU arch %1 requires CUDA version at least %3, but installation at %0 is %2. "<br>
> "Use --cuda-path to specify a different CUDA install, or pass "<br>
><br>
> Modified: cfe/trunk/lib/Driver/ToolChains.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=277542&r1=277541&r2=277542&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=277542&r1=277541&r2=277542&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)<br>
> +++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Aug 2 18:12:51 2016<br>
> @@ -1791,22 +1791,32 @@ void Generic_GCC::CudaInstallationDetect<br>
> LibDeviceName.size(), FileName.find('.', LibDeviceName.size()));<br>
> LibDeviceMap[GpuArch] = FilePath.str();<br>
> // Insert map entries for specifc devices with this compute capability.<br>
> + // NVCC's choice of libdevice library version is rather peculiar:<br>
> + // <a href="http://docs.nvidia.com/cuda/libdevice-users-guide/basic-usage.html#version-selection" rel="noreferrer" target="_blank">http://docs.nvidia.com/cuda/libdevice-users-guide/basic-usage.html#version-selection</a><br>
> + // TODO: this will need to be updated once CUDA-8 is released.<br>
> if (GpuArch == "compute_20") {<br>
> LibDeviceMap["sm_20"] = FilePath;<br>
> LibDeviceMap["sm_21"] = FilePath;<br>
> + LibDeviceMap["sm_32"] = FilePath;<br>
> } else if (GpuArch == "compute_30") {<br>
> LibDeviceMap["sm_30"] = FilePath;<br>
> - LibDeviceMap["sm_32"] = FilePath;<br>
> - } else if (GpuArch == "compute_35") {<br>
> - LibDeviceMap["sm_35"] = FilePath;<br>
> - LibDeviceMap["sm_37"] = FilePath;<br>
> - } else if (GpuArch == "compute_50") {<br>
> + // compute_30 is the fallback libdevice variant for sm_30+,<br>
> + // unless CUDA specifies different version for specific GPU<br>
> + // arch.<br>
> LibDeviceMap["sm_50"] = FilePath;<br>
> LibDeviceMap["sm_52"] = FilePath;<br>
> LibDeviceMap["sm_53"] = FilePath;<br>
> + // sm_6? are currently all aliases for sm_53 in LLVM and<br>
> + // should use compute_30.<br>
> LibDeviceMap["sm_60"] = FilePath;<br>
> LibDeviceMap["sm_61"] = FilePath;<br>
> LibDeviceMap["sm_62"] = FilePath;<br>
> + } else if (GpuArch == "compute_35") {<br>
> + LibDeviceMap["sm_35"] = FilePath;<br>
> + LibDeviceMap["sm_37"] = FilePath;<br>
> + } else if (GpuArch == "compute_50") {<br>
> + // NVCC does not use compute_50 libdevice at all at the moment.<br>
> + // The version that's shipped with CUDA-7.5 is a copy of compute_30.<br>
> }<br>
> }<br>
><br>
> @@ -4759,18 +4769,23 @@ CudaToolChain::addClangTargetOptions(con<br>
> if (DriverArgs.hasArg(options::OPT_nocudalib))<br>
> return;<br>
><br>
> - std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(<br>
> - DriverArgs.getLastArgValue(options::OPT_march_EQ));<br>
> - if (!LibDeviceFile.empty()) {<br>
> - CC1Args.push_back("-mlink-cuda-bitcode");<br>
> - CC1Args.push_back(DriverArgs.MakeArgString(LibDeviceFile));<br>
> -<br>
> - // Libdevice in CUDA-7.0 requires PTX version that's more recent<br>
> - // than LLVM defaults to. Use PTX4.2 which is the PTX version that<br>
> - // came with CUDA-7.0.<br>
> - CC1Args.push_back("-target-feature");<br>
> - CC1Args.push_back("+ptx42");<br>
> + StringRef GpuArch = DriverArgs.getLastArgValue(options::OPT_march_EQ);<br>
> + assert(!GpuArch.empty() && "Must have an explicit GPU arch.");<br>
> + std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);<br>
> +<br>
> + if (LibDeviceFile.empty()) {<br>
> + getDriver().Diag(diag::err_drv_no_cuda_libdevice) << GpuArch;<br>
> + return;<br>
> }<br>
> +<br>
> + CC1Args.push_back("-mlink-cuda-bitcode");<br>
> + CC1Args.push_back(DriverArgs.MakeArgString(LibDeviceFile));<br>
> +<br>
> + // Libdevice in CUDA-7.0 requires PTX version that's more recent<br>
> + // than LLVM defaults to. Use PTX4.2 which is the PTX version that<br>
> + // came with CUDA-7.0.<br>
> + CC1Args.push_back("-target-feature");<br>
> + CC1Args.push_back("+ptx42");<br>
> }<br>
><br>
> void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,<br>
><br>
> Added: cfe/trunk/test/Driver/Inputs/CUDA_80/usr/local/cuda/nvvm/libdevice/libdevice.compute_30.10.bc<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/CUDA_80/usr/local/cuda/nvvm/libdevice/libdevice.compute_30.10.bc?rev=277542&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/CUDA_80/usr/local/cuda/nvvm/libdevice/libdevice.compute_30.10.bc?rev=277542&view=auto</a><br>
> ==============================================================================<br>
> (empty)<br>
><br>
> Modified: cfe/trunk/test/Driver/<a href="http://cuda-detect.cu" rel="noreferrer" target="_blank">cuda-detect.cu</a><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-detect.cu?rev=277542&r1=277541&r2=277542&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-detect.cu?rev=277542&r1=277541&r2=277542&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/test/Driver/<a href="http://cuda-detect.cu" rel="noreferrer" target="_blank">cuda-detect.cu</a> (original)<br>
> +++ cfe/trunk/test/Driver/<a href="http://cuda-detect.cu" rel="noreferrer" target="_blank">cuda-detect.cu</a> Tue Aug 2 18:12:51 2016<br>
> @@ -10,15 +10,41 @@<br>
> // RUN: %clang -v --target=i386-unknown-linux \<br>
> // RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 | FileCheck %s<br>
><br>
> -// Make sure we map libdevice bitcode files to proper GPUs.<br>
> +// Make sure we map libdevice bitcode files to proper GPUs. These<br>
> +// tests use Inputs/CUDA_80 which has full set of libdevice files.<br>
> +// However, libdevice mapping only matches CUDA-7.x at the moment.<br>
> +// sm_2x, sm_32 -> compute_20<br>
> // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_21 \<br>
> -// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \<br>
> +// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \<br>
> +// RUN: | FileCheck %s -check-prefix COMMON \<br>
> +// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE20<br>
> +// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_32 \<br>
> +// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \<br>
> +// RUN: | FileCheck %s -check-prefix COMMON \<br>
> +// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE20<br>
> +// sm_30, sm_5x and sm_6x map to compute_30<br>
> +// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_30 \<br>
> +// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \<br>
> // RUN: | FileCheck %s -check-prefix COMMON \<br>
> -// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE21<br>
> +// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE30<br>
> +// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_50 \<br>
> +// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \<br>
> +// RUN: | FileCheck %s -check-prefix COMMON \<br>
> +// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE30<br>
> +// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_60 \<br>
> +// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \<br>
> +// RUN: | FileCheck %s -check-prefix COMMON \<br>
> +// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE30<br>
> +// sm_35 and sm_37 -> compute_35<br>
> // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \<br>
> -// RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \<br>
> +// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \<br>
> // RUN: | FileCheck %s -check-prefix COMMON -check-prefix CUDAINC \<br>
> // RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE35<br>
> +// RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_37 \<br>
> +// RUN: --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \<br>
> +// RUN: | FileCheck %s -check-prefix COMMON -check-prefix CUDAINC \<br>
> +// RUN: -check-prefix LIBDEVICE -check-prefix LIBDEVICE35<br>
> +<br>
> // Verify that -nocudainc prevents adding include path to CUDA headers.<br>
> // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \<br>
> // RUN: -nocudainc --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \<br>
> @@ -29,12 +55,13 @@<br>
> // RUN: --cuda-path=%S/no-cuda-there %s 2>&1 \<br>
> // RUN: | FileCheck %s -check-prefix COMMON -check-prefix NOCUDAINC<br>
><br>
> -// Verify that no options related to bitcode linking are passes if<br>
> -// there's no bitcode file.<br>
> +// Verify that we get an error if there's no libdevice library to link with.<br>
> +// NOTE: Inputs/CUDA deliberately does *not* have libdevice.compute_30 for this purpose.<br>
> // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_30 \<br>
> // RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \<br>
> -// RUN: | FileCheck %s -check-prefix COMMON -check-prefix NOLIBDEVICE<br>
> -// .. or if we explicitly passed -nocudalib<br>
> +// RUN: | FileCheck %s -check-prefix COMMON -check-prefix MISSINGLIBDEVICE<br>
> +<br>
> +// Verify that -nocudalib prevents linking libdevice bitcode in.<br>
> // RUN: %clang -### -v --target=i386-unknown-linux --cuda-gpu-arch=sm_35 \<br>
> // RUN: -nocudalib --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \<br>
> // RUN: | FileCheck %s -check-prefix COMMON -check-prefix NOLIBDEVICE<br>
> @@ -48,16 +75,19 @@<br>
> // CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA/usr/local/cuda<br>
> // NOCUDA-NOT: Found CUDA installation:<br>
><br>
> +// MISSINGLIBDEVICE: error: cannot find libdevice for sm_30.<br>
> +<br>
> // COMMON: "-triple" "nvptx-nvidia-cuda"<br>
> // COMMON-SAME: "-fcuda-is-device"<br>
> // LIBDEVICE-SAME: "-mlink-cuda-bitcode"<br>
> // NOLIBDEVICE-NOT: "-mlink-cuda-bitcode"<br>
> -// LIBDEVICE21-SAME: libdevice.compute_20.10.bc<br>
> +// LIBDEVICE20-SAME: libdevice.compute_20.10.bc<br>
> +// LIBDEVICE30-SAME: libdevice.compute_30.10.bc<br>
> // LIBDEVICE35-SAME: libdevice.compute_35.10.bc<br>
> // NOLIBDEVICE-NOT: libdevice.compute_{{.*}}.bc<br>
> // LIBDEVICE-SAME: "-target-feature" "+ptx42"<br>
> // NOLIBDEVICE-NOT: "-target-feature" "+ptx42"<br>
> -// CUDAINC-SAME: "-internal-isystem" "{{.*}}/Inputs/CUDA/usr/local/cuda/include"<br>
> +// CUDAINC-SAME: "-internal-isystem" "{{.*}}/Inputs/CUDA{{[_0-9]+}}/usr/local/cuda/include"<br>
> // NOCUDAINC-NOT: "-internal-isystem" "{{.*}}/cuda/include"<br>
> // CUDAINC-SAME: "-include" "__clang_cuda_runtime_wrapper.h"<br>
> // NOCUDAINC-NOT: "-include" "__clang_cuda_runtime_wrapper.h"<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Bruno Cardoso Lopes<br>
<a href="http://www.brunocardoso.cc" rel="noreferrer" target="_blank">http://www.brunocardoso.cc</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">--Artem Belevich</div></div>
</div>