Skip to content
Open
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
19 changes: 12 additions & 7 deletions unified-runtime/source/adapters/cuda/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,19 @@ struct ur_context_handle_t_ : ur::cuda::handle_base {
UR_CHECK_ERROR(urAdapterRetain(ur::cuda::adapter));
};

~ur_context_handle_t_() {
if (MemoryPoolHost) {
umfPoolDestroy(MemoryPoolHost);
~ur_context_handle_t_() noexcept {
try {
if (MemoryPoolHost) {
umfPoolDestroy(MemoryPoolHost);
}
if (MemoryProviderHost) {
umfMemoryProviderDestroy(MemoryProviderHost);
}
urAdapterRelease(ur::cuda::adapter);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think any of those functions (umfPoolDestroy/umfMemoryProviderDestroy/urAdapterRelease) can throw a reasonable exception. Since urAdapterRelease isn't wrapped with UR_CHECK_ERROR the try catch block seems redundant.

} catch (...) {
UR_LOG(ERR, "Exception in context destructor");
assert(false && "Exception in context destructor");
}
if (MemoryProviderHost) {
umfMemoryProviderDestroy(MemoryProviderHost);
}
UR_CHECK_ERROR(urAdapterRelease(ur::cuda::adapter));
}

void invokeExtendedDeleters() {
Expand Down
9 changes: 7 additions & 2 deletions unified-runtime/source/adapters/hip/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,13 @@ struct ur_context_handle_t_ : ur::hip::handle_base {
UR_CHECK_ERROR(urAdapterRetain(ur::hip::adapter));
};

~ur_context_handle_t_() {
UR_CHECK_ERROR(urAdapterRelease(ur::hip::adapter));
~ur_context_handle_t_() noexcept {
try {
urAdapterRelease(ur::hip::adapter);
} catch (...) {
UR_LOG(ERR, "Exception in context destructor");
assert(false && "Exception in context destructor");
}
}

ur_context_handle_t_(const ur_context_handle_t_ &) = delete;
Expand Down