Skip to content

Commit

Permalink
[Cuda] Reintroduce catching and reporting of bad_alloc for event obje…
Browse files Browse the repository at this point in the history
…ct creation

Reintroduces the changes from commit c4ae460, which were reverted
in related merged commit 1b4a8b8 due to being mistakenly deleted
and omitted on rebasing.
  • Loading branch information
GeorgeWeb committed Sep 25, 2024
1 parent 7ecf64d commit 78947c1
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions source/adapters/cuda/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,17 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventCreateWithNativeHandle(

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

*phEvent = ur_event_handle_t_::makeWithNative(
hContext, reinterpret_cast<CUevent>(hNativeEvent));
try {
EventPtr =
std::unique_ptr<ur_event_handle_t_>(ur_event_handle_t_::makeWithNative(
hContext, reinterpret_cast<CUevent>(hNativeEvent)));
} catch (const std::bad_alloc &) {
return UR_RESULT_ERROR_OUT_OF_HOST_MEMORY;
} catch (...) {
return UR_RESULT_ERROR_UNKNOWN;
}

*phEvent = EventPtr.release();

return UR_RESULT_SUCCESS;
}

0 comments on commit 78947c1

Please sign in to comment.