Skip to content

Commit

Permalink
[Clang][OpenMP][NVPTX] Fixed failure in openmp-offload-gpu.c if the s…
Browse files Browse the repository at this point in the history
…ystem has CUDA

https://lists.llvm.org/pipermail/openmp-dev/2021-March/003940.html reports
test failure in `openmp-offload-gpu.c`. The failure is, when using `-S` in the
clang driver, it still reports bitcode library doesn't exist. However, it is not
exposed in my local run and Phabiractor test. The reason it escaped from Phabricator
test is, the test machine doesn't have CUDA, so `LibDeviceFile` is empty. In this
case, the check of `OPT_S` will be hit, and we get "expected" result. However, if
the test machine has CUDA, `LibDeviceFile` will not be empty, then the check will
not be done, and it just proceeds, trying to add the bitcode library. The reason
it escaped from my local run is, I didn't build ALL targets, so this case was
marked UNSUPPORTED.

Reviewed By: kkwli0

Differential Revision: https://reviews.llvm.org/D98902
  • Loading branch information
shiltian committed Apr 13, 2021
1 parent f1812a2 commit 53d474a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions clang/lib/Driver/ToolChains/Cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,13 +696,12 @@ void CudaToolChain::addClangTargetOptions(
if (DriverArgs.hasArg(options::OPT_nogpulib))
return;

std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
if (DeviceOffloadingKind == Action::OFK_OpenMP &&
DriverArgs.hasArg(options::OPT_S))
return;

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;
}
Expand Down

0 comments on commit 53d474a

Please sign in to comment.