summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2015-11-30 09:44:19 +0100
committerJan Holesovsky <kendy@collabora.com>2015-12-01 16:40:44 +0100
commitbd8a89f208c71e51921d5f090179b99b45cc0a5f (patch)
tree76884fe22a5167ae48cd8a94b7e7d75b08ddcaa7 /sc
parent9ae2d9ff4be259ad60bbb10a7488e38ca4eefc11 (diff)
sc interpreter: Don't hide S/W Interpreter behind an environment variable.
Instead provide a user setting that can be enabled so that the S/W Interpreter is used on a subset of the operations. The operations for which it is used are controlled by a whitelist in ScCalcConfig::setOpenCLConfigToDefault(). Change-Id: I7d3f3a864fcb1231e5484ec23961f14fca1466c5
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/calcconfig.hxx1
-rw-r--r--sc/source/core/data/formulacell.cxx2
-rw-r--r--sc/source/core/tool/calcconfig.cxx6
-rw-r--r--sc/source/core/tool/formulagroup.cxx29
-rw-r--r--sc/source/core/tool/token.cxx11
5 files changed, 34 insertions, 15 deletions
diff --git a/sc/inc/calcconfig.hxx b/sc/inc/calcconfig.hxx
index ec355cfdb844..eaf4f36f143b 100644
--- a/sc/inc/calcconfig.hxx
+++ b/sc/inc/calcconfig.hxx
@@ -49,6 +49,7 @@ struct SC_DLLPUBLIC ScCalcConfig
bool mbHasStringRefSyntax:1;
static bool isOpenCLEnabled();
+ static bool isSwInterpreterEnabled();
bool mbOpenCLSubsetOnly:1;
bool mbOpenCLAutoSelect:1;
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 9079d560cbed..0c5edae5ebef 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -3952,7 +3952,7 @@ bool ScFormulaCell::InterpretFormulaGroup()
return false;
}
- if (!ScCalcConfig::isOpenCLEnabled() && (getenv("SC_ALLOW_SOFTWARE_INTERPRETER") == nullptr))
+ if (!ScCalcConfig::isOpenCLEnabled() && !ScCalcConfig::isSwInterpreterEnabled())
return false;
// TODO : Disable invariant formula group interpretation for now in order
diff --git a/sc/source/core/tool/calcconfig.cxx b/sc/source/core/tool/calcconfig.cxx
index f285e138af99..96277ce01194 100644
--- a/sc/source/core/tool/calcconfig.cxx
+++ b/sc/source/core/tool/calcconfig.cxx
@@ -38,6 +38,12 @@ bool ScCalcConfig::isOpenCLEnabled()
return gOpenCLEnabled.get();
}
+bool ScCalcConfig::isSwInterpreterEnabled()
+{
+ static comphelper::ConfigurationListenerProperty<bool> gSwInterpreterEnabled(getMiscListener(), OUString("UseSwInterpreter"));
+ return gSwInterpreterEnabled.get();
+}
+
ScCalcConfig::ScCalcConfig() :
meStringRefAddressSyntax(formula::FormulaGrammar::CONV_UNSPECIFIED),
meStringConversion(StringConversion::LOCALE), // old LibreOffice behavior
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index c4abe00f402f..ce5c70a2b5b2 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -375,7 +375,7 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
nRowEnd += i;
ScMatrixRef pMat;
- if (getenv("SC_ALLOW_SOFTWARE_INTERPRETER") != nullptr)
+ if (ScCalcConfig::isSwInterpreterEnabled())
{
assert(nRowStart <= nRowEnd);
pMat.reset(new ScVectorRefMatrix(p2, nRowStart, nRowEnd - nRowStart + 1));
@@ -481,13 +481,14 @@ FormulaGroupInterpreter *FormulaGroupInterpreter::getStatic()
if ( !msInstance )
{
#if HAVE_FEATURE_OPENCL
- const ScCalcConfig& rConfig = ScInterpreter::GetGlobalConfig();
if (ScCalcConfig::isOpenCLEnabled())
+ {
+ const ScCalcConfig& rConfig = ScInterpreter::GetGlobalConfig();
switchOpenCLDevice(rConfig.maOpenCLDevice, rConfig.mbOpenCLAutoSelect);
+ }
#endif
- static bool bAllowSoftwareInterpreter = (getenv("SC_ALLOW_SOFTWARE_INTERPRETER") != nullptr);
- if ( !msInstance && bAllowSoftwareInterpreter ) // software fallback
+ if (!msInstance && ScCalcConfig::isSwInterpreterEnabled()) // software interpreter
{
SAL_INFO("sc.core.formulagroup", "Create S/W interpreter");
msInstance = new sc::FormulaGroupInterpreterSoftware();
@@ -509,20 +510,26 @@ void FormulaGroupInterpreter::fillOpenCLInfo(std::vector<OpenCLPlatformInfo>& rP
bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool bAutoSelect, bool bForceEvaluation)
{
bool bOpenCLEnabled = ScCalcConfig::isOpenCLEnabled();
- static bool bAllowSoftwareInterpreter = (getenv("SC_ALLOW_SOFTWARE_INTERPRETER") != nullptr);
- if (!bOpenCLEnabled || (bAllowSoftwareInterpreter && rDeviceId == OPENCL_SOFTWARE_DEVICE_CONFIG_NAME))
+ if (!bOpenCLEnabled || (rDeviceId == OPENCL_SOFTWARE_DEVICE_CONFIG_NAME))
{
- if(msInstance)
+ bool bSwInterpreterEnabled = ScCalcConfig::isSwInterpreterEnabled();
+ if (msInstance)
{
// if we already have a software interpreter don't delete it
- if(dynamic_cast<sc::FormulaGroupInterpreterSoftware*>(msInstance))
+ if (bSwInterpreterEnabled && dynamic_cast<sc::FormulaGroupInterpreterSoftware*>(msInstance))
return true;
delete msInstance;
+ msInstance = nullptr;
}
- msInstance = new sc::FormulaGroupInterpreterSoftware();
- return true;
+ if (bSwInterpreterEnabled)
+ {
+ msInstance = new sc::FormulaGroupInterpreterSoftware();
+ return true;
+ }
+
+ return false;
}
bool bSuccess = ::opencl::switchOpenCLDevice(&rDeviceId, bAutoSelect, bForceEvaluation);
if(!bSuccess)
@@ -531,7 +538,7 @@ bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool
delete msInstance;
msInstance = nullptr;
- if (ScCalcConfig::isOpenCLEnabled())
+ if (bOpenCLEnabled)
{
msInstance = new sc::opencl::FormulaGroupInterpreterOpenCL();
return msInstance != nullptr;
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 138e0873c371..41be86a84fe0 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -32,6 +32,7 @@
#include "compiler.hxx"
#include "interpre.hxx"
#include <formula/compiler.hrc>
+#include <formulagroup.hxx>
#include "rechead.hxx"
#include "parclass.hxx"
#include "jumpmatrix.hxx"
@@ -1319,7 +1320,9 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
return;
}
- if (!ScCalcConfig::isOpenCLEnabled() && getenv("SC_ALLOW_SOFTWARE_INTERPRETER") != nullptr && ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->find(eOp) == ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->end())
+ // test for OpenCL interpreter first - the assumption is that S/W
+ // interpreter blacklist is more strict than the OpenCL one
+ if (ScCalcConfig::isSwInterpreterEnabled() && (dynamic_cast<sc::FormulaGroupInterpreterSoftware*>(sc::FormulaGroupInterpreter::getStatic()) != nullptr) && ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->find(eOp) == ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->end())
{
meVectorState = FormulaVectorDisabled;
return;
@@ -1566,10 +1569,12 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
return;
}
+ // only when openCL interpreter is not enabled - the assumption is that
+ // the S/W interpreter blacklist is more strict
if (eOp >= SC_OPCODE_START_BIN_OP &&
eOp <= SC_OPCODE_STOP_UN_OP &&
- !ScCalcConfig::isOpenCLEnabled() &&
- getenv("SC_ALLOW_SOFTWARE_INTERPRETER") != nullptr &&
+ ScCalcConfig::isSwInterpreterEnabled() &&
+ (dynamic_cast<sc::FormulaGroupInterpreterSoftware*>(sc::FormulaGroupInterpreter::getStatic()) != nullptr) &&
ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->find(eOp) == ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->end())
{
meVectorState = FormulaVectorDisabled;