[Libreoffice-commits] core.git: Branch 'feature/fixes11' - sc/source

Michael Meeks michael.meeks at collabora.com
Mon Oct 26 04:46:32 PDT 2015


 sc/source/core/tool/interpr6.cxx |   75 +++++++++++++++++++++++++++------------
 1 file changed, 53 insertions(+), 22 deletions(-)

New commits:
commit 14635e66cd1e948d1c7ff4e90973fc62567cb801
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Sat Oct 24 22:56:39 2015 +0100

    Adapt FuncSum to vectorize better - potentially ...
    
    Change-Id: Ife1523538d4086b0072ca14c768358f4dd3396ab

diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index 694a403..50c0768a 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -203,6 +203,11 @@ double ScInterpreter::GetGammaDist( double fX, double fAlpha, double fLambda )
 
 namespace {
 
+// this is unpleasant - but ... we want raw access.
+struct puncture_mdds_encap : public sc::numeric_block {
+    const double *getPtr(size_t nOffset) const { return &m_array[nOffset]; }
+};
+
 class NumericCellAccumulator
 {
     double mfSum;
@@ -211,32 +216,58 @@ class NumericCellAccumulator
 public:
     NumericCellAccumulator() : mfSum(0.0), mnError(0) {}
 
-    void operator() (size_t, double fVal)
+    void operator() (const sc::CellStoreType::value_type& rNode, size_t nOffset, size_t nDataSize)
     {
-        mfSum += fVal;
-    }
+        switch (rNode.type)
+        {
+            case sc::element_type_numeric:
+            {
+                const puncture_mdds_encap *pBlock = static_cast<const puncture_mdds_encap *>(rNode.data);
+                const double *p = pBlock->getPtr(nOffset);
+                size_t i, nUnrolled = (nDataSize & 0x3) >> 2;
 
-    void operator() (size_t, const ScFormulaCell* pCell)
-    {
-        if (mnError)
-            // Skip all the rest if we have an error.
-            return;
+                // Try to encourage the compiler/CPU to do something sensible (?)
+                for (i = 0; i < nUnrolled; i+=4)
+                {
+                    mfSum += p[i];
+                    mfSum += p[i+1];
+                    mfSum += p[i+2];
+                    mfSum += p[i+3];
+                }
+                for (; i < nDataSize; ++i)
+                    mfSum += p[i];
+                break;
+            }
 
-        double fVal = 0.0;
-        sal_uInt16 nErr = 0;
-        ScFormulaCell& rCell = const_cast<ScFormulaCell&>(*pCell);
-        if (!rCell.GetErrorOrValue(nErr, fVal))
-            // The cell has neither error nor value.  Perhaps string result.
-            return;
+            case sc::element_type_formula:
+            {
+                sc::formula_block::const_iterator it = sc::formula_block::begin(*rNode.data);
+                std::advance(it, nOffset);
+                sc::formula_block::const_iterator itEnd = it;
+                std::advance(itEnd, nDataSize);
+                for (; it != itEnd; ++it)
+                {
+                    double fVal = 0.0;
+                    sal_uInt16 nErr = 0;
+                    ScFormulaCell& rCell = const_cast<ScFormulaCell&>(*(*it));
+                    if (!rCell.GetErrorOrValue(nErr, fVal))
+                        // The cell has neither error nor value.  Perhaps string result.
+                        continue;
 
-        if (nErr)
-        {
-            // Cell has error.
-            mnError = nErr;
-            return;
-        }
+                    if (nErr)
+                    {
+                        // Cell has error - skip all the rest
+                        mnError = nErr;
+                        return;
+                    }
 
-        mfSum += fVal;
+                    mfSum += fVal;
+                }
+            }
+            break;
+            default:
+                ;
+        }
     }
 
     sal_uInt16 getError() const { return mnError; }
@@ -335,7 +366,7 @@ public:
             return;
 
         NumericCellAccumulator aFunc;
-        maPos.miCellPos = sc::ParseFormulaNumeric(maPos.miCellPos, mpCol->GetCellStore(), nRow1, nRow2, aFunc);
+        maPos.miCellPos = sc::ParseBlock(maPos.miCellPos, mpCol->GetCellStore(), aFunc, nRow1, nRow2);
         mnError = aFunc.getError();
         if (mnError)
             return;


More information about the Libreoffice-commits mailing list