From 7237cf514f3da2cc7b0ed3f4335ef99d75c406c6 Mon Sep 17 00:00:00 2001
From: foreman
Date: Wed, 11 Nov 2015 13:14:27 -0500
Subject: [PATCH] P4 to Git Change 1210047 by wchau@wchau_WINDOWS7_OCL on
2015/11/11 13:06:48
SWDEV-80450 - Fix the issue of app context reference count > 0 after app termination by using device context for the mapped buffer/image resource.
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.hpp#155 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpumemory.cpp#123 edit
---
rocclr/runtime/device/gpu/gpudevice.hpp | 3 +++
rocclr/runtime/device/gpu/gpumemory.cpp | 8 ++++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/rocclr/runtime/device/gpu/gpudevice.hpp b/rocclr/runtime/device/gpu/gpudevice.hpp
index df65c498f9..5653973eb4 100644
--- a/rocclr/runtime/device/gpu/gpudevice.hpp
+++ b/rocclr/runtime/device/gpu/gpudevice.hpp
@@ -467,6 +467,9 @@ public:
//! Gets the GPU resource associated with the global heap
const Memory& globalMem() const { return heap_.resource(); }
+ //! Gets the device context object
+ amd::Context& context() const { return *context_; }
+
//! Gets the global heap object
const Heap& heap() const { return heap_; }
diff --git a/rocclr/runtime/device/gpu/gpumemory.cpp b/rocclr/runtime/device/gpu/gpumemory.cpp
index 0534ffe201..3102545416 100644
--- a/rocclr/runtime/device/gpu/gpumemory.cpp
+++ b/rocclr/runtime/device/gpu/gpumemory.cpp
@@ -900,8 +900,8 @@ Memory::allocMapTarget(
if (memory == NULL) {
// for map target of svm buffer , we need use svm host ptr
- memory = new(owner()->getContext())
- amd::Buffer(owner()->getContext(), flag, owner()->getSize());
+ memory = new(dev().context())
+ amd::Buffer(dev().context(), flag, owner()->getSize());
Memory* gpuMemory;
do {
@@ -1242,8 +1242,8 @@ Image::allocMapTarget(
// Allocate a new buffer to use as the map target
//! @note Allocate a 1D buffer, since CAL issues with 3D
//! Also HW doesn't support untiled images
- memory = new (owner()->getContext())
- amd::Buffer(owner()->getContext(), 0,
+ memory = new (dev().context())
+ amd::Buffer(dev().context(), 0,
cal()->width_ * height * depth * elementSize());
memory->setVirtualDevice(owner()->getVirtualDevice());