summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.co.uk>2017-11-15 16:37:45 +0530
committerDennis Francis <dennis.francis@collabora.co.uk>2017-11-21 16:09:43 +0530
commit4defacd1fa2be800f3e7258abbb4ef2cd1834d31 (patch)
treee0af263eec8141029fb583cb51ad8b607e3a1025 /sc
parentfbcdce22bce6d6d1ba5a9e90b642ea08fc09916a (diff)
halve the number of threads if HT is active
added hasHyperThreading() function to tools::cpuid to detect hyperthreading. Change-Id: I13fab4b6c649e681c329b7e3f4c9f36bda879d84
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/tool/formulagroup.cxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index b7968acb19d8..f5b90416e95f 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -19,6 +19,7 @@
#include <scmatrix.hxx>
#include <globalnames.hxx>
#include <comphelper/threadpool.hxx>
+#include <tools/cpuid.hxx>
#include <formula/vectortoken.hxx>
#include <officecfg/Office/Common.hxx>
@@ -299,6 +300,7 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
// The caller must ensure that the top position is the start position of
// the group.
+ static bool bHyperThreadingActive = tools::cpuid::hasHyperThreading();
ScAddress aTmpPos = rTopPos;
std::vector<formula::FormulaConstTokenRef> aResults(xGroup->mnLength);
@@ -335,6 +337,9 @@ bool FormulaGroupInterpreterSoftware::interpret(ScDocument& rDoc, const ScAddres
comphelper::ThreadPool& rThreadPool(comphelper::ThreadPool::getSharedOptimalPool());
sal_Int32 nThreadCount = rThreadPool.getWorkerCount();
+ if ( bHyperThreadingActive && nThreadCount >= 2 )
+ nThreadCount /= 2;
+
SCROW nLen = xGroup->mnLength;
SCROW nBatchSize = nLen / nThreadCount;
if (nLen < nThreadCount)