summaryrefslogtreecommitdiff
path: root/sc/source/core
diff options
context:
space:
mode:
authorWei Wei <weiwei@multicorewareinc.com>2014-02-28 11:25:33 -0600
committerJan Holesovsky <kendy@collabora.com>2014-02-28 19:10:03 +0100
commit4f0d08df0f48c1c47f11e6f5206f445823deca1e (patch)
tree32053bdf2bbbe17c14a4065dffd5aa9dc3acb72e /sc/source/core
parentd1fc65581906ef0ce4c8e276ae67a35fb0fc6dfd (diff)
GPU-Calc: Change the szHostBuffer to fix the out of boundary bug
Change-Id: I4037fb3c0ddda1a9c4b0e777e1a75bc0b11fd24b
Diffstat (limited to 'sc/source/core')
-rw-r--r--sc/source/core/opencl/formulagroupcl.cxx5
1 files changed, 4 insertions, 1 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 724f6753bbcd..55668ee5f383 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -65,6 +65,7 @@ size_t VectorRef::Marshal(cl_kernel k, int argno, int, cl_program)
{
FormulaToken *ref = mFormulaTree->GetFormulaToken();
double *pHostBuffer = NULL;
+ size_t requestedLength = 1;
size_t szHostBuffer = 0;
if (ref->GetType() == formula::svSingleVectorRef) {
const formula::SingleVectorRefToken* pSVR =
@@ -72,6 +73,7 @@ size_t VectorRef::Marshal(cl_kernel k, int argno, int, cl_program)
assert(pSVR);
pHostBuffer = const_cast<double*>(pSVR->GetArray().mpNumericArray);
szHostBuffer = pSVR->GetArrayLength() * sizeof(double);
+ requestedLength = pSVR->GetRequestedArrayLength();
#if 0
std::cerr << "Marshal a Single vector of size " << pSVR->GetArrayLength();
std::cerr << " at argument "<< argno << "\n";
@@ -83,6 +85,7 @@ size_t VectorRef::Marshal(cl_kernel k, int argno, int, cl_program)
pHostBuffer = const_cast<double*>(
pDVR->GetArrays()[mnIndex].mpNumericArray);
szHostBuffer = pDVR->GetArrayLength() * sizeof(double);
+ requestedLength = pDVR->GetRequestedArrayLength();
} else {
throw Unhandled();
}
@@ -102,7 +105,7 @@ size_t VectorRef::Marshal(cl_kernel k, int argno, int, cl_program)
else
{
if (szHostBuffer == 0)
- szHostBuffer = sizeof(double); // a dummy small value
+ szHostBuffer = requestedLength * sizeof(double);//vector length for NAN vector
// Marshal as a buffer of NANs
mpClmem = clCreateBuffer(kEnv.mpkContext,
(cl_mem_flags) CL_MEM_READ_ONLY|CL_MEM_ALLOC_HOST_PTR,