Kaydet (Commit) 51a01d79 authored tarafından Tor Lillqvist's avatar Tor Lillqvist Kaydeden (comit) Michael Meeks

Try to make the background OpenCL compilation conditional at run-time

Change-Id: I2366465f4e786f905c32b17a15c16486c4c21d38
üst 94544378
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
#include "formulacell.hxx" #include "formulacell.hxx"
#include "grouptokenconverter.hxx"
#include "compiler.hxx" #include "compiler.hxx"
#include "document.hxx" #include "document.hxx"
...@@ -414,14 +415,18 @@ ScFormulaCellGroup::ScFormulaCellGroup() : ...@@ -414,14 +415,18 @@ ScFormulaCellGroup::ScFormulaCellGroup() :
mbSubTotal(false), mbSubTotal(false),
meCalcState(sc::GroupCalcEnabled) meCalcState(sc::GroupCalcEnabled)
{ {
if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled) static bool bBackgroundCompilation = getenv("SC_BACKGROUND_COMPILATION") != NULL;
if (bBackgroundCompilation)
{ {
osl::MutexGuard aGuard(getOpenCLCompilationThreadMutex()); if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled)
if (mnCount++ == 0)
{ {
assert(!mxCLKernelThread.is()); osl::MutexGuard aGuard(getOpenCLCompilationThreadMutex());
mxCLKernelThread.set(new sc::CLBuildKernelThread); if (mnCount++ == 0)
mxCLKernelThread->launch(); {
assert(!mxCLKernelThread.is());
mxCLKernelThread.set(new sc::CLBuildKernelThread);
mxCLKernelThread->launch();
}
} }
} }
} }
...@@ -431,7 +436,7 @@ ScFormulaCellGroup::~ScFormulaCellGroup() ...@@ -431,7 +436,7 @@ ScFormulaCellGroup::~ScFormulaCellGroup()
if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled) if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled)
{ {
osl::MutexGuard aGuard(getOpenCLCompilationThreadMutex()); osl::MutexGuard aGuard(getOpenCLCompilationThreadMutex());
if (--mnCount == 0) if (--mnCount == 0 && mxCLKernelThread.is())
{ {
assert(mxCLKernelThread.is()); assert(mxCLKernelThread.is());
mxCLKernelThread->finish(); mxCLKernelThread->finish();
...@@ -3477,17 +3482,35 @@ bool ScFormulaCell::InterpretFormulaGroup() ...@@ -3477,17 +3482,35 @@ bool ScFormulaCell::InterpretFormulaGroup()
if (mxGroup->mbInvariant && false) if (mxGroup->mbInvariant && false)
return InterpretInvariantFormulaGroup(); return InterpretInvariantFormulaGroup();
ScTokenArray aDummy;
if (mxGroup->meCalcState == sc::GroupCalcEnabled) 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; 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; ScTokenArray aDummy;
return false; 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; return true;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment