P4 to Git Change 1576247 by gandryey@gera-w8 on 2018/07/04 16:55:54
SWDEV-158017 - CL_DEVICE_GLOBAL_FREE_MEMORY_AMD doesn't work correctly on PAL backend - Change the free memory detection to account possible memory allocation with oversubscription. - Make sure resource cache isn't counted as allocated memory Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#593 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuresource.cpp#244 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuresource.hpp#88 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#94 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.hpp#31 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.cpp#68 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.hpp#25 edit
This commit is contained in:
@@ -1805,7 +1805,8 @@ bool Device::globalFreeMemory(size_t* freeMemory) const {
|
||||
|
||||
// Fill free memory info
|
||||
freeMemory[TotalFreeMemory] =
|
||||
(memInfo.cardMemAvailableBytes + memInfo.cardExtMemAvailableBytes) / Ki;
|
||||
(memInfo.cardMemAvailableBytes + memInfo.cardExtMemAvailableBytes +
|
||||
resourceCache().lclCacheSize()) / Ki;
|
||||
freeMemory[LargestFreeBlock] =
|
||||
std::max(memInfo.cardLargestFreeBlockBytes, memInfo.cardExtLargestFreeBlockBytes) / Ki;
|
||||
if (settings().apuSystem_) {
|
||||
|
||||
@@ -1748,6 +1748,9 @@ bool ResourceCache::addCalResource(Resource::CalResourceDesc* desc, GslResourceR
|
||||
// Add the current resource to the cache
|
||||
resCache_.push_front({descCached, ref});
|
||||
cacheSize_ += size;
|
||||
if (desc->type_ == Resource::Local) {
|
||||
lclCacheSize_ += size;
|
||||
}
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
@@ -1777,10 +1780,13 @@ GslResourceReference* ResourceCache::findCalResource(Resource::CalResourceDesc*
|
||||
(entry->mipLevels_ == desc->mipLevels_) && (entry->isAllocSVM_ == desc->isAllocSVM_) &&
|
||||
(entry->isAllocExecute_ == desc->isAllocExecute_)) {
|
||||
ref = it.second;
|
||||
cacheSize_ -= size;
|
||||
if (entry->type_ == Resource::Local) {
|
||||
lclCacheSize_ -= size;
|
||||
}
|
||||
delete it.first;
|
||||
// Remove the found etry from the cache
|
||||
resCache_.remove(it);
|
||||
cacheSize_ -= size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1823,12 +1829,16 @@ void ResourceCache::removeLast() {
|
||||
|
||||
size_t size = getResourceSize(entry.first);
|
||||
|
||||
cacheSize_ -= size;
|
||||
if (entry.first->type_ == Resource::Local) {
|
||||
lclCacheSize_ -= size;
|
||||
}
|
||||
|
||||
// Delete CalResourceDesc
|
||||
delete entry.first;
|
||||
|
||||
// Destroy GSL resource
|
||||
entry.second->release();
|
||||
cacheSize_ -= size;
|
||||
}
|
||||
|
||||
} // namespace gpu
|
||||
|
||||
@@ -428,7 +428,10 @@ class ResourceCache : public amd::HeapObject {
|
||||
public:
|
||||
//! Default constructor
|
||||
ResourceCache(size_t cacheSizeLimit)
|
||||
: lockCacheOps_("CAL resource cache", true), cacheSize_(0), cacheSizeLimit_(cacheSizeLimit) {}
|
||||
: lockCacheOps_("CAL resource cache", true)
|
||||
, cacheSize_(0)
|
||||
, lclCacheSize_(0)
|
||||
, cacheSizeLimit_(cacheSizeLimit) {}
|
||||
|
||||
//! Default destructor
|
||||
~ResourceCache();
|
||||
@@ -446,6 +449,9 @@ class ResourceCache : public amd::HeapObject {
|
||||
//! Destroys cache
|
||||
bool free(size_t minCacheEntries = 0);
|
||||
|
||||
//! Returns the size of local memory, stored in the cache
|
||||
size_t lclCacheSize() const { return lclCacheSize_; }
|
||||
|
||||
private:
|
||||
//! Disable copy constructor
|
||||
ResourceCache(const ResourceCache&);
|
||||
@@ -462,6 +468,7 @@ class ResourceCache : public amd::HeapObject {
|
||||
amd::Monitor lockCacheOps_; //!< Lock to serialise cache access
|
||||
|
||||
size_t cacheSize_; //!< Current cache size in bytes
|
||||
size_t lclCacheSize_; //!< Local memory stored in the cache
|
||||
size_t cacheSizeLimit_; //!< Cache size limit in bytes
|
||||
|
||||
//! CAL resource cache
|
||||
|
||||
Reference in New Issue
Block a user