Skip to content

[OpenCL-aot] Return a Friendlier Error When Build Kernel Failed #12124

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

Merged
merged 3 commits into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions opencl/opencl-aot/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ int main(int Argc, char *Argv[]) {
break;
}

std::string CompilerBuildLog;
std::string CompilerBuildLog, CompilerBuildLogMessage;
std::tie(CompilerBuildLog, ErrorMessage, std::ignore) =
getCompilerBuildLog(ProgramUPtr, DeviceId);

Expand All @@ -604,18 +604,20 @@ int main(int Argc, char *Argv[]) {
}

if (!CompilerBuildLog.empty()) {
std::string CompilerBuildLogMessage = "\n" +
CmdToCmdInfoMap[OptCommand].first +
" log:\n" + CompilerBuildLog + '\n';
if (!ErrorMessage.empty())
std::cerr << CompilerBuildLogMessage;
else
logs() << CompilerBuildLogMessage;
// According to the return value of getCompilerBuildLog(), ErrorMessage is
// always empty if CompilerBuildLog is not empty.
CompilerBuildLogMessage = "\n" + CmdToCmdInfoMap[OptCommand].first +
" log:\n" + CompilerBuildLog + '\n';
logs() << CompilerBuildLogMessage;
}

if (clFailed(CLErr)) {
std::string ErrMsg =
"Failed to " + CmdToCmdInfoMap[OptCommand].first + ": ";
// will print CompilerBuildLogMessage when build failed in case verbose is
// false, in order to provide a friendlier compile error for users.
if (!verbose)
std::cerr << CompilerBuildLogMessage;
std::cerr << formatCLError(ErrMsg, CLErr) << '\n';
return CLErr;
}
Expand Down