diff options
author | Tor Lillqvist <tml@collabora.com> | 2013-11-18 20:27:48 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2013-11-20 18:23:06 +0000 |
commit | 51a01d79ca88fe3eab6094338494e04a117831fa (patch) | |
tree | 41ad0d8cc558f3d4d73d986d951d7f5ee30c2e3c /sc/source/core/data | |
parent | 94544378e5fcee7de5b481a9f06d7ef4a821d107 (diff) |
Try to make the background OpenCL compilation conditional at run-time
Change-Id: I2366465f4e786f905c32b17a15c16486c4c21d38
Diffstat (limited to 'sc/source/core/data')
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 49 |
1 files changed, 36 insertions, 13 deletions
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index f7b001bd9521..9f6465f78160 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -18,6 +18,7 @@ */ #include "formulacell.hxx" +#include "grouptokenconverter.hxx" #include "compiler.hxx" #include "document.hxx" @@ -414,14 +415,18 @@ ScFormulaCellGroup::ScFormulaCellGroup() : mbSubTotal(false), meCalcState(sc::GroupCalcEnabled) { - if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled) + static bool bBackgroundCompilation = getenv("SC_BACKGROUND_COMPILATION") != NULL; + if (bBackgroundCompilation) { - osl::MutexGuard aGuard(getOpenCLCompilationThreadMutex()); - if (mnCount++ == 0) + if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled) { - assert(!mxCLKernelThread.is()); - mxCLKernelThread.set(new sc::CLBuildKernelThread); - mxCLKernelThread->launch(); + osl::MutexGuard aGuard(getOpenCLCompilationThreadMutex()); + if (mnCount++ == 0) + { + assert(!mxCLKernelThread.is()); + mxCLKernelThread.set(new sc::CLBuildKernelThread); + mxCLKernelThread->launch(); + } } } } @@ -431,7 +436,7 @@ ScFormulaCellGroup::~ScFormulaCellGroup() if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled) { osl::MutexGuard aGuard(getOpenCLCompilationThreadMutex()); - if (--mnCount == 0) + if (--mnCount == 0 && mxCLKernelThread.is()) { assert(mxCLKernelThread.is()); mxCLKernelThread->finish(); @@ -3477,17 +3482,35 @@ bool ScFormulaCell::InterpretFormulaGroup() if (mxGroup->mbInvariant && false) return InterpretInvariantFormulaGroup(); - ScTokenArray aDummy; if (mxGroup->meCalcState == sc::GroupCalcEnabled) + { + ScTokenArray aCode; + ScAddress aTopPos = aPos; + aTopPos.SetRow(mxGroup->mpTopCell->aPos.Row()); + ScGroupTokenConverter aConverter(aCode, *pDocument, *this, mxGroup->mpTopCell->aPos); + if (!aConverter.convert(*pCode)) + { + mxGroup->meCalcState = sc::GroupCalcDisabled; + return false; + } mxGroup->meCalcState = sc::GroupCalcRunning; - if (!sc::FormulaGroupInterpreter::getStatic()->interpret(*pDocument, mxGroup->mpTopCell->aPos, mxGroup, aDummy)) + if (!sc::FormulaGroupInterpreter::getStatic()->interpret(*pDocument, mxGroup->mpTopCell->aPos, mxGroup, aCode)) + { + mxGroup->meCalcState = sc::GroupCalcDisabled; + return false; + } + mxGroup->meCalcState = sc::GroupCalcEnabled; + } + else { - mxGroup->meCalcState = sc::GroupCalcDisabled; - return false; + ScTokenArray aDummy; + if (!sc::FormulaGroupInterpreter::getStatic()->interpret(*pDocument, mxGroup->mpTopCell->aPos, mxGroup, aDummy)) + { + mxGroup->meCalcState = sc::GroupCalcDisabled; + return false; + } } - if (mxGroup->meCalcState == sc::GroupCalcRunning) - mxGroup->meCalcState = sc::GroupCalcEnabled; return true; } |