Kaydet (Commit) d4afaa72 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

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
üst 42aedc25
......@@ -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();
......
......@@ -31,6 +31,7 @@ class SvxOpenCLTabPage : public SfxTabPage
private:
OpenCLConfig maConfig;
VclPtr<CheckBox> mpUseSwInterpreter;
VclPtr<CheckBox> mpUseOpenCL;
VclPtr<VclFrame> mpBlackListFrame;
......
......@@ -25,6 +25,22 @@
<property name="vexpand">True</property>
<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>
......@@ -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>
......
......@@ -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
......
......@@ -49,6 +49,7 @@ struct SC_DLLPUBLIC ScCalcConfig
bool mbHasStringRefSyntax:1;
static bool isOpenCLEnabled();
static bool isSwInterpreterEnabled();
bool mbOpenCLSubsetOnly:1;
bool mbOpenCLAutoSelect:1;
......
......@@ -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
......
......@@ -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
......
......@@ -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;
......
......@@ -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;
......
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