Skip to content

Commit e81d899

Browse files
jhuber6krishna2803
authored andcommitted
[Clang] Hide offload-arch initialization errors behind verbose flag (llvm#151964)
Summary: This tool tries to print the offloading architectures. If the user doesn't have the HIP libraries or the CUDA libraries it will print and error. This isn't super helpful since we're just querying things. So, for example, if we're on an AMD machine with no CUDA you'll get the AMD GPUs and then an error message saying that CUDA wasn't found. This silences the error just on failing to find the library unless verbose is on.
1 parent f9c1060 commit e81d899

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

clang/tools/offload-arch/AMDGPUArchByHIP.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,9 @@ int printGPUsByHIP() {
165165
llvm::sys::DynamicLibrary::getPermanentLibrary(DynamicHIPPath.c_str(),
166166
&ErrMsg));
167167
if (!DynlibHandle->isValid()) {
168-
llvm::errs() << "Failed to load " << DynamicHIPPath << ": " << ErrMsg
169-
<< '\n';
168+
if (Verbose)
169+
llvm::errs() << "Failed to load " << DynamicHIPPath << ": " << ErrMsg
170+
<< '\n';
170171
return 1;
171172
}
172173

clang/tools/offload-arch/NVPTXArch.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
using namespace llvm;
2323

24+
extern cl::opt<bool> Verbose;
25+
2426
typedef enum cudaError_enum {
2527
CUDA_SUCCESS = 0,
2628
CUDA_ERROR_NO_DEVICE = 100,
@@ -78,7 +80,10 @@ static int handleError(CUresult Err) {
7880
int printGPUsByCUDA() {
7981
// Attempt to load the NVPTX driver runtime.
8082
if (llvm::Error Err = loadCUDA()) {
81-
logAllUnhandledErrors(std::move(Err), llvm::errs());
83+
if (Verbose)
84+
logAllUnhandledErrors(std::move(Err), llvm::errs());
85+
else
86+
consumeError(std::move(Err));
8287
return 1;
8388
}
8489

0 commit comments

Comments
 (0)