summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tools/cpuid.hxx1
-rw-r--r--sc/source/core/tool/formulagroup.cxx5
-rw-r--r--tools/source/misc/cpuid.cxx11
3 files changed, 15 insertions, 2 deletions
diff --git a/include/tools/cpuid.hxx b/include/tools/cpuid.hxx
index d7aa07d54258..419d05714ae4 100644
--- a/include/tools/cpuid.hxx
+++ b/include/tools/cpuid.hxx
@@ -25,6 +25,7 @@ namespace tools
namespace cpuid
{
TOOLS_DLLPUBLIC bool hasSSE2();
+ TOOLS_DLLPUBLIC bool hasHyperThreading();
}
}
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)
diff --git a/tools/source/misc/cpuid.cxx b/tools/source/misc/cpuid.cxx
index 1518dfc175c4..e3ba82dffda5 100644
--- a/tools/source/misc/cpuid.cxx
+++ b/tools/source/misc/cpuid.cxx
@@ -16,8 +16,6 @@ namespace tools
namespace cpuid
{
-#if defined(LO_SSE2_AVAILABLE)
-
namespace
{
#if defined(_MSC_VER)
@@ -35,6 +33,8 @@ void getCpuId(uint32_t array[4])
#endif
}
+#if defined(LO_SSE2_AVAILABLE)
+
bool hasSSE2()
{
uint32_t cpuInfoArray[] = {0, 0, 0, 0};
@@ -48,6 +48,13 @@ bool hasSSE2() { return false; }
#endif
+bool hasHyperThreading()
+{
+ uint32_t cpuInfoArray[] = {0, 0, 0, 0};
+ getCpuId(cpuInfoArray);
+ return (cpuInfoArray[3] & (1 << 28)) != 0;
+}
+
}
}