From 64c479e9da02f724e1870649c99fac92f5f27cd3 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Thu, 18 Dec 2014 13:53:29 -0500 Subject: [PATCH] Unmap memory object right after the buffer is read. Change-Id: Ic7c355dc005b8071a3b5db347f51882d89d2160f --- sc/source/core/opencl/formulagroupcl.cxx | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index 5a2bca4e9e24..c3ee9323c3d2 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -3688,6 +3688,14 @@ public: mnGroupLength * sizeof(double), 0, NULL, NULL, &err); + if (err != CL_SUCCESS) + { + SAL_WARN("sc.opencl", "Dynamic formula compiler: OpenCL error: " << err); + mpResBuf = NULL; + return; + } + + err = clEnqueueUnmapMemObject(kEnv.mpkCmdQueue, mpCLResBuf, mpResBuf, 0, NULL, NULL); if (err != CL_SUCCESS) { SAL_WARN("sc.opencl", "Dynamic formula compiler: OpenCL error: " << err); @@ -3701,18 +3709,6 @@ public: return false; rDoc.SetFormulaResults(rTopPos, mpResBuf, mnGroupLength); - - // Obtain cl context - ::opencl::KernelEnv kEnv; - ::opencl::setKernelEnv(&kEnv); - - cl_int err = clEnqueueUnmapMemObject(kEnv.mpkCmdQueue, mpCLResBuf, mpResBuf, 0, NULL, NULL); - if (err != CL_SUCCESS) - { - SAL_WARN("sc.opencl", "Dynamic formula compiler: OpenCL error: " << err); - return false; - } - return true; } };