Make threaded calculation the default (when OpenCL is not used)
Introduce a configuration setting to turn it off. For now, can also be
turned off with the environment variable SC_NO_THREADED_CALCULATION,
but that is probably not something we want to keep or guarantee
staility of. (LO looks at way too many environment variables already.)
Change-Id: I469cde259eda72cc2d630814a25f707f1210b0ab
diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index b1feca1..72ac33b 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -1416,6 +1416,12 @@
<info>
<desc>Contains settings for how to calculate formulae.</desc>
</info>
<prop oor:name="UseThreadedCalculationForFormulaGroups" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Whether to use threaded calculation of forumula groups when applicable.</desc>
</info>
<value>true</value>
</prop>
<!-- Note: The default values below probably must correspond
to those assigned in setOpenCLConfigToDefault() in
sc/source/core/tool/calcconfig.cxx
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index fed52b9..615fbb8 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -54,6 +54,7 @@
#include <svl/intitem.hxx>
#include <o3tl/make_unique.hxx>
#include <rtl/strbuf.hxx>
#include <officecfg/Office/Calc.hxx>
#include <formulagroup.hxx>
#include <listenercontext.hxx>
#include <types.hxx>
@@ -4322,11 +4323,10 @@ bool ScFormulaCell::InterpretFormulaGroup()
return false;
}
static const bool bThreadingRequested = std::getenv("CPU_THREADED_CALCULATION");
static const bool bThreadingProhibited = std::getenv("SC_NO_THREADED_CALCULATION");
// To temporarilu use threading for sc unit tests regardless of the size of the formula group,
// add the condition !std::getenv("LO_TESTNAME") below (with &&), and run with
// CPU_THREADED_CALCULATION=yes
// add the condition !std::getenv("LO_TESTNAME") below (with &&)
if (GetWeight() < ScInterpreter::GetGlobalConfig().mnOpenCLMinimumFormulaGroupSize)
{
mxGroup->meCalcState = sc::GroupCalcDisabled;
@@ -4341,7 +4341,7 @@ bool ScFormulaCell::InterpretFormulaGroup()
return false;
}
if (!ScCalcConfig::isOpenCLEnabled() && bThreadingRequested)
if (!bThreadingProhibited && !ScCalcConfig::isOpenCLEnabled() && officecfg::Office::Calc::Formula::Calculation::UseThreadedCalculationForFormulaGroups::get())
{
// iterate over code in the formula ...
// ensure all input is pre-calculated -
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 0a58607..a24f419 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -25,6 +25,7 @@
#include <tools/mempool.hxx>
#include <osl/diagnose.h>
#include <sfx2/docfile.hxx>
#include <officecfg/Office/Calc.hxx>
#include <token.hxx>
#include <tokenarray.hxx>
@@ -1346,11 +1347,11 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
// It's already disabled. No more checking needed.
return;
static const bool bThreadingRequested = std::getenv("CPU_THREADED_CALCULATION");
static const bool bThreadingProhibited = std::getenv("SC_NO_THREADED_CALCULATION");
OpCode eOp = r.GetOpCode();
if (!ScCalcConfig::isOpenCLEnabled() && bThreadingRequested)
if (!bThreadingProhibited && !ScCalcConfig::isOpenCLEnabled() && officecfg::Office::Calc::Formula::Calculation::UseThreadedCalculationForFormulaGroups::get())
{
if (aThreadedCalcBlackList.count(eOp))
{