sc/inc/formulacell.hxx | 1 + sc/inc/formulagroup.hxx | 4 ++-- sc/source/core/data/formulacell.cxx | 15 +++++++++++++++ sc/source/core/opencl/formulagroupcl.cxx | 10 +++++----- sc/source/core/tool/clkernelthread.cxx | 10 +--------- sc/source/core/tool/formulagroup.cxx | 4 ++-- 6 files changed, 26 insertions(+), 18 deletions(-)
New commits: commit 995bc14e932f8dc9ee4a40619fa2b0db647a2c37 Author: Kohei Yoshida <kohei.yosh...@collabora.com> Date: Thu Mar 6 20:45:25 2014 -0500 Allow easy toggling of threaded OpenCL kernel compilation. Via compiler defined macro. Change-Id: Ic20e6564d99e8ae80c15eda5d12b4dbb76ffbd36 diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index 67b0fb6..6f3c555 100644 --- a/sc/inc/formulacell.hxx +++ b/sc/inc/formulacell.hxx @@ -76,6 +76,7 @@ struct SC_DLLPUBLIC ScFormulaCellGroup : boost::noncopyable void setCode( const ScTokenArray& rCode ); void compileCode( ScDocument& rDoc, const ScAddress& rPos, formula::FormulaGrammar::Grammar eGram ); + void compileOpenCLKernel(); static int snCount; static rtl::Reference<sc::CLBuildKernelThread> sxCompilationThread; diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx index a3f1891..bb0e0b4 100644 --- a/sc/inc/formulagroup.hxx +++ b/sc/inc/formulagroup.hxx @@ -107,7 +107,7 @@ class SC_DLLPUBLIC FormulaGroupInterpreter virtual ScMatrixRef inverseMatrix(const ScMatrix& rMat) = 0; virtual CompiledFormula* createCompiledFormula(ScDocument& rDoc, const ScAddress& rTopPos, - ScFormulaCellGroupRef& xGroup, + ScFormulaCellGroup& rGroup, ScTokenArray& rCode) = 0; virtual bool interpret(ScDocument& rDoc, const ScAddress& rTopPos, ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode) = 0; }; @@ -122,7 +122,7 @@ public: virtual ScMatrixRef inverseMatrix(const ScMatrix& rMat); virtual CompiledFormula* createCompiledFormula(ScDocument& rDoc, const ScAddress& rTopPos, - ScFormulaCellGroupRef& xGroup, + ScFormulaCellGroup& rGroup, ScTokenArray& rCode) SAL_OVERRIDE; virtual bool interpret(ScDocument& rDoc, const ScAddress& rTopPos, ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode) SAL_OVERRIDE; }; diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 9a328ed..821bc67 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -54,6 +54,8 @@ #include <boost/scoped_ptr.hpp> +#define ENABLE_THREADED_OPENCL_KERNEL_COMPILATION 1 + using namespace formula; #ifdef USE_MEMPOOL @@ -482,7 +484,16 @@ void ScFormulaCellGroup::compileCode( } } +void ScFormulaCellGroup::compileOpenCLKernel() +{ + if (meCalcState == sc::GroupCalcDisabled) + return; + + mpCompiledFormula = sc::FormulaGroupInterpreter::getStatic()->createCompiledFormula( + *mpTopCell->GetDocument(), mpTopCell->aPos, *this, *mpCode); + meKernelState = sc::OpenCLKernelBinaryCreated; +} ScFormulaCell::ScFormulaCell( ScDocument* pDoc, const ScAddress& rPos ) : eTempGrammar(formula::FormulaGrammar::GRAM_DEFAULT), @@ -3492,8 +3503,12 @@ ScFormulaCellGroupRef ScFormulaCell::CreateCellGroup( SCROW nLen, bool bInvarian mxGroup->mbInvariant = bInvariant; mxGroup->mnLength = nLen; mxGroup->mpCode = pCode; // Move this to the shared location. +#if ENABLE_THREADED_OPENCL_KERNEL_COMPILATION if (mxGroup->sxCompilationThread.is()) mxGroup->scheduleCompilation(); +#else + mxGroup->compileOpenCLKernel(); +#endif return mxGroup; } diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index ea1a7e0..3cf52f5 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -3342,7 +3342,7 @@ public: virtual ScMatrixRef inverseMatrix( const ScMatrix& rMat ) SAL_OVERRIDE; virtual CompiledFormula* createCompiledFormula(ScDocument& rDoc, const ScAddress& rTopPos, - ScFormulaCellGroupRef& xGroup, + ScFormulaCellGroup& rGroup, ScTokenArray& rCode) SAL_OVERRIDE; virtual bool interpret( ScDocument& rDoc, const ScAddress& rTopPos, ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode ) SAL_OVERRIDE; @@ -3427,15 +3427,15 @@ DynamicKernel* DynamicKernel::create(ScDocument& /* rDoc */, CompiledFormula* FormulaGroupInterpreterOpenCL::createCompiledFormula(ScDocument& rDoc, const ScAddress& rTopPos, - ScFormulaCellGroupRef& xGroup, + ScFormulaCellGroup& rGroup, ScTokenArray& rCode) { ScTokenArray aConvertedCode; - ScGroupTokenConverter aConverter(aConvertedCode, rDoc, *xGroup->mpTopCell, rTopPos); + ScGroupTokenConverter aConverter(aConvertedCode, rDoc, *rGroup.mpTopCell, rTopPos); if (!aConverter.convert(rCode) || aConvertedCode.GetLen() == 0) return NULL; - SymbolTable::nR = xGroup->mnLength; + SymbolTable::nR = rGroup.mnLength; return DynamicKernel::create(rDoc, rTopPos, aConvertedCode); } @@ -3460,7 +3460,7 @@ bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc, else { assert(xGroup->meCalcState == sc::GroupCalcRunning); - pKernel = static_cast<DynamicKernel*>(createCompiledFormula(rDoc, rTopPos, xGroup, rCode)); + pKernel = static_cast<DynamicKernel*>(createCompiledFormula(rDoc, rTopPos, *xGroup, rCode)); } if (!pKernel) diff --git a/sc/source/core/tool/clkernelthread.cxx b/sc/source/core/tool/clkernelthread.cxx index 2715af6..ea3c7d0 100644 --- a/sc/source/core/tool/clkernelthread.cxx +++ b/sc/source/core/tool/clkernelthread.cxx @@ -49,15 +49,7 @@ void CLBuildKernelThread::execute() { case CLBuildKernelWorkItem::COMPILE: SAL_INFO("sc.opencl.thread", "told to compile group " << aWorkItem.mxGroup << " (state " << aWorkItem.mxGroup->meCalcState << ") to binary"); - if (aWorkItem.mxGroup->meCalcState == sc::GroupCalcDisabled) - break; - assert(aWorkItem.mxGroup->meKernelState == sc::OpenCLKernelCompilationScheduled); - aWorkItem.mxGroup->mpCompiledFormula = - sc::FormulaGroupInterpreter::getStatic()->createCompiledFormula(*aWorkItem.mxGroup->mpTopCell->GetDocument(), - aWorkItem.mxGroup->mpTopCell->aPos, - aWorkItem.mxGroup, - *aWorkItem.mxGroup->mpCode); - aWorkItem.mxGroup->meKernelState = sc::OpenCLKernelBinaryCreated; + aWorkItem.mxGroup->compileOpenCLKernel(); SAL_INFO("sc.opencl.thread", "group " << aWorkItem.mxGroup << " compilation done"); maCompilationDoneCondition.set(); break; diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx index 806d2d1..d680235 100644 --- a/sc/source/core/tool/formulagroup.cxx +++ b/sc/source/core/tool/formulagroup.cxx @@ -294,7 +294,7 @@ ScMatrixRef FormulaGroupInterpreterSoftware::inverseMatrix(const ScMatrix& /*rMa CompiledFormula* FormulaGroupInterpreterSoftware::createCompiledFormula(ScDocument& /* rDoc */, const ScAddress& /* rTopPos */, - ScFormulaCellGroupRef& /* xGroup */, + ScFormulaCellGroup& /* rGroup */, ScTokenArray& /* rCode */) { return NULL; @@ -502,7 +502,7 @@ public: FormulaGroupInterpreterOpenCLMissing() : FormulaGroupInterpreter() {} virtual ~FormulaGroupInterpreterOpenCLMissing() {} virtual ScMatrixRef inverseMatrix(const ScMatrix&) { return ScMatrixRef(); } - virtual CompiledFormula* createCompiledFormula(ScDocument&, const ScAddress&, ScFormulaCellGroupRef&, ScTokenArray&) SAL_OVERRIDE { return NULL; } + virtual CompiledFormula* createCompiledFormula(ScDocument&, const ScAddress&, ScFormulaCellGroup&, ScTokenArray&) SAL_OVERRIDE { return NULL; } virtual bool interpret(ScDocument&, const ScAddress&, ScFormulaCellGroupRef&, ScTokenArray&) { return false; } }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits