diff options
author | Jan Holesovsky <kendy@collabora.com> | 2015-11-30 09:44:19 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2015-12-01 16:40:44 +0100 |
commit | bd8a89f208c71e51921d5f090179b99b45cc0a5f (patch) | |
tree | 76884fe22a5167ae48cd8a94b7e7d75b08ddcaa7 | |
parent | tdf#88443:percent value fixed (diff) | |
download | core-bd8a89f208c71e51921d5f090179b99b45cc0a5f.tar.gz core-bd8a89f208c71e51921d5f090179b99b45cc0a5f.zip |
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
-rw-r--r-- | cui/source/options/optopencl.cxx | 19 | ||||
-rw-r--r-- | cui/source/options/optopencl.hxx | 1 | ||||
-rw-r--r-- | cui/uiconfig/ui/optopenclpage.ui | 18 | ||||
-rw-r--r-- | officecfg/registry/schema/org/openoffice/Office/Common.xcs | 7 | ||||
-rw-r--r-- | sc/inc/calcconfig.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/data/formulacell.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/calcconfig.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/tool/formulagroup.cxx | 29 | ||||
-rw-r--r-- | sc/source/core/tool/token.cxx | 11 |
9 files changed, 77 insertions, 17 deletions
diff --git a/cui/source/options/optopencl.cxx b/cui/source/options/optopencl.cxx index 71cd281480dc..db1470e290c7 100644 --- a/cui/source/options/optopencl.cxx +++ b/cui/source/options/optopencl.cxx @@ -35,7 +35,8 @@ #include <com/sun/star/util/XChangesBatch.hpp> #include <com/sun/star/setup/UpdateCheckConfig.hpp> -#include "cuires.hrc" +#include <cuires.hrc> +#include <dialmgr.hxx> #include "optopencl.hxx" #include <svtools/treelistentry.hxx> @@ -43,6 +44,7 @@ SvxOpenCLTabPage::SvxOpenCLTabPage(vcl::Window* pParent, const SfxItemSet& rSet) SfxTabPage(pParent, "OptOpenCLPage", "cui/ui/optopenclpage.ui", &rSet), maConfig(OpenCLConfig::get()) { + get(mpUseSwInterpreter, "useswinterpreter"); get(mpUseOpenCL, "useopencl"); get(mpBlackListTable, "blacklist"); get(mpBlackListFrame,"blacklistframe"); @@ -60,6 +62,8 @@ SvxOpenCLTabPage::SvxOpenCLTabPage(vcl::Window* pParent, const SfxItemSet& rSet) get(mpVendor,"vendor"); get(mpDrvVersion,"driverversion"); + mpUseSwInterpreter->Check(officecfg::Office::Common::Misc::UseSwInterpreter::get()); + mpUseOpenCL->Check(maConfig.mbUseOpenCL); mpUseOpenCL->SetClickHdl(LINK(this, SvxOpenCLTabPage, EnableOpenCLHdl)); @@ -116,6 +120,7 @@ void SvxOpenCLTabPage::dispose() mpBlackList.disposeAndClear(); mpWhiteList.disposeAndClear(); + mpUseSwInterpreter.clear(); mpUseOpenCL.clear(); mpBlackListFrame.clear(); mpBlackListTable.clear(); @@ -146,6 +151,15 @@ bool SvxOpenCLTabPage::FillItemSet( SfxItemSet* ) bool bModified = false; std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); + if (mpUseSwInterpreter->IsValueChangedFromSaved()) + { + officecfg::Office::Common::Misc::UseSwInterpreter::set(mpUseSwInterpreter->IsChecked(), batch); + bModified = true; + + ScopedVclPtrInstance<MessageDialog> aWarnBox(this, CUI_RES(RID_SVXSTR_OPTIONS_RESTART), VCL_MESSAGE_INFO); + aWarnBox->Execute(); + } + if (mpUseOpenCL->IsValueChangedFromSaved()) maConfig.mbUseOpenCL = mpUseOpenCL->IsChecked(); @@ -195,6 +209,9 @@ void SvxOpenCLTabPage::Reset( const SfxItemSet* ) { maConfig = OpenCLConfig::get(); + mpUseSwInterpreter->Check(officecfg::Office::Common::Misc::UseSwInterpreter::get()); + mpUseSwInterpreter->SaveValue(); + mpUseOpenCL->Check(maConfig.mbUseOpenCL); mpUseOpenCL->SaveValue(); diff --git a/cui/source/options/optopencl.hxx b/cui/source/options/optopencl.hxx index fe91fe1f440f..10dc30b5ce2b 100644 --- a/cui/source/options/optopencl.hxx +++ b/cui/source/options/optopencl.hxx @@ -31,6 +31,7 @@ class SvxOpenCLTabPage : public SfxTabPage private: OpenCLConfig maConfig; + VclPtr<CheckBox> mpUseSwInterpreter; VclPtr<CheckBox> mpUseOpenCL; VclPtr<VclFrame> mpBlackListFrame; diff --git a/cui/uiconfig/ui/optopenclpage.ui b/cui/uiconfig/ui/optopenclpage.ui index 89ac882818a0..2cad763361ca 100644 --- a/cui/uiconfig/ui/optopenclpage.ui +++ b/cui/uiconfig/ui/optopenclpage.ui @@ -26,6 +26,22 @@ <property name="orientation">vertical</property> <property name="spacing">12</property> <child> + <object class="GtkCheckButton" id="useswinterpreter"> + <property name="label" translatable="yes">Allow use of Software Interpreter (even when OpenCL is not available)</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> <object class="GtkCheckButton" id="useopencl"> <property name="label" translatable="yes">Allow use of OpenCL</property> <property name="visible">True</property> @@ -38,7 +54,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">0</property> + <property name="position">1</property> </packing> </child> <child> diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index ebfe66f5bb80..8fe1457d4520 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -5642,6 +5642,13 @@ </info> <value oor:separator=";">Linux//Advanced Micro Devices, Inc\.//1445\.5 \(sse2,avx\);//Advanced Micro Devices, Inc\.//;//Intel\(R\) Corporation//;//NVIDIA Corporation//</value> </prop> + <prop oor:name="UseSwInterpreter" oor:type="xs:boolean" oor:nillable="false"> + <info> + <desc>Determines whether Software Interpreter can be used to speed + up some operations on Calc formulas.</desc> + </info> + <value>false</value> + </prop> <prop oor:name="MacroRecorderMode" oor:type="xs:boolean" oor:nillable="false"> <info> <desc>Determines if the limited, and awkward code producing 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; |