diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-03-06 20:45:25 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-03-06 20:50:03 -0500 |
commit | 20ed6886ade81ee015a22b2eb3aeff64691971bf (patch) | |
tree | 96aa9162c897773a3f7e7be201875a3d80eea049 /sc | |
parent | 5325137783825c498ed4236080ed7fe51cdec09a (diff) |
Allow easy toggling of threaded OpenCL kernel compilation.
Via compiler defined macro.
Change-Id: Ic20e6564d99e8ae80c15eda5d12b4dbb76ffbd36
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/formulacell.hxx | 1 | ||||
-rw-r--r-- | sc/inc/formulagroup.hxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 15 | ||||
-rw-r--r-- | sc/source/core/opencl/formulagroupcl.cxx | 10 | ||||
-rw-r--r-- | sc/source/core/tool/clkernelthread.cxx | 10 | ||||
-rw-r--r-- | sc/source/core/tool/formulagroup.cxx | 4 |
6 files changed, 26 insertions, 18 deletions
diff --git a/sc/inc/formulacell.hxx b/sc/inc/formulacell.hxx index 67b0fb68b3e7..6f3c555a09a4 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 a3f1891417a4..bb0e0b42e4e4 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 9a328ed38f96..821bc67f3b11 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 ea1a7e024358..3cf52f5e422c 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 2715af6df245..ea3c7d0c1331 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 806d2d1178da..d68023566ea2 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; } }; |