From 90b40c60e1be88a048c953bceb418633b7918dce Mon Sep 17 00:00:00 2001
From: foreman
Date: Fri, 15 Jan 2016 11:26:41 -0500
Subject: [PATCH] P4 to Git Change 1228064 by wchau@wchau_WIN_OCL_HSA on
2016/01/15 11:18:23
SWDEV-79308 - Resubmit of CL1226881 with the fix of the SC sanity check issue. Reduce the total scratch buffer size by a factor of 4, which in effect reducing the max. scratch waves from 32 to 8, to avoid the required total scratch buffer
size exceeds the available local memory.
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuresource.cpp#233 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp#154 edit
[ROCm/clr commit: 685d1164eed074ddd4b7dd42ec7c9ac5022ba56e]
---
projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp | 4 ++--
.../rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp | 8 ++++++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp b/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp
index aa3d1fdf07..0042ae68f4 100644
--- a/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp
+++ b/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp
@@ -1937,8 +1937,8 @@ ResourceCache::findCalResource(Resource::CalResourceDesc* desc)
GslResourceReference* ref = NULL;
size_t size = getResourceSize(desc);
- // Early exit if resource is too big
- if (size >= cacheSizeLimit_ || desc->skipRsrcCache_) {
+ // Early exit if resource is too big or it is for scratch buffer
+ if (size >= cacheSizeLimit_ || desc->skipRsrcCache_ || desc->scratch_ ) {
//! \note we may need to free the cache here to reduce memory pressure
return ref;
}
diff --git a/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp b/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp
index 19de5ed4f9..4256a3cc3d 100644
--- a/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp
+++ b/projects/clr/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp
@@ -1231,6 +1231,14 @@ CALGSLDevice::calcScratchBufferSize(uint32 regNum) const
m_cs->CalcAllScratchBufferSizes(enabledShadersFlag, scratchSpacePerShaderStage,
scratchBufferSizes);
+
+ // SWDEV-79308:
+ // Reduce the total scratch buffer size by a factor of 4, which in effect reducing the
+ // max. scratch waves from 32 to 8. This will avoid the required total scratch buffer
+ // size exceeds the available local memory. (Note: the scratch buffer size needs to
+ // be 64K alignment)
+ scratchBufferSizes[target] = (scratchBufferSizes[target] >> 2) & 0xFFFF0000;
+
return scratchBufferSizes[target];
}