From 1653cb9849c89bbc0d16d3a76d6acc7b07d97ae3 Mon Sep 17 00:00:00 2001
From: foreman
Date: Thu, 26 Oct 2017 12:54:46 -0400
Subject: [PATCH] P4 to Git Change 1475222 by gandryey@gera-lnx-rcf on
2017/10/26 12:45:19
SWDEV-79445 - Don't enable HostMemoryDirectAccess flag for persistent memory
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocmemory.cpp#27 edit
[ROCm/clr commit: 66e0d09af0000da51491923b78a8f64a03b81f5d]
---
projects/clr/rocclr/runtime/device/rocm/rocmemory.cpp | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/projects/clr/rocclr/runtime/device/rocm/rocmemory.cpp b/projects/clr/rocclr/runtime/device/rocm/rocmemory.cpp
index ef331176a7..c464ce391e 100644
--- a/projects/clr/rocclr/runtime/device/rocm/rocmemory.cpp
+++ b/projects/clr/rocclr/runtime/device/rocm/rocmemory.cpp
@@ -149,7 +149,8 @@ void* Memory::cpuMap(device::VirtualDevice& vDev, uint flags, uint startLayer, u
assert(mapTarget != nullptr);
- if (!isHostMemDirectAccess()) {
+ const cl_mem_flags memFlags = owner()->getMemFlags();
+ if (!isHostMemDirectAccess() && !(memFlags & CL_MEM_USE_PERSISTENT_MEM_AMD)) {
if (!vDev.blitMgr().readBuffer(*this, mapTarget, amd::Coord3D(0), amd::Coord3D(size()), true)) {
decIndMapCount();
return nullptr;
@@ -160,7 +161,8 @@ void* Memory::cpuMap(device::VirtualDevice& vDev, uint flags, uint startLayer, u
}
void Memory::cpuUnmap(device::VirtualDevice& vDev) {
- if (!isHostMemDirectAccess()) {
+ const cl_mem_flags memFlags = owner()->getMemFlags();
+ if (!isHostMemDirectAccess() && !(memFlags & CL_MEM_USE_PERSISTENT_MEM_AMD)) {
if (!vDev.blitMgr().writeBuffer(mapMemory_->getHostMem(), *this, amd::Coord3D(0),
amd::Coord3D(size()), true)) {
LogError("[OCL] Fail sync the device memory on cpuUnmap");
@@ -647,7 +649,6 @@ bool Buffer::create() {
if (deviceMemory_ == nullptr) {
return false;
}
- flags_ |= HostMemoryDirectAccess | MemoryCpuUncached;
owner()->setHostMem(host_ptr);
return true;
}
@@ -1030,8 +1031,8 @@ void* Image::allocMapTarget(const amd::Coord3D& origin, const amd::Coord3D& regi
size_t elementSize = image->getImageFormat().getElementSize();
size_t offset = origin[0] * elementSize;
-
- if (pHostMem == nullptr) {
+ const cl_mem_flags memFlags = owner()->getMemFlags();
+ if ((pHostMem == nullptr) || (memFlags & CL_MEM_USE_PERSISTENT_MEM_AMD)) {
if (indirectMapCount_ == 1) {
if (!allocateMapMemory(owner()->getSize())) {
decIndMapCount();