From ec29b52ae87817de7f8c5c20765e6376f56fdb9c Mon Sep 17 00:00:00 2001
From: foreman
Date: Fri, 12 Jan 2018 18:15:39 -0500
Subject: [PATCH] P4 to Git Change 1503305 by gandryey@gera-w8 on 2018/01/12
18:09:51
SWDEV-142224 - [OCL] OCL runtime hang in multithread app with extended tests
- Lock the resource cache only if a resource will be placed into the cache. Views, allocated/destroyed dynamically on the queues, won't be placed into the cache and lock should not be called for them
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.cpp#46 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.hpp#15 edit
---
rocclr/runtime/device/pal/palresource.cpp | 2 +-
rocclr/runtime/device/pal/palresource.hpp | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/rocclr/runtime/device/pal/palresource.cpp b/rocclr/runtime/device/pal/palresource.cpp
index f84ec1517d..73565bac0f 100644
--- a/rocclr/runtime/device/pal/palresource.cpp
+++ b/rocclr/runtime/device/pal/palresource.cpp
@@ -1837,7 +1837,6 @@ ResourceCache::~ResourceCache() { free(); }
//! \note the cache works in FILO mode
bool ResourceCache::addGpuMemory(Resource::Descriptor* desc, GpuMemoryReference* ref) {
- amd::ScopedLock l(&lockCacheOps_);
bool result = false;
size_t size = ref->iMem()->Desc().size;
@@ -1845,6 +1844,7 @@ bool ResourceCache::addGpuMemory(Resource::Descriptor* desc, GpuMemoryReference*
if (((desc->type_ == Resource::Local) || (desc->type_ == Resource::Persistent) ||
(desc->type_ == Resource::Remote) || (desc->type_ == Resource::RemoteUSWC)) &&
(size < cacheSizeLimit_) && !desc->SVMRes_) {
+ amd::ScopedLock l(&lockCacheOps_);
// Validate the cache size limit. Loop until we have enough space
while ((cacheSize_ + size) > cacheSizeLimit_) {
removeLast();
diff --git a/rocclr/runtime/device/pal/palresource.hpp b/rocclr/runtime/device/pal/palresource.hpp
index e7f91440fd..b315fbcae4 100644
--- a/rocclr/runtime/device/pal/palresource.hpp
+++ b/rocclr/runtime/device/pal/palresource.hpp
@@ -478,8 +478,8 @@ class ResourceCache : public amd::HeapObject {
amd::Monitor lockCacheOps_; //!< Lock to serialise cache access
- size_t cacheSize_; //!< Current cache size in bytes
- size_t cacheSizeLimit_; //!< Cache size limit in bytes
+ size_t cacheSize_; //!< Current cache size in bytes
+ const size_t cacheSizeLimit_; //!< Cache size limit in bytes
//! CAL resource cache
std::list > resCache_;