Skip to content

[SYCL] Add UR error code when throwing exception from Scheduler::enqueueCommandForCG #18517

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
May 21, 2025
Merged
Show file tree
Hide file tree
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
6 changes: 2 additions & 4 deletions sycl/source/detail/adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class Adapter {
/// \throw SYCL 2020 exception(errc) if ur_result is not UR_RESULT_SUCCESS
template <sycl::errc errc = sycl::errc::runtime>
void checkUrResult(ur_result_t ur_result) const {
const char *message = nullptr;
if (ur_result == UR_RESULT_ERROR_ADAPTER_SPECIFIC) {
const char *message = nullptr;
int32_t adapter_error = 0;
ur_result = call_nocheck<UrApiKind::urAdapterGetLastError>(
MAdapter, &message, &adapter_error);
Expand All @@ -84,9 +84,7 @@ class Adapter {
throw sycl::detail::set_ur_error(
sycl::exception(sycl::make_error_code(errc),
__SYCL_UR_ERROR_REPORT +
sycl::detail::codeToString(ur_result) +
(message ? "\n" + std::string(message) + "\n"
: std::string{})),
sycl::detail::codeToString(ur_result)),
ur_result);
}
}
Expand Down
11 changes: 8 additions & 3 deletions sycl/source/detail/scheduler/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,14 @@ void Scheduler::enqueueCommandForCG(EventImplPtr NewEvent,
try {
bool Enqueued = GraphProcessor::enqueueCommand(
NewCmd, Lock, Res, ToCleanUp, NewCmd, Blocking);
if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult)
throw exception(make_error_code(errc::runtime),
"Enqueue process failed.");
if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) {
throw sycl::detail::set_ur_error(
sycl::exception(sycl::make_error_code(errc::runtime),
std::string("Enqueue process failed.\n") +
__SYCL_UR_ERROR_REPORT +
sycl::detail::codeToString(Res.MErrCode)),
Res.MErrCode);
}
} catch (...) {
// enqueueCommand() func and if statement above may throw an exception,
// so destroy required resources to avoid memory leak
Expand Down