[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - 2 commits - sc/qa sc/source

I-Jui Sung (Ray) ray at multicorewareinc.com
Sun Nov 24 23:26:52 PST 2013


 sc/qa/unit/data/xls/opencl/math/sumproductTest.xls |binary
 sc/qa/unit/opencl-test.cxx                         |   26 ++++++++++
 sc/source/core/opencl/formulagroupcl.cxx           |   52 ++++++++++++++++++---
 3 files changed, 72 insertions(+), 6 deletions(-)

New commits:
commit cb699c576c91f7c1de98036a01c369402eee073e
Author: I-Jui (Ray) Sung <ray at multicorewareinc.com>
Date:   Mon Nov 25 01:10:04 2013 -0600

    GPU Calc: a test case for unrolling SumOfProduct
    
    AMLOEXT-245 BUG
    
    Change-Id: Ia8756af26c765820a04137a87f6681447dd18efd

diff --git a/sc/qa/unit/data/xls/opencl/math/sumproductTest.xls b/sc/qa/unit/data/xls/opencl/math/sumproductTest.xls
new file mode 100644
index 0000000..28eaebf
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/sumproductTest.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 6fabd98..f1ab881 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -244,6 +244,7 @@ public:
     void testStatisticalFormulaCovar();
     void testLogicalFormulaAnd();
     void testMathFormulaSumProduct();
+    void testMathFormulaSumProduct2();
     void testStatisticalParallelCountBug();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
@@ -418,6 +419,7 @@ public:
     CPPUNIT_TEST(testStatisticalFormulaCovar);
     CPPUNIT_TEST(testLogicalFormulaAnd);
     CPPUNIT_TEST(testMathFormulaSumProduct);
+    CPPUNIT_TEST(testMathFormulaSumProduct2);
     CPPUNIT_TEST(testStatisticalParallelCountBug);
     CPPUNIT_TEST_SUITE_END();
 
@@ -4792,6 +4794,30 @@ void ScOpenclTest::testMathFormulaSumProduct()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-245]
+void ScOpenclTest::testMathFormulaSumProduct2()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh = loadDoc("opencl/math/sumproductTest.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/math/sumproductTest.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    // Check the results of formula cells in the shared formula range.
+    for (SCROW i = 2; i <= 12; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(4,i,1));
+        double fExcel = pDocRes->GetValue(ScAddress(4,i,1));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel,  fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
+
 //[AMLOEXT-217]
 void ScOpenclTest:: testLogicalFormulaAnd()
 {
commit fecc3486633d9a83e5c1f501fbd8c2256d65cbf7
Author: I-Jui (Ray) Sung <ray at multicorewareinc.com>
Date:   Mon Nov 25 01:13:44 2013 -0600

    GPU Calc: fixed a SUMPRODUCT problem
    
    ALMOEXT-245
    
    Change-Id: Iedbbdc612232a939b2270e373313c872de831c20

diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index ad6ccc1..515fc89 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1107,10 +1107,30 @@ public:
             ss << "for(int outLoop=0; outLoop<" <<
             nCurWindowSize/outLoopSize<< "; outLoop++){\n\t";
             for(int count=0; count < outLoopSize; count++){
-                ss << "i = outLoop*"<<outLoopSize<<"+"<<count<<";\n\t";
+                ss << "i = outLoop*"<<outLoopSize<<"+"<<count<<";\n";
                 if(count==0){
-                    temp3 << "currentCount0 = i+gid0+1;\n\t";
-                    temp3 << "currentCount1 = i+1;\n\t";
+                    for (unsigned i = 0; i < vSubArguments.size(); i++)
+                    {
+                        tmpCur = vSubArguments[i]->GetFormulaToken();
+                        if(ocPush==tmpCur->GetOpCode())
+                        {
+                            pCurDVR= dynamic_cast<
+                                const formula::DoubleVectorRefToken *>(tmpCur);
+                            if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
+                            {
+                                temp3 << "        currentCount";
+                                temp3 << i;
+                                temp3 <<" =i+gid0+1;\n";
+                            }
+                            else
+                            {
+                                temp3 << "        currentCount";
+                                temp3 << i;
+                                temp3 << " =i+1;\n";
+                            }
+                        }
+                    }
+
                     temp3 << "tmp = fsum(";
                     for (unsigned i = 0; i < vSubArguments.size(); i++){
                         if (i)
@@ -1153,10 +1173,30 @@ public:
         for(unsigned int count=nCurWindowSize/outLoopSize*outLoopSize;
         count < nCurWindowSize; count++)
         {
-            ss << "i =" <<count<<";\n\t";
+            ss << "i =" <<count<<";\n";
             if(count==nCurWindowSize/outLoopSize*outLoopSize){
-                temp4 << "currentCount0 = i+gid0+1;\n\t";
-                temp4 << "currentCount1 = i+1;\n\t";
+                for (unsigned i = 0; i < vSubArguments.size(); i++)
+                {
+                    tmpCur = vSubArguments[i]->GetFormulaToken();
+                    if(ocPush==tmpCur->GetOpCode())
+                    {
+                        pCurDVR= dynamic_cast<
+                            const formula::DoubleVectorRefToken *>(tmpCur);
+                        if(!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
+                        {
+                            temp4 << "        currentCount";
+                            temp4 << i;
+                            temp4 <<" =i+gid0+1;\n";
+                        }
+                        else
+                        {
+                            temp4 << "        currentCount";
+                            temp4 << i;
+                            temp4 << " =i+1;\n";
+                        }
+                    }
+                }
+
                 temp4 << "tmp = fsum(";
                 for (unsigned i = 0; i < vSubArguments.size(); i++)
                 {


More information about the Libreoffice-commits mailing list