Skip to content

Commit 4037e92

Browse files
authored
[SYCL] Add UR error code when throwing exception from Scheduler::enqueueCommandForCG (#18517)
Add UR error code when throwing exception from Scheduler::enqueueCommandForCG. Remove message string from non adapter specific error exception in checkUrResult as it's only used in the adapter specific error path. This is related to oneapi-src/unified-runtime#2440 and #18423 where `clEnqueueMemFillINTEL` was failing with -30 (`CL_INVALID_VALUE`) but no detail was provided in the log: ``` terminate called after throwing an instance of 'sycl::_V1::exception' what(): Enqueue process failed. Aborted (core dumped) ``` This is because the first exception thrown from `checkUrResult` was being hidden by a second exception thrown from `Scheduler::enqueueCommandForCG`. I've modified this second exception to include the UR result. The output now looks like: ``` terminate called after throwing an instance of 'sycl::_V1::exception' what(): Enqueue process failed. Native API failed. Native API returns: 4 (UR_RESULT_ERROR_INVALID_VALUE) ```
1 parent 7cac7a1 commit 4037e92

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

sycl/source/detail/adapter.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ class Adapter {
6666
/// \throw SYCL 2020 exception(errc) if ur_result is not UR_RESULT_SUCCESS
6767
template <sycl::errc errc = sycl::errc::runtime>
6868
void checkUrResult(ur_result_t ur_result) const {
69-
const char *message = nullptr;
7069
if (ur_result == UR_RESULT_ERROR_ADAPTER_SPECIFIC) {
70+
const char *message = nullptr;
7171
int32_t adapter_error = 0;
7272
ur_result = call_nocheck<UrApiKind::urAdapterGetLastError>(
7373
MAdapter, &message, &adapter_error);
@@ -84,9 +84,7 @@ class Adapter {
8484
throw sycl::detail::set_ur_error(
8585
sycl::exception(sycl::make_error_code(errc),
8686
__SYCL_UR_ERROR_REPORT +
87-
sycl::detail::codeToString(ur_result) +
88-
(message ? "\n" + std::string(message) + "\n"
89-
: std::string{})),
87+
sycl::detail::codeToString(ur_result)),
9088
ur_result);
9189
}
9290
}

sycl/source/detail/scheduler/scheduler.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,14 @@ void Scheduler::enqueueCommandForCG(EventImplPtr NewEvent,
188188
try {
189189
bool Enqueued = GraphProcessor::enqueueCommand(
190190
NewCmd, Lock, Res, ToCleanUp, NewCmd, Blocking);
191-
if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult)
192-
throw exception(make_error_code(errc::runtime),
193-
"Enqueue process failed.");
191+
if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) {
192+
throw sycl::detail::set_ur_error(
193+
sycl::exception(sycl::make_error_code(errc::runtime),
194+
std::string("Enqueue process failed.\n") +
195+
__SYCL_UR_ERROR_REPORT +
196+
sycl::detail::codeToString(Res.MErrCode)),
197+
Res.MErrCode);
198+
}
194199
} catch (...) {
195200
// enqueueCommand() func and if statement above may throw an exception,
196201
// so destroy required resources to avoid memory leak

0 commit comments

Comments
 (0)