Skip to content
Open
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
24 changes: 15 additions & 9 deletions sycl/source/detail/device_global_map_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <detail/memory_manager.hpp>
#include <detail/queue_impl.hpp>
#include <detail/usm/usm_impl.hpp>
#include <sycl/detail/common.hpp>

namespace sycl {
inline namespace _V1 {
Expand All @@ -21,16 +22,21 @@ DeviceGlobalUSMMem::~DeviceGlobalUSMMem() {
// removeAssociatedResources is expected to have cleaned up both the pointer
// and the event. When asserts are enabled the values are set, so we check
// these here.
auto ContextImplPtr = MAllocatingContext.lock();
if (ContextImplPtr) {
if (MPtr != nullptr) {
detail::usm::freeInternal(MPtr, ContextImplPtr.get());
MPtr = nullptr;
}
if (MInitEvent != nullptr) {
ContextImplPtr->getAdapter().call<UrApiKind::urEventRelease>(MInitEvent);
MInitEvent = nullptr;
try {
auto ContextImplPtr = MAllocatingContext.lock();
if (ContextImplPtr) {
if (MPtr != nullptr) {
detail::usm::freeInternal(MPtr, ContextImplPtr.get());
MPtr = nullptr;
}
if (MInitEvent != nullptr) {
ContextImplPtr->getAdapter().call<UrApiKind::urEventRelease>(
MInitEvent);
MInitEvent = nullptr;
}
}
} catch (std::exception &e) {
__SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~DeviceGlobalUSMMem", e);
}

assert(MPtr == nullptr && "MPtr has not been cleaned up.");
Expand Down
Loading