summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2015-11-24 11:12:33 +0100
committerJan Holesovsky <kendy@collabora.com>2015-11-24 11:12:33 +0100
commit2fb8894e45770b816e674a7c38e295f1e6673084 (patch)
tree8f833e939b8b193221551f47a123bbc51cb0a84b
parent626675a2692907ba5363f135c0f67d19ebdc5ff5 (diff)
sc: Implement S/W interpreter subsetting, similarly to openCL one. private/kendy/swinterpreter
And add only the minimum amonut of operations we are sure about. Change-Id: I53b780091bc7b2cc78a3571b072ce00d19971fe8
-rw-r--r--sc/inc/calcconfig.hxx1
-rw-r--r--sc/source/core/tool/calcconfig.cxx11
-rw-r--r--sc/source/core/tool/token.cxx18
3 files changed, 29 insertions, 1 deletions
diff --git a/sc/inc/calcconfig.hxx b/sc/inc/calcconfig.hxx
index 4091bda5bea5..ec355cfdb844 100644
--- a/sc/inc/calcconfig.hxx
+++ b/sc/inc/calcconfig.hxx
@@ -58,6 +58,7 @@ struct SC_DLLPUBLIC ScCalcConfig
typedef std::shared_ptr<std::set<OpCode>> OpCodeSet;
OpCodeSet mpOpenCLSubsetOpCodes;
+ OpCodeSet mpSwInterpreterSubsetOpCodes;
ScCalcConfig();
diff --git a/sc/source/core/tool/calcconfig.cxx b/sc/source/core/tool/calcconfig.cxx
index 20d5530647c9..f285e138af99 100644
--- a/sc/source/core/tool/calcconfig.cxx
+++ b/sc/source/core/tool/calcconfig.cxx
@@ -86,6 +86,15 @@ void ScCalcConfig::setOpenCLConfigToDefault()
ocSlope,
ocSumIfs}));
+ // opcodes that are known to work well with the software interpreter
+ static OpCodeSet pDefaultSwInterpreterSubsetOpCodes(new std::set<OpCode>({
+ ocAdd,
+ ocSub,
+ ocMul,
+ ocDiv,
+ ocSum,
+ ocProduct}));
+
// Note that these defaults better be kept in sync with those in
// officecfg/registry/schema/org/openoffice/Office/Calc.xcs.
// Crazy.
@@ -93,6 +102,7 @@ void ScCalcConfig::setOpenCLConfigToDefault()
mbOpenCLAutoSelect = true;
mnOpenCLMinimumFormulaGroupSize = 100;
mpOpenCLSubsetOpCodes = pDefaultOpenCLSubsetOpCodes;
+ mpSwInterpreterSubsetOpCodes = pDefaultSwInterpreterSubsetOpCodes;
}
void ScCalcConfig::reset()
@@ -127,6 +137,7 @@ bool ScCalcConfig::operator== (const ScCalcConfig& r) const
maOpenCLDevice == r.maOpenCLDevice &&
mnOpenCLMinimumFormulaGroupSize == r.mnOpenCLMinimumFormulaGroupSize &&
*mpOpenCLSubsetOpCodes == *r.mpOpenCLSubsetOpCodes &&
+ *mpSwInterpreterSubsetOpCodes == *r.mpSwInterpreterSubsetOpCodes &&
true;
}
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 08fcadaad7a6..63ab8faec151 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1315,7 +1315,13 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
if (SC_OPCODE_START_FUNCTION <= eOp && eOp < SC_OPCODE_STOP_FUNCTION)
{
- if (ScInterpreter::GetGlobalConfig().mbOpenCLSubsetOnly && ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->find(eOp) == ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->end())
+ if (ScCalcConfig::isOpenCLEnabled() && ScInterpreter::GetGlobalConfig().mbOpenCLSubsetOnly && ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->find(eOp) == ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->end())
+ {
+ meVectorState = FormulaVectorDisabled;
+ return;
+ }
+
+ if (getenv("SC_ALLOW_SOFTWARE_INTERPRETER") != nullptr && ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->find(eOp) == ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->end())
{
meVectorState = FormulaVectorDisabled;
return;
@@ -1555,12 +1561,22 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
if (eOp >= SC_OPCODE_START_BIN_OP &&
eOp <= SC_OPCODE_STOP_UN_OP &&
+ ScCalcConfig::isOpenCLEnabled() &&
ScInterpreter::GetGlobalConfig().mbOpenCLSubsetOnly &&
ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->find(eOp) == ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->end())
{
meVectorState = FormulaVectorDisabled;
return;
}
+
+ if (eOp >= SC_OPCODE_START_BIN_OP &&
+ eOp <= SC_OPCODE_STOP_UN_OP &&
+ getenv("SC_ALLOW_SOFTWARE_INTERPRETER") != nullptr &&
+ ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->find(eOp) == ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->end())
+ {
+ meVectorState = FormulaVectorDisabled;
+ return;
+ }
}
bool ScTokenArray::ImplGetReference( ScRange& rRange, const ScAddress& rPos, bool bValidOnly ) const