diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-12-15 21:07:28 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-12-15 21:21:06 -0500 |
commit | 990dbcab759265de1497b15a93e53a5fe81ff48d (patch) | |
tree | 94e31836d78e92dc8ac66964de770d8c6131f3ff /sc | |
parent | cf7d8b41a9c0c2a4015217b49266f781c9558d9e (diff) |
Pass group length to context / result objects to reduce # of params.
It looks cleaner this way.
Change-Id: Id46cb52863fb9366d83ac17d3f8521e5a13a59c9
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index e455c8eef5c5..a2c254c27c3d 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -3657,13 +3657,16 @@ class CLInterpreterResult { DynamicKernel* mpKernel; + SCROW mnGroupLength; + public: - CLInterpreterResult() : mpKernel(NULL) {} - CLInterpreterResult( DynamicKernel* pKernel ) : mpKernel(pKernel) {} + CLInterpreterResult() : mpKernel(NULL), mnGroupLength(0) {} + CLInterpreterResult( DynamicKernel* pKernel, SCROW nGroupLength ) : + mpKernel(pKernel), mnGroupLength(nGroupLength) {} bool isValid() const { return mpKernel != NULL; } - bool pushResultToDocument( ScDocument& rDoc, const ScAddress& rTopPos, SCROW nLength ) + bool pushResultToDocument( ScDocument& rDoc, const ScAddress& rTopPos ) { if (!isValid()) return false; @@ -3679,7 +3682,7 @@ public: double* resbuf = (double*)clEnqueueMapBuffer(kEnv.mpkCmdQueue, res, CL_TRUE, CL_MAP_READ, 0, - nLength * sizeof(double), 0, NULL, NULL, + mnGroupLength * sizeof(double), 0, NULL, NULL, &err); if (err != CL_SUCCESS) @@ -3688,7 +3691,7 @@ public: return false; } - rDoc.SetFormulaResults(rTopPos, resbuf, nLength); + rDoc.SetFormulaResults(rTopPos, resbuf, mnGroupLength); err = clEnqueueUnmapMemObject(kEnv.mpkCmdQueue, res, resbuf, 0, NULL, NULL); if (err != CL_SUCCESS) @@ -3706,7 +3709,11 @@ class CLInterpreterContext std::shared_ptr<DynamicKernel> mpKernelStore; /// for managed kernel instance. DynamicKernel* mpKernel; + SCROW mnGroupLength; + public: + CLInterpreterContext( SCROW nGroupLength ) : + mpKernel(NULL), mnGroupLength(nGroupLength) {} bool isValid() const { @@ -3724,7 +3731,7 @@ public: mpKernel = pKernel; } - CLInterpreterResult launchKernel( SCROW nLength ) + CLInterpreterResult launchKernel() { CLInterpreterResult aRes; // invalid by default. @@ -3734,7 +3741,7 @@ public: try { // Run the kernel. - mpKernel->Launch(nLength); + mpKernel->Launch(mnGroupLength); } catch (const UnhandledToken& ut) { @@ -3757,7 +3764,7 @@ public: return CLInterpreterResult(); } - return CLInterpreterResult(mpKernel); + return CLInterpreterResult(mpKernel, mnGroupLength); } }; @@ -3765,7 +3772,7 @@ public: CLInterpreterContext createCLInterpreterContext( ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode ) { - CLInterpreterContext aCxt; + CLInterpreterContext aCxt(xGroup->mnLength); #if ENABLE_THREADED_OPENCL_KERNEL_COMPILATION if (rGroup.meKernelState == sc::OpenCLKernelCompilationScheduled || @@ -3813,11 +3820,11 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, if (!aCxt.isValid()) return false; - CLInterpreterResult aRes = aCxt.launchKernel(xGroup->mnLength); + CLInterpreterResult aRes = aCxt.launchKernel(); if (!aRes.isValid()) return false; - return aRes.pushResultToDocument(rDoc, rTopPos, xGroup->mnLength); + return aRes.pushResultToDocument(rDoc, rTopPos); } }} // namespace sc::opencl |