From db94c3fb665e2c2a8bce25beeb069ff1728d5e19 Mon Sep 17 00:00:00 2001
From: foreman
Date: Mon, 18 Jan 2016 17:19:01 -0500
Subject: [PATCH] P4 to Git Change 1228628 by wchau@wchau_WIN_OCL_HSA on
2016/01/18 17:02:40
SWDEV-79308 - Resubmit of CL1228064 with restriction of mininum scratch buffer size of 64K if a scratch buffer is needed.
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.
Made sure the scratch buffer size is aligned with 64K boundary
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuresource.cpp#235 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp#156 edit
---
rocclr/runtime/device/gpu/gpuresource.cpp | 4 ++--
.../device/gpu/gslbe/src/rt/GSLDevice.cpp | 17 ++++++++++++++++-
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/rocclr/runtime/device/gpu/gpuresource.cpp b/rocclr/runtime/device/gpu/gpuresource.cpp
index aa3d1fdf07..d601553123 100644
--- a/rocclr/runtime/device/gpu/gpuresource.cpp
+++ b/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/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp b/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp
index 19de5ed4f9..5edfdea48c 100644
--- a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp
+++ b/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp
@@ -1217,7 +1217,7 @@ CALGSLDevice::calcScratchBufferSize(uint32 regNum) const
{
gslProgramTargetEnum target = GSL_COMPUTE_PROGRAM;
- // Determine the scratch size we need to allocate.
+ // Determine the scratch size we need to allocate
cmScratchSpaceNeededPerShaderStage scratchSpacePerShaderStage;
memset(&scratchSpacePerShaderStage, 0, sizeof(scratchSpacePerShaderStage));
uint32 scratchBufferSizes[gslProgramTarget_COUNT];
@@ -1231,6 +1231,21 @@ 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)
+ if (scratchBufferSizes[target] > 0)
+ {
+ scratchBufferSizes[target] = (scratchBufferSizes[target] >> 2) & 0xFFFF0000;
+
+ if (scratchBufferSizes[target] == 0) { // assign minimum scratch buffer size of 64K
+ scratchBufferSizes[target] = 0x10000;
+ }
+ }
+
return scratchBufferSizes[target];
}