[Libreoffice-commits] core.git: sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Tue Dec 16 16:17:49 PST 2014
sc/source/core/opencl/formulagroupcl.cxx | 35 ++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 10 deletions(-)
New commits:
commit cccf45a3d3ea6b06e6c8a507645d23505a91e8d5
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Tue Dec 16 18:52:48 2014 -0500
Split the wait-for-result part and push-result-to-doc part.
Change-Id: I496fa9274922603f4c7efdcab90e66a23df741fa
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 28519b5..5a2bca4 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -3659,28 +3659,31 @@ class CLInterpreterResult
SCROW mnGroupLength;
+ cl_mem mpCLResBuf;
+ double* mpResBuf;
+
public:
- CLInterpreterResult() : mpKernel(NULL), mnGroupLength(0) {}
+ CLInterpreterResult() : mpKernel(NULL), mnGroupLength(0), mpCLResBuf(NULL), mpResBuf(NULL) {}
CLInterpreterResult( DynamicKernel* pKernel, SCROW nGroupLength ) :
- mpKernel(pKernel), mnGroupLength(nGroupLength) {}
+ mpKernel(pKernel), mnGroupLength(nGroupLength), mpCLResBuf(NULL), mpResBuf(NULL) {}
bool isValid() const { return mpKernel != NULL; }
- bool pushResultToDocument( ScDocument& rDoc, const ScAddress& rTopPos )
+ void waitForResult()
{
if (!isValid())
- return false;
+ return;
// Map results back
- cl_mem res = mpKernel->GetResultBuffer();
+ mpCLResBuf = mpKernel->GetResultBuffer();
// Obtain cl context
::opencl::KernelEnv kEnv;
::opencl::setKernelEnv(&kEnv);
cl_int err;
- double* resbuf = (double*)clEnqueueMapBuffer(kEnv.mpkCmdQueue,
- res,
+ mpResBuf = (double*)clEnqueueMapBuffer(kEnv.mpkCmdQueue,
+ mpCLResBuf,
CL_TRUE, CL_MAP_READ, 0,
mnGroupLength * sizeof(double), 0, NULL, NULL,
&err);
@@ -3688,12 +3691,22 @@ public:
if (err != CL_SUCCESS)
{
SAL_WARN("sc.opencl", "Dynamic formula compiler: OpenCL error: " << err);
- return false;
+ mpResBuf = NULL;
}
+ }
+
+ bool pushResultToDocument( ScDocument& rDoc, const ScAddress& rTopPos )
+ {
+ if (!mpResBuf)
+ return false;
- rDoc.SetFormulaResults(rTopPos, resbuf, mnGroupLength);
+ rDoc.SetFormulaResults(rTopPos, mpResBuf, mnGroupLength);
- err = clEnqueueUnmapMemObject(kEnv.mpkCmdQueue, res, resbuf, 0, NULL, NULL);
+ // 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);
@@ -3826,6 +3839,8 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc,
if (!aRes.isValid())
return false;
+ aRes.waitForResult();
+
return aRes.pushResultToDocument(rDoc, rTopPos);
}
More information about the Libreoffice-commits
mailing list