Kaydet (Commit) 089a4f24 authored tarafından Luboš Luňák's avatar Luboš Luňák Kaydeden (comit) Tor Lillqvist

remove Calc's software interpreter

- it's in practice never used nowadays, group threading has higher
priority in the code and since SwInterpreter's allowed opcodes are
a subset of group threading's, there should be no formula where
control flow gets as far as using SwInterpreter
- the only opcodes SwInterpreter allows are ocAdd, ocSub, ocMul,
ocDiv, ocSum and ocProduct, which is a rather limited set and group
threading should handle all that as well
- if SwInterpreter performs anything better than group threading,
there shouldn't be a problem doing the same for group threading
- it's yet another code path that should be handled, tested, etc.
and the added complexity is not worth it
- it shares some code with OpenCL handling, which is both added
hassle in case OpenCL code needs changes, and it also causes confusion
such as people thinking SwInterpreter has something to do with OpenCL

Change-Id: I99052862b60b6266c70dd436d1d7938177dc6bd9
Reviewed-on: https://gerrit.libreoffice.org/58643
Tested-by: Jenkins
Reviewed-by: 's avatarTor Lillqvist <tml@collabora.com>
üst 954f59db
......@@ -2112,8 +2112,6 @@ namespace comphelper
"ForceOpenGL", "false"));
xRootElement->appendChild(lcl_getConfigElement(xDocument, "/org.openoffice.Office.Common/Misc",
"UseOpenCL", "false"));
xRootElement->appendChild(lcl_getConfigElement(xDocument, "/org.openoffice.Office.Common/Misc",
"UseSwInterpreter", "false"));
// write back
uno::Reference< xml::sax::XSAXSerializable > xSerializer(xDocument, uno::UNO_QUERY);
......
......@@ -341,12 +341,9 @@ OUString AboutDialog::GetVersionString()
OUString aCalcMode = "Calc: "; // Calc calculation mode
#if HAVE_FEATURE_OPENCL
bool bSWInterp = officecfg::Office::Common::Misc::UseSwInterpreter::get();
bool bOpenCL = openclwrapper::GPUEnv::isOpenCLEnabled();
if (bOpenCL)
aCalcMode += "CL";
else if (bSWInterp)
aCalcMode += "group";
#else
const bool bOpenCL = false;
#endif
......
......@@ -47,14 +47,10 @@ 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(mpOclUsed,"openclused");
get(mpOclNotUsed,"openclnotused");
mpUseSwInterpreter->Check(officecfg::Office::Common::Misc::UseSwInterpreter::get());
mpUseSwInterpreter->Enable(!officecfg::Office::Common::Misc::UseSwInterpreter::isReadOnly());
mpUseOpenCL->Check(maConfig.mbUseOpenCL);
mpUseOpenCL->Enable(!officecfg::Office::Common::Misc::UseOpenCL::isReadOnly());
......@@ -70,7 +66,6 @@ SvxOpenCLTabPage::~SvxOpenCLTabPage()
void SvxOpenCLTabPage::dispose()
{
mpUseSwInterpreter.clear();
mpUseOpenCL.clear();
mpOclUsed.clear();
mpOclNotUsed.clear();
......@@ -88,12 +83,6 @@ 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;
}
if (mpUseOpenCL->IsValueChangedFromSaved())
maConfig.mbUseOpenCL = mpUseOpenCL->IsChecked();
......@@ -127,9 +116,6 @@ 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,7 +31,6 @@ class SvxOpenCLTabPage : public SfxTabPage
private:
OpenCLConfig maConfig;
VclPtr<CheckBox> mpUseSwInterpreter;
VclPtr<CheckBox> mpUseOpenCL;
VclPtr<FixedText> mpOclUsed;
......
......@@ -25,22 +25,6 @@
<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" context="optopenclpage|useswinterpreter">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" context="optopenclpage|useopencl">Allow use of OpenCL</property>
......
......@@ -5417,13 +5417,6 @@
</info>
<value>none</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>true</value>
</prop>
<prop oor:name="MacroRecorderMode" oor:type="xs:boolean" oor:nillable="false">
<info>
<desc>Determines if the limited, and awkward code producing
......
......@@ -47,7 +47,6 @@ struct SC_DLLPUBLIC ScCalcConfig
static bool isOpenCLEnabled();
static bool isThreadingEnabled();
static bool isSwInterpreterEnabled();
bool mbOpenCLSubsetOnly:1;
bool mbOpenCLAutoSelect:1;
......@@ -57,7 +56,6 @@ struct SC_DLLPUBLIC ScCalcConfig
typedef std::shared_ptr<std::set<OpCode>> OpCodeSet;
OpCodeSet mpOpenCLSubsetOpCodes;
OpCodeSet mpSwInterpreterSubsetOpCodes;
ScCalcConfig();
......
......@@ -146,16 +146,6 @@ public:
virtual bool interpret(ScDocument& rDoc, const ScAddress& rTopPos, ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode) = 0;
};
/// Inherit from this for alternate formula group calculation approaches.
class SC_DLLPUBLIC FormulaGroupInterpreterSoftware : public FormulaGroupInterpreter
{
public:
FormulaGroupInterpreterSoftware();
virtual ScMatrixRef inverseMatrix(const ScMatrix& rMat) override;
virtual bool interpret(ScDocument& rDoc, const ScAddress& rTopPos, ScFormulaCellGroupRef& xGroup, ScTokenArray& rCode) override;
};
}
#endif
......
......@@ -65,7 +65,6 @@ public:
CPPUNIT_TEST_SUITE(ScPerfObj);
CPPUNIT_TEST(testSheetFindAll);
CPPUNIT_TEST(testFixedSum);
CPPUNIT_TEST(testFormulaGroupSWInterpreter);
CPPUNIT_TEST(testSheetNamedRanges);
CPPUNIT_TEST(testSheets);
CPPUNIT_TEST(testSum);
......@@ -103,7 +102,6 @@ private:
void testSubTotalWithoutFormulas();
void testLoadingFileWithSingleBigSheet();
void testFixedSum();
void testFormulaGroupSWInterpreter();
void testMatConcatSmall();
void testMatConcatLarge();
};
......@@ -697,36 +695,6 @@ void ScPerfObj::testFixedSum()
}
}
void ScPerfObj::testFormulaGroupSWInterpreter()
{
// 1. Create spreadsheet
SpreadsheetDoc aSpreadsheet;
// 2. Disable OpenCL
ScModelObj* pModel = aSpreadsheet.GetModel();
pModel->enableOpenCL(false);
CPPUNIT_ASSERT(!ScCalcConfig::isOpenCLEnabled());
pModel->enableAutomaticCalculation(false);
// 3. Setup data and formulas
ScDocument& rDoc = aSpreadsheet.GetDocument();
for (unsigned int r = 0; r <= 10000; ++r)
rDoc.SetValue( ScAddress(0,r,0), r+1 );
rDoc.SetString(ScAddress(1,0,0), "=A1");
rDoc.SetString(ScAddress(2,0,0), "=PRODUCT(A1,SUM(B1:B$10000))");
aSpreadsheet.copyRange("B1:C1", "B2:C10000");
// 4. Calculate
callgrindStart();
pModel->calculateAll();
callgrindDump("sc:formula_group_sw_interpreter");
// 5. Automatically close the document (Ctrl-W) on spreadsheet destruction
}
void ScPerfObj::testMatConcatSmall()
{
uno::Reference< sheet::XSpreadsheetDocument > xDoc(init("empty.ods"), UNO_QUERY_THROW);
......
......@@ -209,7 +209,6 @@ void ScCopyPasteTest::testTdf84411()
pModel->enableOpenCL(false);
CPPUNIT_ASSERT(!ScCalcConfig::isOpenCLEnabled());
pModel->enableAutomaticCalculation(true);
CPPUNIT_ASSERT( ScCalcConfig::isSwInterpreterEnabled() );
// 4. Copy and Paste
......
......@@ -865,48 +865,30 @@ void Test::testFormulaHashAndTag()
struct {
const char* pFormula;
ScFormulaVectorState eState;
ScFormulaVectorState eSwInterpreterState; // these can change when more is whitelisted
} aVectorTests[] = {
{ "=SUM(1;2;3;4;5)", FormulaVectorEnabled, FormulaVectorEnabled },
{ "=NOW()", FormulaVectorDisabled, FormulaVectorDisabled },
{ "=AVERAGE(X1:Y200)", FormulaVectorCheckReference, FormulaVectorDisabled },
{ "=MAX(X1:Y200;10;20)", FormulaVectorCheckReference, FormulaVectorDisabled },
{ "=MIN(10;11;22)", FormulaVectorEnabled, FormulaVectorDisabled },
{ "=H4", FormulaVectorCheckReference, FormulaVectorCheckReference },
{ "=SUM(1;2;3;4;5)", FormulaVectorEnabled },
{ "=NOW()", FormulaVectorDisabled },
{ "=AVERAGE(X1:Y200)", FormulaVectorCheckReference },
{ "=MAX(X1:Y200;10;20)", FormulaVectorCheckReference },
{ "=MIN(10;11;22)", FormulaVectorEnabled },
{ "=H4", FormulaVectorCheckReference },
};
bool bSwInterpreter = officecfg::Office::Common::Misc::UseSwInterpreter::get();
bool bOpenCL = officecfg::Office::Common::Misc::UseOpenCL::get();
for (bool bForceSwInterpreter : { false, true })
for (size_t i = 0; i < SAL_N_ELEMENTS(aVectorTests); ++i)
{
std::shared_ptr< comphelper::ConfigurationChanges > xBatch(comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Misc::UseSwInterpreter::set(bForceSwInterpreter, xBatch);
if (bForceSwInterpreter)
officecfg::Office::Common::Misc::UseOpenCL::set(false, xBatch);
xBatch->commit();
m_pDoc->SetString(aPos1, OUString::createFromAscii(aVectorTests[i].pFormula));
ScFormulaVectorState eState = m_pDoc->GetFormulaVectorState(aPos1);
ScFormulaVectorState eReferenceState = aVectorTests[i].eState;
for (size_t i = 0; i < SAL_N_ELEMENTS(aVectorTests); ++i)
if (eState != eReferenceState)
{
m_pDoc->SetString(aPos1, OUString::createFromAscii(aVectorTests[i].pFormula));
ScFormulaVectorState eState = m_pDoc->GetFormulaVectorState(aPos1);
ScFormulaVectorState eReferenceState = bForceSwInterpreter? aVectorTests[i].eSwInterpreterState: aVectorTests[i].eState;
if (eState != eReferenceState)
{
std::ostringstream os;
os << "Unexpected vectorization state: expr: '" << aVectorTests[i].pFormula << "', using software interpreter: " << bForceSwInterpreter;
CPPUNIT_ASSERT_MESSAGE(os.str(), false);
}
aPos1.IncRow();
std::ostringstream os;
os << "Unexpected vectorization state: expr: '" << aVectorTests[i].pFormula << "'";
CPPUNIT_ASSERT_MESSAGE(os.str(), false);
}
aPos1.IncRow();
}
std::shared_ptr< comphelper::ConfigurationChanges > xBatch(comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Misc::UseSwInterpreter::set(bSwInterpreter, xBatch);
officecfg::Office::Common::Misc::UseOpenCL::set(bOpenCL, xBatch);
xBatch->commit();
m_pDoc->DeleteTab(0);
}
......
......@@ -4526,17 +4526,14 @@ bool ScFormulaCell::InterpretFormulaGroup()
bool bDependencyComputed = false;
bool bDependencyCheckFailed = false;
// Preference order:
// First try OpenCL, but only if actual OpenCL is available (i.e. no SwInterpreter).
// Then try threading and as the last one try SwInterpreter.
if( ScCalcConfig::isOpenCLEnabled())
if( InterpretFormulaGroupOpenCL(aScope, bDependencyComputed, bDependencyCheckFailed))
return true;
// Preference order: First try OpenCL, then threading.
if( InterpretFormulaGroupOpenCL(aScope, bDependencyComputed, bDependencyCheckFailed))
return true;
if( InterpretFormulaGroupThreading(aScope, bDependencyComputed, bDependencyCheckFailed))
return true;
return InterpretFormulaGroupOpenCL(aScope, bDependencyComputed, bDependencyCheckFailed);
return false;
}
bool ScFormulaCell::CheckComputeDependencies(sc::FormulaLogger::GroupScope& rScope)
......@@ -4726,9 +4723,9 @@ bool ScFormulaCell::InterpretFormulaGroupOpenCL(sc::FormulaLogger::GroupScope& a
if (!bCanVectorize)
return false;
if (!ScCalcConfig::isOpenCLEnabled() && !ScCalcConfig::isSwInterpreterEnabled())
if (!ScCalcConfig::isOpenCLEnabled())
{
aScope.addMessage("opencl not enabled and sw interpreter not enabled");
aScope.addMessage("opencl not enabled");
return false;
}
......
......@@ -59,14 +59,6 @@ bool ScCalcConfig::isThreadingEnabled()
return gThreadingEnabled.get();
}
bool ScCalcConfig::isSwInterpreterEnabled()
{
if (utl::ConfigManager::IsFuzzing())
return false;
static comphelper::ConfigurationListenerProperty<bool> gSwInterpreterEnabled(getMiscListener(), "UseSwInterpreter");
return gSwInterpreterEnabled.get();
}
ScCalcConfig::ScCalcConfig() :
meStringRefAddressSyntax(formula::FormulaGrammar::CONV_UNSPECIFIED),
meStringConversion(StringConversion::LOCALE), // old LibreOffice behavior
......@@ -115,15 +107,6 @@ 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.
......@@ -131,7 +114,6 @@ void ScCalcConfig::setOpenCLConfigToDefault()
mbOpenCLAutoSelect = true;
mnOpenCLMinimumFormulaGroupSize = 100;
mpOpenCLSubsetOpCodes = pDefaultOpenCLSubsetOpCodes;
mpSwInterpreterSubsetOpCodes = pDefaultSwInterpreterSubsetOpCodes;
}
void ScCalcConfig::reset()
......@@ -165,8 +147,7 @@ bool ScCalcConfig::operator== (const ScCalcConfig& r) const
mbOpenCLAutoSelect == r.mbOpenCLAutoSelect &&
maOpenCLDevice == r.maOpenCLDevice &&
mnOpenCLMinimumFormulaGroupSize == r.mnOpenCLMinimumFormulaGroupSize &&
*mpOpenCLSubsetOpCodes == *r.mpOpenCLSubsetOpCodes &&
*mpSwInterpreterSubsetOpCodes == *r.mpSwInterpreterSubsetOpCodes;
*mpOpenCLSubsetOpCodes == *r.mpOpenCLSubsetOpCodes;
}
bool ScCalcConfig::operator!= (const ScCalcConfig& r) const
......
......@@ -269,8 +269,6 @@ FormulaLogger::FormulaLogger()
writeAscii("---\n");
writeAscii("OpenCL: ");
writeAscii(ScCalcConfig::isOpenCLEnabled() ? "enabled\n" : "disabled\n");
writeAscii("Software Interpreter: ");
writeAscii(ScCalcConfig::isSwInterpreterEnabled() ? "enabled\n" : "disabled\n");
writeAscii("---\n");
sync();
......
......@@ -1376,19 +1376,6 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
return;
}
// 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())
{
SAL_INFO("sc.core.formulagroup", "opcode " << formula::FormulaCompiler().GetOpCodeMap(sheet::FormulaLanguage::ENGLISH)->getSymbol(eOp)
<< "(" << int(eOp) << ") disables S/W interpreter for formula group");
meVectorState = FormulaVectorDisabledNotInSoftwareSubset;
mbOpenCLEnabled = false;
return;
}
// We support vectorization for the following opcodes.
switch (eOp)
{
......@@ -1627,18 +1614,6 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
mbOpenCLEnabled = false;
return;
}
// only when openCL interpreter is not enabled - the assumption is that
// the S/W interpreter blacklist is more strict
else if (ScCalcConfig::isSwInterpreterEnabled() &&
(dynamic_cast<sc::FormulaGroupInterpreterSoftware*>(sc::FormulaGroupInterpreter::getStatic()) != nullptr) &&
ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->find(eOp) == ScInterpreter::GetGlobalConfig().mpSwInterpreterSubsetOpCodes->end())
{
SAL_INFO("sc.core.formulagroup", "opcode " << formula::FormulaCompiler().GetOpCodeMap(sheet::FormulaLanguage::ENGLISH)->getSymbol(eOp)
<< "(" << int(eOp) << ") disables S/W interpreter for formula group");
meVectorState = FormulaVectorDisabledNotInSoftwareSubset;
mbOpenCLEnabled = false;
return;
}
}
else
{
......@@ -1825,7 +1800,7 @@ void ScTokenArray::GenHash()
void ScTokenArray::ResetVectorState()
{
mbOpenCLEnabled = ScCalcConfig::isOpenCLEnabled() || ScCalcConfig::isSwInterpreterEnabled();
mbOpenCLEnabled = ScCalcConfig::isOpenCLEnabled();
meVectorState = mbOpenCLEnabled ? FormulaVectorEnabled : FormulaVectorDisabled;
mbThreadingEnabled = ScCalcConfig::isThreadingEnabled();
}
......
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