P4 to Git Change 1547415 by gandryey@gera-w8 on 2018/04/27 16:14:51

SWDEV-79445 - OCL generic changes and code clean-up
	- Persistent memory failure could be propagated to the app without the second attempt after resource cache release. Try to allocate memory again after resource cache release.

Affected files ...

... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.cpp#65 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.hpp#23 edit


[ROCm/clr commit: 402f99f3e6]
This commit is contained in:
foreman
2018-04-27 16:22:03 -04:00
parent b316ebcc3f
commit 2919f24b17
2 changed files with 12 additions and 4 deletions
@@ -40,10 +40,14 @@ GpuMemoryReference* GpuMemoryReference::Create(const Device& dev,
GpuMemoryReference* memRef = new (gpuMemSize) GpuMemoryReference(dev);
if (memRef != nullptr) {
result = dev.iDev()->CreateGpuMemory(createInfo, &memRef[1], &memRef->gpuMem_);
if ((result != Pal::Result::Success) &&
// Free cache if PAL failed allocation
dev.resourceCache().free()) {
// If cache was freed, then try to allocate again
result = dev.iDev()->CreateGpuMemory(createInfo, &memRef[1], &memRef->gpuMem_);
}
if (result != Pal::Result::Success) {
memRef->release();
// Free cache if PAL failed allocation
dev.resourceCache().free();
return nullptr;
}
}
@@ -2034,14 +2038,17 @@ GpuMemoryReference* ResourceCache::findGpuMemory(Resource::Descriptor* desc, Pal
}
// ================================================================================================
void ResourceCache::free(size_t minCacheEntries) {
bool ResourceCache::free(size_t minCacheEntries) {
bool result = false;
if (minCacheEntries < resCache_.size()) {
result = true;
// Clear the cache
while (static_cast<int>(cacheSize_) > 0) {
removeLast();
}
CondLog((cacheSize_ != 0), "Incorrect size for cache release!");
}
return result;
}
// ================================================================================================
@@ -548,7 +548,8 @@ class ResourceCache : public amd::HeapObject {
Pal::gpusize* offset);
//! Destroys cache
void free(size_t minCacheEntries = 0);
//! Returns true if cache was freed and false if cache is already empty.
bool free(size_t minCacheEntries = 0);
private:
//! Disable copy constructor