summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2015-10-14 19:28:47 +0100
committerMichael Meeks <michael.meeks@collabora.com>2015-10-14 19:36:56 +0000
commit866909c1db1c81fc6b64184bbc715766a09e2d4b (patch)
treed75908477e48a35e660b6e4198e604541d701fb6 /sc
parent8840a66faceb5ebff2e6021e9b14da691d420234 (diff)
Improve performance by using the ScCalcOptions for OpenCL.
Use the new configurationlistener to track the relevant setting. Change-Id: I9decea55df25f7eb34cd2fef94743d1907360d16 Reviewed-on: https://gerrit.libreoffice.org/19377 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/calcconfig.hxx4
-rw-r--r--sc/source/core/data/formulacell.cxx3
-rw-r--r--sc/source/core/inc/interpre.hxx3
-rw-r--r--sc/source/core/tool/calcconfig.cxx16
-rw-r--r--sc/source/core/tool/formulagroup.cxx8
-rw-r--r--sc/source/core/tool/interpr1.cxx2
-rw-r--r--sc/source/core/tool/interpr4.cxx13
-rw-r--r--sc/source/core/tool/interpr5.cxx3
8 files changed, 38 insertions, 14 deletions
diff --git a/sc/inc/calcconfig.hxx b/sc/inc/calcconfig.hxx
index 29337eafc764..158bc1a53f20 100644
--- a/sc/inc/calcconfig.hxx
+++ b/sc/inc/calcconfig.hxx
@@ -20,6 +20,8 @@
#include <formula/opcode.hxx>
#include <rtl/ustring.hxx>
+#include <comphelper/configurationlistener.hxx>
+
// have to match the registry values
enum ScRecalcOptions
{
@@ -46,6 +48,8 @@ struct SC_DLLPUBLIC ScCalcConfig
bool mbEmptyStringAsZero:1;
bool mbHasStringRefSyntax:1;
+ comphelper::ConfigurationListenerProperty<bool> mbOpenCLEnabled;
+
bool mbOpenCLSubsetOnly:1;
bool mbOpenCLAutoSelect:1;
OUString maOpenCLDevice;
diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx
index 06f6439fafc3..09a06bd579a5 100644
--- a/sc/source/core/data/formulacell.cxx
+++ b/sc/source/core/data/formulacell.cxx
@@ -60,7 +60,6 @@
#include <listenerquery.hxx>
#include <listenerqueryids.hxx>
#include <grouparealistener.hxx>
-#include <officecfg/Office/Common.hxx>
#include <memory>
#include <boost/ptr_container/ptr_map.hpp>
@@ -3891,7 +3890,7 @@ bool ScFormulaCell::InterpretFormulaGroup()
return false;
}
- if (!officecfg::Office::Common::Misc::UseOpenCL::get())
+ if (!ScInterpreter::GetGlobalConfig().mbOpenCLEnabled.get())
return false;
// TODO : Disable invariant formula group interpretation for now in order
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 280d9d1548a3..22f9d11582d7 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -146,7 +146,8 @@ public:
VolatileType GetVolatileType() const { return meVolatileType;}
private:
- static ScCalcConfig maGlobalConfig;
+ static ScCalcConfig& GetOrCreateGlobalConfig();
+ static ScCalcConfig *mpGlobalConfig;
static ScTokenStack* pGlobalStack;
static bool bGlobalStackInUse;
diff --git a/sc/source/core/tool/calcconfig.cxx b/sc/source/core/tool/calcconfig.cxx
index 1f040054fede..a1ac442378d0 100644
--- a/sc/source/core/tool/calcconfig.cxx
+++ b/sc/source/core/tool/calcconfig.cxx
@@ -20,11 +20,25 @@
#include "compiler.hxx"
#include "docsh.hxx"
+#include <comphelper/configurationlistener.hxx>
+
+using comphelper::ConfigurationListener;
+
+static rtl::Reference<ConfigurationListener> getMiscListener()
+{
+ static rtl::Reference<ConfigurationListener> xListener;
+ if (!xListener.is())
+ xListener = rtl::Reference<ConfigurationListener>(
+ new ConfigurationListener("/org.openoffice.Office.Common/Misc"));
+ return xListener;
+}
+
ScCalcConfig::ScCalcConfig() :
meStringRefAddressSyntax(formula::FormulaGrammar::CONV_UNSPECIFIED),
meStringConversion(StringConversion::LOCALE), // old LibreOffice behavior
mbEmptyStringAsZero(false),
- mbHasStringRefSyntax(false)
+ mbHasStringRefSyntax(false),
+ mbOpenCLEnabled(getMiscListener(), "UseOpenCL")
{
setOpenCLConfigToDefault();
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index f3dcd375c9df..659c2318ad01 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -477,7 +477,7 @@ FormulaGroupInterpreter *FormulaGroupInterpreter::getStatic()
{
#if HAVE_FEATURE_OPENCL
const ScCalcConfig& rConfig = ScInterpreter::GetGlobalConfig();
- if (officecfg::Office::Common::Misc::UseOpenCL::get())
+ if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled.get())
switchOpenCLDevice(rConfig.maOpenCLDevice, rConfig.mbOpenCLAutoSelect);
#endif
static bool bAllowSoftwareInterpreter = (getenv("SC_ALLOW_BROKEN_SOFTWARE_INTERPRETER") != NULL);
@@ -503,7 +503,7 @@ void FormulaGroupInterpreter::fillOpenCLInfo(std::vector<OpenCLPlatformInfo>& rP
bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool bAutoSelect, bool bForceEvaluation)
{
- bool bOpenCLEnabled = officecfg::Office::Common::Misc::UseOpenCL::get();
+ bool bOpenCLEnabled = ScInterpreter::GetGlobalConfig().mbOpenCLEnabled.get();
static bool bAllowSoftwareInterpreter = (getenv("SC_ALLOW_BROKEN_SOFTWARE_INTERPRETER") != NULL);
if (!bOpenCLEnabled || (bAllowSoftwareInterpreter && rDeviceId == OPENCL_SOFTWARE_DEVICE_CONFIG_NAME))
{
@@ -526,7 +526,7 @@ bool FormulaGroupInterpreter::switchOpenCLDevice(const OUString& rDeviceId, bool
delete msInstance;
msInstance = NULL;
- if ( officecfg::Office::Common::Misc::UseOpenCL::get() )
+ if ( ScInterpreter::GetGlobalConfig().mbOpenCLEnabled.get() )
{
msInstance = new sc::opencl::FormulaGroupInterpreterOpenCL();
return msInstance != NULL;
@@ -539,7 +539,7 @@ void FormulaGroupInterpreter::getOpenCLDeviceInfo(sal_Int32& rDeviceId, sal_Int3
{
rDeviceId = -1;
rPlatformId = -1;
- bool bOpenCLEnabled = officecfg::Office::Common::Misc::UseOpenCL::get();
+ bool bOpenCLEnabled = ScInterpreter::GetGlobalConfig().mbOpenCLEnabled.get();
if(!bOpenCLEnabled)
return;
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index b9cdc1c4e838..e4838e4251c1 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -76,7 +76,7 @@ static const sal_uInt64 n2power48 = SAL_CONST_UINT64( 281474976710656); // 2^48
IMPL_FIXEDMEMPOOL_NEWDEL( ScTokenStack )
IMPL_FIXEDMEMPOOL_NEWDEL( ScInterpreter )
-ScCalcConfig ScInterpreter::maGlobalConfig;
+ScCalcConfig *ScInterpreter::mpGlobalConfig = NULL;
ScTokenStack* ScInterpreter::pGlobalStack = NULL;
bool ScInterpreter::bGlobalStackInUse = false;
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index e8a3b1d454aa..bd84fa625afd 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3503,19 +3503,26 @@ ScInterpreter::~ScInterpreter()
delete pTokenMatrixMap;
}
+ScCalcConfig& ScInterpreter::GetOrCreateGlobalConfig()
+{
+ if (!mpGlobalConfig)
+ mpGlobalConfig = new ScCalcConfig();
+ return *mpGlobalConfig;
+}
+
void ScInterpreter::SetGlobalConfig(const ScCalcConfig& rConfig)
{
- maGlobalConfig = rConfig;
+ GetOrCreateGlobalConfig() = rConfig;
}
const ScCalcConfig& ScInterpreter::GetGlobalConfig()
{
- return maGlobalConfig;
+ return GetOrCreateGlobalConfig();
}
void ScInterpreter::MergeCalcConfig()
{
- maCalcConfig = maGlobalConfig;
+ maCalcConfig = GetOrCreateGlobalConfig();
maCalcConfig.MergeDocumentSpecific( pDok->GetCalcConfig());
}
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 0d2fb0a7456c..88cd12dd9a5c 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -26,7 +26,6 @@
#endif
#include <unotools/bootstrap.hxx>
-#include <officecfg/Office/Common.hxx>
#include <svl/zforlist.hxx>
#include "interpre.hxx"
@@ -912,7 +911,7 @@ void ScInterpreter::ScMatInv()
SCSIZE nC, nR;
pMat->GetDimensions(nC, nR);
- if (officecfg::Office::Common::Misc::UseOpenCL::get())
+ if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled.get())
{
sc::FormulaGroupInterpreter *pInterpreter = sc::FormulaGroupInterpreter::getStatic();
if (pInterpreter != NULL)