From 043029e43bfdfa4fc2f7571355a383e9c3a8e3dd Mon Sep 17 00:00:00 2001
From: foreman
Date: Mon, 2 Apr 2018 11:28:59 -0400
Subject: [PATCH] P4 to Git Change 1535454 by todli@todli-win-opencl-kv1 on
2018/04/02 11:12:16
SWDEV-133452 - 1.Add HostMemoryDirectAccess flag to SDI ExternalPhysical memory
2.Disable host writeBuffer for SDI ExternalPhysical memory
3.Support marker offset for SDI WriteMarker in Runtime
http://ocltc.amd.com/reviews/r/14518/
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palblit.cpp#19 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palmemory.cpp#19 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#81 edit
[ROCm/clr commit: e7fb98dd9462152428d637e9f1745e0e0a427592]
---
.../clr/rocclr/runtime/device/pal/palblit.cpp | 16 ++++++++++++----
.../clr/rocclr/runtime/device/pal/palmemory.cpp | 1 +
.../clr/rocclr/runtime/device/pal/palvirtual.cpp | 4 ++++
3 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/projects/clr/rocclr/runtime/device/pal/palblit.cpp b/projects/clr/rocclr/runtime/device/pal/palblit.cpp
index 40030668df..c32a6aa687 100644
--- a/projects/clr/rocclr/runtime/device/pal/palblit.cpp
+++ b/projects/clr/rocclr/runtime/device/pal/palblit.cpp
@@ -298,7 +298,9 @@ bool DmaBlitManager::writeBuffer(const void* srcHost, device::Memory& dstMemory,
const amd::Coord3D& origin, const amd::Coord3D& size,
bool entire) const {
// Use host copy if memory has direct access or it's persistent
- if (setup_.disableWriteBuffer_ || gpuMem(dstMemory).isHostMemDirectAccess() ||
+ if (setup_.disableWriteBuffer_ ||
+ (gpuMem(dstMemory).isHostMemDirectAccess() &&
+ (gpuMem(dstMemory).memoryType() != Resource::ExternalPhysical)) ||
gpuMem(dstMemory).isPersistentDirectMap()) {
return HostBlitManager::writeBuffer(srcHost, dstMemory, origin, size, entire);
} else {
@@ -384,7 +386,9 @@ bool DmaBlitManager::writeBufferRect(const void* srcHost, device::Memory& dstMem
const amd::BufferRect& bufRect, const amd::Coord3D& size,
bool entire) const {
// Use host copy if memory has direct access or it's persistent
- if (setup_.disableWriteBufferRect_ || dstMemory.isHostMemDirectAccess() ||
+ if (setup_.disableWriteBufferRect_ ||
+ (dstMemory.isHostMemDirectAccess() &&
+ (gpuMem(dstMemory).memoryType() != Resource::ExternalPhysical)) ||
gpuMem(dstMemory).isPersistentDirectMap()) {
return HostBlitManager::writeBufferRect(srcHost, dstMemory, hostRect, bufRect, size, entire);
} else {
@@ -1926,7 +1930,9 @@ bool KernelBlitManager::writeBuffer(const void* srcHost, device::Memory& dstMemo
bool result = false;
// Use host copy if memory has direct access or it's persistent
- if (setup_.disableWriteBuffer_ || gpuMem(dstMemory).isHostMemDirectAccess() ||
+ if (setup_.disableWriteBuffer_ ||
+ (gpuMem(dstMemory).isHostMemDirectAccess() &&
+ (gpuMem(dstMemory).memoryType() != Resource::ExternalPhysical)) ||
(gpuMem(dstMemory).memoryType() == Resource::Persistent)) {
result = HostBlitManager::writeBuffer(srcHost, dstMemory, origin, size, entire);
synchronize();
@@ -1975,7 +1981,9 @@ bool KernelBlitManager::writeBufferRect(const void* srcHost, device::Memory& dst
bool result = false;
// Use host copy if memory has direct access or it's persistent
- if (setup_.disableWriteBufferRect_ || gpuMem(dstMemory).isHostMemDirectAccess() ||
+ if (setup_.disableWriteBufferRect_ ||
+ (gpuMem(dstMemory).isHostMemDirectAccess() &&
+ (gpuMem(dstMemory).memoryType() != Resource::ExternalPhysical)) ||
gpuMem(dstMemory).isPersistentDirectMap()) {
result = HostBlitManager::writeBufferRect(srcHost, dstMemory, hostRect, bufRect, size, entire);
synchronize();
diff --git a/projects/clr/rocclr/runtime/device/pal/palmemory.cpp b/projects/clr/rocclr/runtime/device/pal/palmemory.cpp
index 4777390de9..b498d5c9e3 100644
--- a/projects/clr/rocclr/runtime/device/pal/palmemory.cpp
+++ b/projects/clr/rocclr/runtime/device/pal/palmemory.cpp
@@ -127,6 +127,7 @@ bool Memory::create(Resource::MemoryType memType, Resource::CreateParams* params
if (result) {
switch (memoryType()) {
case Resource::Pinned:
+ case Resource::ExternalPhysical:
// Marks memory object for direct GPU access to the host memory
flags_ |= HostMemoryDirectAccess;
break;
diff --git a/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp b/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp
index dbfa84e012..bce0b937b9 100644
--- a/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp
+++ b/projects/clr/rocclr/runtime/device/pal/palvirtual.cpp
@@ -2570,7 +2570,11 @@ void VirtualGPU::submitSignal(amd::SignalCommand& vcmd) {
queues_[engineID_]->addCmdMemRef(pGpuMemory->memRef());
queues_[engineID_]->iCmd()->
+#if (PAL_CLIENT_INTERFACE_MAJOR_VERSION < 396)
CmdUpdateBusAddressableMemoryMarker(*(pGpuMemory->iMem()), value);
+#else
+ CmdUpdateBusAddressableMemoryMarker(*(pGpuMemory->iMem()), vcmd.markerOffset(), value);
+#endif
eventEnd(engineID_, gpuEvent);
// Restore the original engine