From bfdbc52e299c6e1afbc3dc96131519e3c52f18b4 Mon Sep 17 00:00:00 2001
From: foreman
Date: Wed, 21 Aug 2019 11:47:51 -0400
Subject: [PATCH] P4 to Git Change 1986743 by gandryey@gera-win10 on 2019/08/21
11:42:44
SWDEV-79445 - OCL generic changes and code clean-up
- Don't attempt to destroy memory object if PAL reference is null
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.cpp#77 edit
[ROCm/clr commit: af240466f9d7333a115d574175ae014b6b4b50ac]
---
.../rocclr/runtime/device/pal/palresource.cpp | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/projects/clr/rocclr/runtime/device/pal/palresource.cpp b/projects/clr/rocclr/runtime/device/pal/palresource.cpp
index fd0796aaa6..09b3b34d8c 100644
--- a/projects/clr/rocclr/runtime/device/pal/palresource.cpp
+++ b/projects/clr/rocclr/runtime/device/pal/palresource.cpp
@@ -178,6 +178,9 @@ GpuMemoryReference::GpuMemoryReference(const Device& dev)
// ================================================================================================
GpuMemoryReference::~GpuMemoryReference() {
+ if (nullptr == iMem()) {
+ return;
+ }
if (gpu_ == nullptr) {
Device::ScopedLockVgpus lock(device_);
// Release all memory objects on all virtual GPUs
@@ -199,15 +202,13 @@ GpuMemoryReference::~GpuMemoryReference() {
if (cpuAddress_ != nullptr) {
iMem()->Unmap();
}
- if (0 != iMem()) {
- if (!(iMem()->Desc().flags.isShared || iMem()->Desc().flags.isExternal ||
- iMem()->Desc().flags.isExternPhys)) {
- // Update free memory size counters
- device_.updateAllocedMemory(iMem()->Desc().preferredHeap, iMem()->Desc().size, true);
- }
- iMem()->Destroy();
- gpuMem_ = nullptr;
+ if (!(iMem()->Desc().flags.isShared || iMem()->Desc().flags.isExternal ||
+ iMem()->Desc().flags.isExternPhys)) {
+ // Update free memory size counters
+ device_.updateAllocedMemory(iMem()->Desc().preferredHeap, iMem()->Desc().size, true);
}
+ iMem()->Destroy();
+ gpuMem_ = nullptr;
}
// ================================================================================================