-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[Clang] Hide offload-arch initialization errors behind verbose flag
#151964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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 this. 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.
|
@llvm/pr-subscribers-backend-amdgpu Author: Joseph Huber (jhuber6) ChangesSummary: Full diff: https://github.com/llvm/llvm-project/pull/151964.diff 2 Files Affected:
diff --git a/clang/tools/offload-arch/AMDGPUArchByHIP.cpp b/clang/tools/offload-arch/AMDGPUArchByHIP.cpp
index 02431bf909d6d..11cff4f5ecdbe 100644
--- a/clang/tools/offload-arch/AMDGPUArchByHIP.cpp
+++ b/clang/tools/offload-arch/AMDGPUArchByHIP.cpp
@@ -165,8 +165,9 @@ int printGPUsByHIP() {
llvm::sys::DynamicLibrary::getPermanentLibrary(DynamicHIPPath.c_str(),
&ErrMsg));
if (!DynlibHandle->isValid()) {
- llvm::errs() << "Failed to load " << DynamicHIPPath << ": " << ErrMsg
- << '\n';
+ if (Verbose)
+ llvm::errs() << "Failed to load " << DynamicHIPPath << ": " << ErrMsg
+ << '\n';
return 1;
}
diff --git a/clang/tools/offload-arch/NVPTXArch.cpp b/clang/tools/offload-arch/NVPTXArch.cpp
index c7b7fcdf80500..11ea2e79cd279 100644
--- a/clang/tools/offload-arch/NVPTXArch.cpp
+++ b/clang/tools/offload-arch/NVPTXArch.cpp
@@ -21,6 +21,8 @@
using namespace llvm;
+extern cl::opt<bool> Verbose;
+
typedef enum cudaError_enum {
CUDA_SUCCESS = 0,
CUDA_ERROR_NO_DEVICE = 100,
@@ -78,7 +80,10 @@ static int handleError(CUresult Err) {
int printGPUsByCUDA() {
// Attempt to load the NVPTX driver runtime.
if (llvm::Error Err = loadCUDA()) {
- logAllUnhandledErrors(std::move(Err), llvm::errs());
+ if (Verbose)
+ logAllUnhandledErrors(std::move(Err), llvm::errs());
+ else
+ consumeError(std::move(Err));
return 1;
}
|
|
@llvm/pr-subscribers-clang Author: Joseph Huber (jhuber6) ChangesSummary: Full diff: https://github.com/llvm/llvm-project/pull/151964.diff 2 Files Affected:
diff --git a/clang/tools/offload-arch/AMDGPUArchByHIP.cpp b/clang/tools/offload-arch/AMDGPUArchByHIP.cpp
index 02431bf909d6d..11cff4f5ecdbe 100644
--- a/clang/tools/offload-arch/AMDGPUArchByHIP.cpp
+++ b/clang/tools/offload-arch/AMDGPUArchByHIP.cpp
@@ -165,8 +165,9 @@ int printGPUsByHIP() {
llvm::sys::DynamicLibrary::getPermanentLibrary(DynamicHIPPath.c_str(),
&ErrMsg));
if (!DynlibHandle->isValid()) {
- llvm::errs() << "Failed to load " << DynamicHIPPath << ": " << ErrMsg
- << '\n';
+ if (Verbose)
+ llvm::errs() << "Failed to load " << DynamicHIPPath << ": " << ErrMsg
+ << '\n';
return 1;
}
diff --git a/clang/tools/offload-arch/NVPTXArch.cpp b/clang/tools/offload-arch/NVPTXArch.cpp
index c7b7fcdf80500..11ea2e79cd279 100644
--- a/clang/tools/offload-arch/NVPTXArch.cpp
+++ b/clang/tools/offload-arch/NVPTXArch.cpp
@@ -21,6 +21,8 @@
using namespace llvm;
+extern cl::opt<bool> Verbose;
+
typedef enum cudaError_enum {
CUDA_SUCCESS = 0,
CUDA_ERROR_NO_DEVICE = 100,
@@ -78,7 +80,10 @@ static int handleError(CUresult Err) {
int printGPUsByCUDA() {
// Attempt to load the NVPTX driver runtime.
if (llvm::Error Err = loadCUDA()) {
- logAllUnhandledErrors(std::move(Err), llvm::errs());
+ if (Verbose)
+ logAllUnhandledErrors(std::move(Err), llvm::errs());
+ else
+ consumeError(std::move(Err));
return 1;
}
|
offload-arch initialization erros behind verbose flagoffload-arch initialization errors behind verbose flag
| llvm::errs() << "Failed to load " << DynamicHIPPath << ": " << ErrMsg | ||
| << '\n'; | ||
| if (Verbose) | ||
| llvm::errs() << "Failed to load " << DynamicHIPPath << ": " << ErrMsg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Errors should start with lowercase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably do a big monolithic NFC that updates a lot of cases like this.
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.