]> granicus.if.org Git - clang/commitdiff
[OpenMP] Don't throw cudalib not found error if only front-end is required.
authorGheorghe-Teodor Bercea <gheorghe-teod.bercea@ibm.com>
Tue, 26 Sep 2017 15:36:20 +0000 (15:36 +0000)
committerGheorghe-Teodor Bercea <gheorghe-teod.bercea@ibm.com>
Tue, 26 Sep 2017 15:36:20 +0000 (15:36 +0000)
Summary: If we only use the compiler front-end, do not throw an error about the cuda device library not being found. This allows the front-end to be run on systems where no Cuda installation is found.

Reviewers: Hahnfeld, ABataev, carlo.bertolli, caomhin, tra

Reviewed By: tra

Subscribers: hfinkel, tra, cfe-commits

Differential Revision: https://reviews.llvm.org/D37914

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314217 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains/Cuda.cpp
test/Driver/openmp-offload-gpu.c

index 6378735a8766387b9750b4cd0d7c579a42835406..349f9e4f51a91181cdcd98471d673566a313e462 100644 (file)
@@ -500,6 +500,10 @@ void CudaToolChain::addClangTargetOptions(
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
 
   if (LibDeviceFile.empty()) {
+    if (DeviceOffloadingKind == Action::OFK_OpenMP &&
+        DriverArgs.hasArg(options::OPT_S))
+      return;
+
     getDriver().Diag(diag::err_drv_no_cuda_libdevice) << GpuArch;
     return;
   }
index 81e1dfcb98162e276d5f0115b77f04d2a71c8799..8558a36c6722264b18f940d376d2bd1f13133377 100644 (file)
 // RUN:   | FileCheck -check-prefix=CHK-FLAG-NOLIBDEVICE %s
 
 // CHK-FLAG-NOLIBDEVICE-NOT: error:{{.*}}sm_60
+
+/// ###########################################################################
+
+/// Check that error is not thrown by toolchain when no cuda lib device is found when using -S.
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -S -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 \
+// RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-NOLIBDEVICE %s
+
+// CHK-NOLIBDEVICE-NOT: error:{{.*}}sm_60