Author: hahnfeld Date: Mon Oct 16 06:31:30 2017 New Revision: 315902 URL: http://llvm.org/viewvc/llvm-project?rev=315902&view=rev Log: [CUDA] Require libdevice only if needed
If the user passes -nocudalib, we can live without it being present. Simplify the code by just checking whether LibDeviceMap is empty. Differential Revision: https://reviews.llvm.org/D38901 Added: cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/ cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/usr/ cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/usr/local/ cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/usr/local/cuda/ cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/usr/local/cuda/bin/ cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/usr/local/cuda/bin/.keep cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/usr/local/cuda/include/ cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/usr/local/cuda/include/.keep cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/usr/local/cuda/lib/ cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/usr/local/cuda/lib/.keep cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/usr/local/cuda/lib64/ cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/usr/local/cuda/lib64/.keep Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp cfe/trunk/test/Driver/cuda-detect.cu Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=315902&r1=315901&r2=315902&view=diff ============================================================================== --- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Mon Oct 16 06:31:30 2017 @@ -87,8 +87,7 @@ CudaInstallationDetector::CudaInstallati LibDevicePath = InstallPath + "/nvvm/libdevice"; auto &FS = D.getVFS(); - if (!(FS.exists(IncludePath) && FS.exists(BinPath) && - FS.exists(LibDevicePath))) + if (!(FS.exists(IncludePath) && FS.exists(BinPath))) continue; // On Linux, we have both lib and lib64 directories, and we need to choose @@ -167,17 +166,9 @@ CudaInstallationDetector::CudaInstallati } } - // This code prevents IsValid from being set when - // no libdevice has been found. - bool allEmpty = true; - std::string LibDeviceFile; - for (auto key : LibDeviceMap.keys()) { - LibDeviceFile = LibDeviceMap.lookup(key); - if (!LibDeviceFile.empty()) - allEmpty = false; - } - - if (allEmpty) + // Check that we have found at least one libdevice that we can link in if + // -nocudalib hasn't been specified. + if (LibDeviceMap.empty() && !Args.hasArg(options::OPT_nocudalib)) continue; IsValid = true; Added: cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/usr/local/cuda/bin/.keep URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/usr/local/cuda/bin/.keep?rev=315902&view=auto ============================================================================== (empty) Added: cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/usr/local/cuda/include/.keep URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/usr/local/cuda/include/.keep?rev=315902&view=auto ============================================================================== (empty) Added: cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/usr/local/cuda/lib/.keep URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/usr/local/cuda/lib/.keep?rev=315902&view=auto ============================================================================== (empty) Added: cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/usr/local/cuda/lib64/.keep URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/CUDA-nolibdevice/usr/local/cuda/lib64/.keep?rev=315902&view=auto ============================================================================== (empty) Modified: cfe/trunk/test/Driver/cuda-detect.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-detect.cu?rev=315902&r1=315901&r2=315902&view=diff ============================================================================== --- cfe/trunk/test/Driver/cuda-detect.cu (original) +++ cfe/trunk/test/Driver/cuda-detect.cu Mon Oct 16 06:31:30 2017 @@ -2,7 +2,7 @@ // REQUIRES: x86-registered-target // REQUIRES: nvptx-registered-target // -// # Check that we properly detect CUDA installation. +// Check that we properly detect CUDA installation. // RUN: %clang -v --target=i386-unknown-linux \ // RUN: --sysroot=%S/no-cuda-there 2>&1 | FileCheck %s -check-prefix NOCUDA // RUN: %clang -v --target=i386-apple-macosx \ @@ -18,6 +18,19 @@ // RUN: %clang -v --target=i386-apple-macosx \ // RUN: --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 | FileCheck %s +// Check that we don't find a CUDA installation without libdevice ... +// RUN: %clang -v --target=i386-unknown-linux \ +// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice 2>&1 | FileCheck %s -check-prefix NOCUDA +// RUN: %clang -v --target=i386-apple-macosx \ +// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice 2>&1 | FileCheck %s -check-prefix NOCUDA + +// ... unless the user doesn't need libdevice +// RUN: %clang -v --target=i386-unknown-linux -nocudalib \ +// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice 2>&1 | FileCheck %s -check-prefix NO-LIBDEVICE +// RUN: %clang -v --target=i386-apple-macosx -nocudalib \ +// RUN: --sysroot=%S/Inputs/CUDA-nolibdevice 2>&1 | FileCheck %s -check-prefix NO-LIBDEVICE + + // Make sure we map libdevice bitcode files to proper GPUs. These // tests use Inputs/CUDA_80 which has full set of libdevice files. // However, libdevice mapping only matches CUDA-7.x at the moment. @@ -112,6 +125,7 @@ // RUN: | FileCheck %s --check-prefix CHECK-CXXINCLUDE // CHECK: Found CUDA installation: {{.*}}/Inputs/CUDA/usr/local/cuda +// NO-LIBDEVICE: Found CUDA installation: {{.*}}/Inputs/CUDA-nolibdevice/usr/local/cuda // NOCUDA-NOT: Found CUDA installation: // MISSINGLIBDEVICE: error: cannot find libdevice for sm_20. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits