Skip to content

Commit 78947c1

Browse files
author
Georgi Mirazchiyski
committed
[Cuda] Reintroduce catching and reporting of bad_alloc for event object creation
Reintroduces the changes from commit c4ae460, which were reverted in related merged commit 1b4a8b8 due to being mistakenly deleted and omitted on rebasing.
1 parent 7ecf64d commit 78947c1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

source/adapters/cuda/event.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,17 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventCreateWithNativeHandle(
290290

291291
std::unique_ptr<ur_event_handle_t_> EventPtr{nullptr};
292292

293-
*phEvent = ur_event_handle_t_::makeWithNative(
294-
hContext, reinterpret_cast<CUevent>(hNativeEvent));
293+
try {
294+
EventPtr =
295+
std::unique_ptr<ur_event_handle_t_>(ur_event_handle_t_::makeWithNative(
296+
hContext, reinterpret_cast<CUevent>(hNativeEvent)));
297+
} catch (const std::bad_alloc &) {
298+
return UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
299+
} catch (...) {
300+
return UR_RESULT_ERROR_UNKNOWN;
301+
}
302+
303+
*phEvent = EventPtr.release();
295304

296305
return UR_RESULT_SUCCESS;
297306
}

0 commit comments

Comments
 (0)