File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change 1212#include < detail/memory_manager.hpp>
1313#include < detail/queue_impl.hpp>
1414#include < detail/usm/usm_impl.hpp>
15+ #include < sycl/detail/common.hpp>
1516
1617namespace sycl {
1718inline namespace _V1 {
@@ -21,16 +22,21 @@ DeviceGlobalUSMMem::~DeviceGlobalUSMMem() {
2122 // removeAssociatedResources is expected to have cleaned up both the pointer
2223 // and the event. When asserts are enabled the values are set, so we check
2324 // these here.
24- auto ContextImplPtr = MAllocatingContext.lock ();
25- if (ContextImplPtr) {
26- if (MPtr != nullptr ) {
27- detail::usm::freeInternal (MPtr, ContextImplPtr.get ());
28- MPtr = nullptr ;
29- }
30- if (MInitEvent != nullptr ) {
31- ContextImplPtr->getAdapter ().call <UrApiKind::urEventRelease>(MInitEvent);
32- MInitEvent = nullptr ;
25+ try {
26+ auto ContextImplPtr = MAllocatingContext.lock ();
27+ if (ContextImplPtr) {
28+ if (MPtr != nullptr ) {
29+ detail::usm::freeInternal (MPtr, ContextImplPtr.get ());
30+ MPtr = nullptr ;
31+ }
32+ if (MInitEvent != nullptr ) {
33+ ContextImplPtr->getAdapter ().call <UrApiKind::urEventRelease>(
34+ MInitEvent);
35+ MInitEvent = nullptr ;
36+ }
3337 }
38+ } catch (std::exception &e) {
39+ __SYCL_REPORT_EXCEPTION_TO_STREAM (" exception in ~DeviceGlobalUSMMem" , e);
3440 }
3541
3642 assert (MPtr == nullptr && " MPtr has not been cleaned up." );
You can’t perform that action at this time.
0 commit comments