Skip to content

[SYCL] Catch exceptions thrown in destructors #14808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 2, 2024
Merged
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
12 changes: 8 additions & 4 deletions sycl/source/detail/device_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ device_impl::device_impl(ur_native_handle_t InteropDeviceHandle,
}

device_impl::~device_impl() {
// TODO catch an exception and put it to list of asynchronous exceptions
const PluginPtr &Plugin = getPlugin();
ur_result_t Err = Plugin->call_nocheck(urDeviceRelease, MDevice);
__SYCL_CHECK_OCL_CODE_NO_EXC(Err);
try {
// TODO catch an exception and put it to list of asynchronous exceptions
const PluginPtr &Plugin = getPlugin();
ur_result_t Err = Plugin->call_nocheck(urDeviceRelease, MDevice);
__SYCL_CHECK_OCL_CODE_NO_EXC(Err);
} catch (std::exception &e) {
__SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~device_impl", e);
}
}

bool device_impl::is_affinity_supported(
Expand Down
21 changes: 15 additions & 6 deletions sycl/source/detail/kernel_program_cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,14 @@ class KernelProgramCache {
this->State.store(InitialState);
}
~ProgramBuildResult() {
if (Val) {
ur_result_t Err = Plugin->call_nocheck(urProgramRelease, Val);
__SYCL_CHECK_OCL_CODE_NO_EXC(Err);
try {
if (Val) {
ur_result_t Err = Plugin->call_nocheck(urProgramRelease, Val);
__SYCL_CHECK_OCL_CODE_NO_EXC(Err);
}
} catch (std::exception &e) {
__SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~ProgramBuildResult",
e);
}
}
};
Expand Down Expand Up @@ -133,9 +138,13 @@ class KernelProgramCache {
Val.first = nullptr;
}
~KernelBuildResult() {
if (Val.first) {
ur_result_t Err = Plugin->call_nocheck(urKernelRelease, Val.first);
__SYCL_CHECK_OCL_CODE_NO_EXC(Err);
try {
if (Val.first) {
ur_result_t Err = Plugin->call_nocheck(urKernelRelease, Val.first);
__SYCL_CHECK_OCL_CODE_NO_EXC(Err);
}
} catch (std::exception &e) {
__SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~KernelBuildResult", e);
}
}
};
Expand Down
Loading