From 9018bc85cc2ef436235e258db3df5c2995caaa97 Mon Sep 17 00:00:00 2001
From: foreman
Date: Thu, 22 Feb 2018 18:54:16 -0500
Subject: [PATCH] P4 to Git Change 1518569 by gandryey@gera-w8 on 2018/02/22
18:48:33
SWDEV-145750 - SSG Player drop in performance observed when using the OCL Api in 18.10
- Keep persistent memory mapped all time for Linux and Win10
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#73 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.cpp#48 edit
---
rocclr/runtime/device/pal/paldevice.cpp | 7 +++++++
rocclr/runtime/device/pal/palresource.cpp | 3 ++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/rocclr/runtime/device/pal/paldevice.cpp b/rocclr/runtime/device/pal/paldevice.cpp
index 7621350b92..c9775f88a1 100644
--- a/rocclr/runtime/device/pal/paldevice.cpp
+++ b/rocclr/runtime/device/pal/paldevice.cpp
@@ -1281,6 +1281,13 @@ pal::Memory* Device::createBuffer(amd::Memory& owner, bool directAccess) const {
} else if (owner.getMemFlags() & CL_MEM_USE_PERSISTENT_MEM_AMD) {
// Attempt to allocate from persistent heap
result = gpuMemory->create(Resource::Persistent);
+ // Disallow permanent map for Win7 only, since OS will move buffer to sysmem
+ if (IS_LINUX ||
+ // Or Win10
+ (properties().gpuMemoryProperties.flags.supportPerSubmitMemRefs == false)) {
+ void* address = gpuMemory->map(nullptr);
+ CondLog(address == nullptr, "PAL failed lock of persistent memory!");
+ }
} else if (directAccess || (type == Resource::Remote)) {
// Check for system memory allocations
if ((owner.getMemFlags() & (CL_MEM_ALLOC_HOST_PTR | CL_MEM_USE_HOST_PTR)) ||
diff --git a/rocclr/runtime/device/pal/palresource.cpp b/rocclr/runtime/device/pal/palresource.cpp
index 1ee7d2ca37..cd336ebd44 100644
--- a/rocclr/runtime/device/pal/palresource.cpp
+++ b/rocclr/runtime/device/pal/palresource.cpp
@@ -1106,7 +1106,8 @@ void Resource::free() {
}
// Sanity check for the map calls
- if ((mapCount_ != 0) && (memoryType() != Remote) && (memoryType() != RemoteUSWC)) {
+ if ((mapCount_ != 0) && (memoryType() != Remote) &&
+ (memoryType() != RemoteUSWC) && (memoryType() != Persistent)) {
LogWarning("Resource wasn't unlocked, but destroyed!");
}
const bool wait =