Kaydet (Commit) 1fa23989 authored tarafından Michael Meeks's avatar Michael Meeks Kaydeden (comit) Tor Lillqvist

Tentative performance improvement.

Change-Id: Iec3a6a6869a4546f3d10928470361716d7b10243
üst ec765242
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "scdllapi.h" #include "scdllapi.h"
#include <memory>
#include <ostream> #include <ostream>
#include <set> #include <set>
...@@ -50,9 +51,9 @@ struct SC_DLLPUBLIC ScCalcConfig ...@@ -50,9 +51,9 @@ struct SC_DLLPUBLIC ScCalcConfig
OUString maOpenCLDevice; OUString maOpenCLDevice;
sal_Int32 mnOpenCLMinimumFormulaGroupSize; sal_Int32 mnOpenCLMinimumFormulaGroupSize;
typedef std::set<OpCode> OpCodeSet; typedef std::shared_ptr<std::set<OpCode>> OpCodeSet;
OpCodeSet maOpenCLSubsetOpCodes; OpCodeSet mpOpenCLSubsetOpCodes;
ScCalcConfig(); ScCalcConfig();
......
...@@ -35,7 +35,7 @@ void ScCalcConfig::setOpenCLConfigToDefault() ...@@ -35,7 +35,7 @@ void ScCalcConfig::setOpenCLConfigToDefault()
{ {
// Keep in order of opcode value, is that clearest? (Random order, // Keep in order of opcode value, is that clearest? (Random order,
// at least, would make no sense at all.) // at least, would make no sense at all.)
static const OpCodeSet aDefaultOpenCLSubsetOpCodes { static const std::set<OpCode> aDefaultOpenCLSubsetOpCodes {
ocAdd, ocAdd,
ocSub, ocSub,
ocMul, ocMul,
...@@ -74,7 +74,7 @@ void ScCalcConfig::setOpenCLConfigToDefault() ...@@ -74,7 +74,7 @@ void ScCalcConfig::setOpenCLConfigToDefault()
mbOpenCLSubsetOnly = true; mbOpenCLSubsetOnly = true;
mbOpenCLAutoSelect = true; mbOpenCLAutoSelect = true;
mnOpenCLMinimumFormulaGroupSize = 100; mnOpenCLMinimumFormulaGroupSize = 100;
maOpenCLSubsetOpCodes = aDefaultOpenCLSubsetOpCodes; mpOpenCLSubsetOpCodes.reset(new std::set<OpCode>(aDefaultOpenCLSubsetOpCodes));
} }
void ScCalcConfig::reset() void ScCalcConfig::reset()
...@@ -108,7 +108,7 @@ bool ScCalcConfig::operator== (const ScCalcConfig& r) const ...@@ -108,7 +108,7 @@ bool ScCalcConfig::operator== (const ScCalcConfig& r) const
mbOpenCLAutoSelect == r.mbOpenCLAutoSelect && mbOpenCLAutoSelect == r.mbOpenCLAutoSelect &&
maOpenCLDevice == r.maOpenCLDevice && maOpenCLDevice == r.maOpenCLDevice &&
mnOpenCLMinimumFormulaGroupSize == r.mnOpenCLMinimumFormulaGroupSize && mnOpenCLMinimumFormulaGroupSize == r.mnOpenCLMinimumFormulaGroupSize &&
maOpenCLSubsetOpCodes == r.maOpenCLSubsetOpCodes && *mpOpenCLSubsetOpCodes == *r.mpOpenCLSubsetOpCodes &&
true; true;
} }
...@@ -144,7 +144,7 @@ std::ostream& operator<<(std::ostream& rStream, const ScCalcConfig& rConfig) ...@@ -144,7 +144,7 @@ std::ostream& operator<<(std::ostream& rStream, const ScCalcConfig& rConfig)
"OpenCLAutoSelect=" << (rConfig.mbOpenCLAutoSelect?"Y":"N") << "," "OpenCLAutoSelect=" << (rConfig.mbOpenCLAutoSelect?"Y":"N") << ","
"OpenCLDevice='" << rConfig.maOpenCLDevice << "'," "OpenCLDevice='" << rConfig.maOpenCLDevice << "',"
"OpenCLMinimumFormulaGroupSize=" << rConfig.mnOpenCLMinimumFormulaGroupSize << "," "OpenCLMinimumFormulaGroupSize=" << rConfig.mnOpenCLMinimumFormulaGroupSize << ","
"OpenCLSubsetOpCodes={" << ScOpCodeSetToSymbolicString(rConfig.maOpenCLSubsetOpCodes) << "}," "OpenCLSubsetOpCodes={" << ScOpCodeSetToSymbolicString(rConfig.mpOpenCLSubsetOpCodes) << "},"
"}"; "}";
return rStream; return rStream;
} }
...@@ -155,9 +155,9 @@ OUString ScOpCodeSetToSymbolicString(const ScCalcConfig::OpCodeSet& rOpCodes) ...@@ -155,9 +155,9 @@ OUString ScOpCodeSetToSymbolicString(const ScCalcConfig::OpCodeSet& rOpCodes)
formula::FormulaCompiler aCompiler; formula::FormulaCompiler aCompiler;
formula::FormulaCompiler::OpCodeMapPtr pOpCodeMap(aCompiler.GetOpCodeMap(css::sheet::FormulaLanguage::ENGLISH)); formula::FormulaCompiler::OpCodeMapPtr pOpCodeMap(aCompiler.GetOpCodeMap(css::sheet::FormulaLanguage::ENGLISH));
for (auto i = rOpCodes.cbegin(); i != rOpCodes.cend(); ++i) for (auto i = rOpCodes->cbegin(); i != rOpCodes->cend(); ++i)
{ {
if (i != rOpCodes.cbegin()) if (i != rOpCodes->cbegin())
result.append(';'); result.append(';');
result.append(pOpCodeMap->getSymbol(*i)); result.append(pOpCodeMap->getSymbol(*i));
} }
...@@ -167,7 +167,7 @@ OUString ScOpCodeSetToSymbolicString(const ScCalcConfig::OpCodeSet& rOpCodes) ...@@ -167,7 +167,7 @@ OUString ScOpCodeSetToSymbolicString(const ScCalcConfig::OpCodeSet& rOpCodes)
ScCalcConfig::OpCodeSet ScStringToOpCodeSet(const OUString& rOpCodes) ScCalcConfig::OpCodeSet ScStringToOpCodeSet(const OUString& rOpCodes)
{ {
ScCalcConfig::OpCodeSet result; ScCalcConfig::OpCodeSet result(new std::set< OpCode >());
formula::FormulaCompiler aCompiler; formula::FormulaCompiler aCompiler;
formula::FormulaCompiler::OpCodeMapPtr pOpCodeMap(aCompiler.GetOpCodeMap(css::sheet::FormulaLanguage::ENGLISH)); formula::FormulaCompiler::OpCodeMapPtr pOpCodeMap(aCompiler.GetOpCodeMap(css::sheet::FormulaLanguage::ENGLISH));
...@@ -184,12 +184,12 @@ ScCalcConfig::OpCodeSet ScStringToOpCodeSet(const OUString& rOpCodes) ...@@ -184,12 +184,12 @@ ScCalcConfig::OpCodeSet ScStringToOpCodeSet(const OUString& rOpCodes)
OUString element(s.copy(fromIndex, semicolon - fromIndex)); OUString element(s.copy(fromIndex, semicolon - fromIndex));
sal_Int32 n = element.toInt32(); sal_Int32 n = element.toInt32();
if (n > 0 || (n == 0 && element == "0")) if (n > 0 || (n == 0 && element == "0"))
result.insert(static_cast<OpCode>(n)); result->insert(static_cast<OpCode>(n));
else else
{ {
auto opcode(pHashMap->find(element)); auto opcode(pHashMap->find(element));
if (opcode != pHashMap->end()) if (opcode != pHashMap->end())
result.insert(static_cast<OpCode>(opcode->second)); result->insert(static_cast<OpCode>(opcode->second));
else else
SAL_WARN("sc.opencl", "Unrecognized OpCode " << element << " in OpCode set string"); SAL_WARN("sc.opencl", "Unrecognized OpCode " << element << " in OpCode set string");
} }
......
...@@ -491,9 +491,9 @@ void ScFormulaCfg::UpdateFromProperties( const Sequence<OUString>& aNames ) ...@@ -491,9 +491,9 @@ void ScFormulaCfg::UpdateFromProperties( const Sequence<OUString>& aNames )
break; break;
case SCFORMULAOPT_OPENCL_SUBSET_OPS: case SCFORMULAOPT_OPENCL_SUBSET_OPS:
{ {
OUString sVal = ScOpCodeSetToSymbolicString(GetCalcConfig().maOpenCLSubsetOpCodes); OUString sVal = ScOpCodeSetToSymbolicString(GetCalcConfig().mpOpenCLSubsetOpCodes);
pValues[nProp] >>= sVal; pValues[nProp] >>= sVal;
GetCalcConfig().maOpenCLSubsetOpCodes = ScStringToOpCodeSet(sVal); GetCalcConfig().mpOpenCLSubsetOpCodes = ScStringToOpCodeSet(sVal);
} }
break; break;
} }
...@@ -638,7 +638,7 @@ void ScFormulaCfg::ImplCommit() ...@@ -638,7 +638,7 @@ void ScFormulaCfg::ImplCommit()
break; break;
case SCFORMULAOPT_OPENCL_SUBSET_OPS: case SCFORMULAOPT_OPENCL_SUBSET_OPS:
{ {
OUString sVal = ScOpCodeSetToSymbolicString(GetCalcConfig().maOpenCLSubsetOpCodes); OUString sVal = ScOpCodeSetToSymbolicString(GetCalcConfig().mpOpenCLSubsetOpCodes);
pValues[nProp] <<= sVal; pValues[nProp] <<= sVal;
} }
break; break;
......
...@@ -1315,7 +1315,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r ) ...@@ -1315,7 +1315,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
if (SC_OPCODE_START_FUNCTION <= eOp && eOp < SC_OPCODE_STOP_FUNCTION) if (SC_OPCODE_START_FUNCTION <= eOp && eOp < SC_OPCODE_STOP_FUNCTION)
{ {
if (ScInterpreter::GetGlobalConfig().mbOpenCLSubsetOnly && ScInterpreter::GetGlobalConfig().maOpenCLSubsetOpCodes.find(eOp) == ScInterpreter::GetGlobalConfig().maOpenCLSubsetOpCodes.end()) if (ScInterpreter::GetGlobalConfig().mbOpenCLSubsetOnly && ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->find(eOp) == ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->end())
{ {
meVectorState = FormulaVectorDisabled; meVectorState = FormulaVectorDisabled;
return; return;
...@@ -1556,7 +1556,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r ) ...@@ -1556,7 +1556,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
if (eOp >= SC_OPCODE_START_BIN_OP && if (eOp >= SC_OPCODE_START_BIN_OP &&
eOp <= SC_OPCODE_STOP_UN_OP && eOp <= SC_OPCODE_STOP_UN_OP &&
ScInterpreter::GetGlobalConfig().mbOpenCLSubsetOnly && ScInterpreter::GetGlobalConfig().mbOpenCLSubsetOnly &&
ScInterpreter::GetGlobalConfig().maOpenCLSubsetOpCodes.find(eOp) == ScInterpreter::GetGlobalConfig().maOpenCLSubsetOpCodes.end()) ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->find(eOp) == ScInterpreter::GetGlobalConfig().mpOpenCLSubsetOpCodes->end())
{ {
meVectorState = FormulaVectorDisabled; meVectorState = FormulaVectorDisabled;
return; return;
......
...@@ -111,7 +111,7 @@ ScCalcOptionsDialog::ScCalcOptionsDialog(vcl::Window* pParent, const ScCalcConfi ...@@ -111,7 +111,7 @@ ScCalcOptionsDialog::ScCalcOptionsDialog(vcl::Window* pParent, const ScCalcConfi
mpSpinButton->SetModifyHdl(LINK(this, ScCalcOptionsDialog, SpinOpenCLMinSizeHdl)); mpSpinButton->SetModifyHdl(LINK(this, ScCalcOptionsDialog, SpinOpenCLMinSizeHdl));
get(mpEditField, "entry"); get(mpEditField, "entry");
mpEditField->SetText(ScOpCodeSetToSymbolicString(maConfig.maOpenCLSubsetOpCodes)); mpEditField->SetText(ScOpCodeSetToSymbolicString(maConfig.mpOpenCLSubsetOpCodes));
mpEditField->set_height_request(4 * mpEditField->GetTextHeight()); mpEditField->set_height_request(4 * mpEditField->GetTextHeight());
mpEditField->SetModifyHdl(LINK(this, ScCalcOptionsDialog, EditModifiedHdl)); mpEditField->SetModifyHdl(LINK(this, ScCalcOptionsDialog, EditModifiedHdl));
...@@ -252,7 +252,7 @@ IMPL_LINK_NOARG_TYPED(ScCalcOptionsDialog, DeviceSelHdl, SvTreeListBox*, void) ...@@ -252,7 +252,7 @@ IMPL_LINK_NOARG_TYPED(ScCalcOptionsDialog, DeviceSelHdl, SvTreeListBox*, void)
IMPL_LINK(ScCalcOptionsDialog, EditModifiedHdl, Edit*, pCtrl) IMPL_LINK(ScCalcOptionsDialog, EditModifiedHdl, Edit*, pCtrl)
{ {
maConfig.maOpenCLSubsetOpCodes = ScStringToOpCodeSet(pCtrl->GetText()); maConfig.mpOpenCLSubsetOpCodes = ScStringToOpCodeSet(pCtrl->GetText());
return 0; return 0;
} }
...@@ -286,7 +286,7 @@ struct OpenCLTester ...@@ -286,7 +286,7 @@ struct OpenCLTester
ScDocShell* mpDocShell; ScDocShell* mpDocShell;
ScDocument *mpDoc; ScDocument *mpDoc;
bool mbOldAutoCalc; bool mbOldAutoCalc;
ScCalcConfig maOldCalcConfig; ScCalcConfig mpOldCalcConfig;
OpenCLTester() : OpenCLTester() :
mnTestAreas(0) mnTestAreas(0)
...@@ -305,10 +305,10 @@ struct OpenCLTester ...@@ -305,10 +305,10 @@ struct OpenCLTester
mbOldAutoCalc = mpDoc->GetAutoCalc(); mbOldAutoCalc = mpDoc->GetAutoCalc();
mpDoc->SetAutoCalc(false); mpDoc->SetAutoCalc(false);
maOldCalcConfig = ScInterpreter::GetGlobalConfig(); mpOldCalcConfig = ScInterpreter::GetGlobalConfig();
ScCalcConfig aConfig(maOldCalcConfig); ScCalcConfig pConfig(mpOldCalcConfig);
aConfig.mnOpenCLMinimumFormulaGroupSize = 20; pConfig.mnOpenCLMinimumFormulaGroupSize = 20;
ScInterpreter::SetGlobalConfig(aConfig); ScInterpreter::SetGlobalConfig(pConfig);
mpDoc->SetString(ScAddress(0,0,0), "Result:"); mpDoc->SetString(ScAddress(0,0,0), "Result:");
} }
...@@ -815,7 +815,7 @@ IMPL_STATIC_LINK_TYPED(ScCalcOptionsDialog, TestClickHdl, Button*, pButton, void ...@@ -815,7 +815,7 @@ IMPL_STATIC_LINK_TYPED(ScCalcOptionsDialog, TestClickHdl, Button*, pButton, void
})); }));
xTestDocument->mpDoc->CalcAll(); xTestDocument->mpDoc->CalcAll();
ScInterpreter::SetGlobalConfig(xTestDocument->maOldCalcConfig); ScInterpreter::SetGlobalConfig(xTestDocument->mpOldCalcConfig);
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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