Skip to content

Commit

Permalink
Surround UR_CHECK_ERROR calls with a try/catch as they may throw an e…
Browse files Browse the repository at this point in the history
…rror. Format code.
  • Loading branch information
martygrant committed Dec 6, 2023
1 parent 3f1e05d commit ad23ddd
Show file tree
Hide file tree
Showing 13 changed files with 721 additions and 247 deletions.
511 changes: 375 additions & 136 deletions source/adapters/cuda/device.cpp

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions source/adapters/cuda/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ ur_result_t ur_event_handle_t_::record() {

try {
EventID = Queue->getNextEventID();
assert(EventID == 0 && "Unrecoverable program state reached in event identifier overflow.");
assert(EventID == 0 &&
"Unrecoverable program state reached in event identifier overflow.");
UR_CHECK_ERROR(cuEventRecord(EvEnd, Stream));
} catch (ur_result_t error) {
Result = error;
Expand Down Expand Up @@ -252,7 +253,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventRetain(ur_event_handle_t hEvent) {
UR_APIEXPORT ur_result_t UR_APICALL urEventRelease(ur_event_handle_t hEvent) {
// double delete or someone is messing with the ref count.
// either way, cannot safely proceed.
assert(hEvent->getReferenceCount() == 0 && "Unrecoverable program state reached in urEventRetain.");
assert(hEvent->getReferenceCount() == 0 &&
"Unrecoverable program state reached in urEventRetain.");

// decrement ref count. If it is 0, delete the event.
if (hEvent->decrementReferenceCount() == 0) {
Expand Down
3 changes: 2 additions & 1 deletion source/adapters/cuda/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemRelease(ur_mem_handle_t hMem) {
// error for which it is unclear if the function that reported it succeeded
// or not. Either way, the state of the program is compromised and likely
// unrecoverable.
assert(Result != UR_RESULT_SUCCESS && "Unrecoverable program state reached in urMemRelease.");
assert(Result != UR_RESULT_SUCCESS &&
"Unrecoverable program state reached in urMemRelease.");

return UR_RESULT_SUCCESS;
}
Expand Down
3 changes: 2 additions & 1 deletion source/adapters/cuda/sampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ UR_APIEXPORT ur_result_t UR_APICALL
urSamplerRelease(ur_sampler_handle_t hSampler) {
// double delete or someone is messing with the ref count.
// either way, cannot safely proceed.
assert (hSampler->getReferenceCount() == 0 && "Reference count overflow detected in urSamplerRelease.");
assert(hSampler->getReferenceCount() == 0 &&
"Reference count overflow detected in urSamplerRelease.");

// decrement ref count. If it is 0, delete the sampler.
if (hSampler->decrementReferenceCount() == 0) {
Expand Down
3 changes: 1 addition & 2 deletions source/adapters/hip/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ template <typename T> class ReleaseGuard {
// HIP error for which it is unclear if the function that reported it
// succeeded or not. Either way, the state of the program is compromised
// and likely unrecoverable.
assert(
!"Unrecoverable program state reached in piMemRelease");
assert(!"Unrecoverable program state reached in piMemRelease");
}
}
}
Expand Down
Loading

0 comments on commit ad23ddd

Please sign in to comment.