[Libreoffice-commits] core.git: 6 commits - sc/qa sc/source

Wei Wei weiwei at multicorewareinc.com
Wed Dec 18 23:13:11 PST 2013


 sc/qa/unit/data/xls/opencl/logical/not.xls |binary
 sc/qa/unit/data/xls/opencl/logical/xor.xls |binary
 sc/qa/unit/opencl-test.cxx                 |    5 
 sc/source/core/opencl/op_statistical.cxx   |  612 ++++++++++++++++-------------
 4 files changed, 357 insertions(+), 260 deletions(-)

New commits:
commit 3d0152ba5f551e23b3de5a32e0c45e9d73f482ed
Author: Wei Wei <weiwei at multicorewareinc.com>
Date:   Wed Dec 18 16:34:56 2013 -0600

    GPU Calc: remove the warning; shrink the test case
    
    number for XOR and NOT
    
    Change-Id: Ib184aa27a4bd4553886fb9422c937dac9c053a4e
    
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/qa/unit/data/xls/opencl/logical/not.xls b/sc/qa/unit/data/xls/opencl/logical/not.xls
index 651a8f9..7cd86a0 100644
Binary files a/sc/qa/unit/data/xls/opencl/logical/not.xls and b/sc/qa/unit/data/xls/opencl/logical/not.xls differ
diff --git a/sc/qa/unit/data/xls/opencl/logical/xor.xls b/sc/qa/unit/data/xls/opencl/logical/xor.xls
index fccba9b..7737727 100644
Binary files a/sc/qa/unit/data/xls/opencl/logical/xor.xls and b/sc/qa/unit/data/xls/opencl/logical/xor.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 9d28359..09c8a48 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -4942,7 +4942,7 @@ void ScOpenclTest:: testLogicalFormulaNot()
     ScDocShellRef xDocShRes = loadDoc("opencl/logical/not.", XLS);
     ScDocument *pDocRes = xDocShRes->GetDocument();
     CPPUNIT_ASSERT(pDocRes);
-    for (SCROW i = 0; i < 30000; ++i)
+    for (SCROW i = 0; i < 3000; ++i)
     {
         double fLibre = pDoc->GetValue(ScAddress(1, i, 0));
         double fExcel = pDocRes->GetValue(ScAddress(1, i, 0));
@@ -4964,7 +4964,7 @@ void ScOpenclTest:: testLogicalFormulaXor()
     ScDocShellRef xDocShRes = loadDoc("opencl/logical/xor.", XLS);
     ScDocument *pDocRes = xDocShRes->GetDocument();
     CPPUNIT_ASSERT(pDocRes);
-    for (SCROW i = 0; i < 30000; ++i)
+    for (SCROW i = 0; i < 3000; ++i)
     {
         double fLibre = pDoc->GetValue(ScAddress(1, i, 0));
         double fExcel = pDocRes->GetValue(ScAddress(1, i, 0));
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index 47c5ccf..c3b8a5d 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -3798,7 +3798,7 @@ void OpPearson::GenSlidingWindowFunction(
     ss <<"\n";
     for (i = 0; i < vSubArguments.size(); i++)
     {
-        FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+        pCur = vSubArguments[i]->GetFormulaToken();
         assert(pCur);
         if (pCur->GetType() == formula::svDoubleVectorRef)
         {
@@ -4066,7 +4066,7 @@ vSubArguments)
     ss << "    double tmp = 0;\n";
     for (unsigned i = 0; i < vSubArguments.size(); i++)
     {
-        FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+        pCur = vSubArguments[i]->GetFormulaToken();
         assert(pCur);
         if (pCur->GetType() == formula::svDoubleVectorRef)
         {
@@ -4334,13 +4334,13 @@ void OpRsq::GenSlidingWindowFunction(
     ss <<"\n";
     for (i = 0; i < vSubArguments.size(); i++)
     {
-        FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+        pCur = vSubArguments[i]->GetFormulaToken();
         assert(pCur);
         if (pCur->GetType() == formula::svDoubleVectorRef)
         {
             const formula::DoubleVectorRefToken* pDVR =
             dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
-            size_t nCurWindowSize = pDVR->GetRefRowSize();
+            nCurWindowSize = pDVR->GetRefRowSize();
             ss << "for (int i = ";
             if (!pDVR->IsStartFixed() && pDVR->IsEndFixed()) {
 #ifdef  ISNAN
@@ -5354,13 +5354,13 @@ void OpKurt:: GenSlidingWindowFunction(std::stringstream &ss,
         ss << "    double tmp = 0;\n";
         for (unsigned i = 0; i < vSubArguments.size(); i++)
         {
-            FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+            pCur = vSubArguments[i]->GetFormulaToken();
             assert(pCur);
             if (pCur->GetType() == formula::svDoubleVectorRef)
             {
                 const formula::DoubleVectorRefToken* pDVR =
                 dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
-                size_t nCurWindowSize = pDVR->GetRefRowSize();
+                nCurWindowSize = pDVR->GetRefRowSize();
                 ss << "    for (int i = 0; i <" << nCurWindowSize;
                 ss << "; i++)\n";
                 ss << "    {\n";
commit ef25611384dc4fe872a6b31806fea668f9ab645d
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date:   Tue Dec 10 10:50:49 2013 +0800

    GPU Calc: Optimized NORMDIST
    
    AMLOEXT-284
    
    Change-Id: I5028ebbee91d6c7a64e9993b97b5f942f039d92c
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index d818062..47c5ccf 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -4600,70 +4600,56 @@ void OpNormdist::GenSlidingWindowFunction(
     ss << "{\n";
     ss << "    double x,mue,sigma,c;\n";
     ss << "    int gid0=get_global_id(0);\n";
-#ifdef ISNAN
-    FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
-    const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
-    formula::SingleVectorRefToken *>(tmpCur0);
-    FormulaToken *tmpCur1 = vSubArguments[1]->GetFormulaToken();
-    const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const
-    formula::SingleVectorRefToken *>(tmpCur1);
-    FormulaToken *tmpCur2 = vSubArguments[2]->GetFormulaToken();
-    const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const
-    formula::SingleVectorRefToken *>(tmpCur2);
-    FormulaToken *tmpCur3 = vSubArguments[3]->GetFormulaToken();
-    const formula::SingleVectorRefToken*tmpCurDVR3= dynamic_cast<const
-    formula::SingleVectorRefToken *>(tmpCur3);
-    ss << "    int buffer_x_len = ";
-    ss << tmpCurDVR0->GetArrayLength();
-    ss << ";\n";
-    ss << "    int buffer_mue_len = ";
-    ss << tmpCurDVR1->GetArrayLength();
-    ss << ";\n";
-    ss << "    int buffer_sigma_len = ";
-    ss << tmpCurDVR2->GetArrayLength();
-    ss << ";\n";
-    ss << "    int buffer_c_len = ";
-    ss << tmpCurDVR3->GetArrayLength();
-    ss << ";\n";
-#endif
-#ifdef ISNAN
-    ss <<"if((gid0)>=buffer_c_len || isNan(";
-    ss << vSubArguments[3]->GenSlidingWindowDeclRef();
-    ss <<"))\n";
-    ss <<"        c = 0;\nelse \n";
-#endif
-    ss << "    c = "<<vSubArguments[3]->GenSlidingWindowDeclRef();
-    ss << ";\n";
-#ifdef ISNAN
-    ss <<"if((gid0)>=buffer_sigma_len || isNan(";
-    ss << vSubArguments[2]->GenSlidingWindowDeclRef();
-    ss <<"))\n";
-    ss <<"        sigma = 0;\nelse \n";
+    ss << "    double tmp0,tmp1,tmp2,tmp3;\n";
+    size_t i = vSubArguments.size();
+    ss <<"\n    ";
+    for (i = 0; i < vSubArguments.size(); i++)
+    {
+        FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+        assert(pCur);
+        if (pCur->GetType() == formula::svSingleVectorRef)
+        {
+#ifdef  ISNAN
+                const formula::SingleVectorRefToken* pSVR =
+                dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+            ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n";
 #endif
-    ss <<"        sigma = "<<vSubArguments[2]->GenSlidingWindowDeclRef();
-    ss <<";\n";
-#ifdef ISNAN
-    ss <<"    if((gid0)>=buffer_mue_len || isNan(";
-    ss << vSubArguments[1]->GenSlidingWindowDeclRef();
-    ss <<"))\n";
-    ss <<"        mue = 0;\nelse \n";
+        }
+        else if (pCur->GetType() == formula::svDouble)
+        {
+#ifdef  ISNAN
+            ss << "{\n";
 #endif
-    ss <<"        mue = "<<vSubArguments[1]->GenSlidingWindowDeclRef();
-    ss <<";\n";
-#ifdef ISNAN
-    ss<<"    if((gid0)>=buffer_x_len || isNan(";
-    ss << vSubArguments[0]->GenSlidingWindowDeclRef();
-    ss<<"))\n";
-    ss<<"    x = 0;\nelse \n";
+        }
+#ifdef  ISNAN
+        if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
+        {
+            ss << "    if (isNan(";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << "))\n";
+            ss << "        tmp"<<i<<"= 0;\n";
+            ss << "    else\n";
+            ss << "        tmp"<<i<<"=\n";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << ";\n}\n";
+        }
+        else
+        {
+            ss << "tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss <<";\n";
+        }
 #endif
-    ss <<"   x = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
-    ss << ";\n";
+    }
+    ss << "x = tmp0;\n";
+    ss << "mue = tmp1;\n";
+    ss << "sigma = tmp2;\n";
+    ss << "c = tmp3;\n";
     ss << "double mid,tmp;\n";
     ss << "mid = (x - mue)/sigma;\n";
     ss << "if(c)\n";
     ss << "    tmp = 0.5 *erfc(-mid * 0.7071067811865475);\n";
     ss << "else \n";
-    ss <<"     tmp=(0.39894228040143268*exp(-(mid * mid)/2.0))/sigma;\n";
+    ss <<"     tmp=(0.39894228040143268*exp(-pow(mid,2)/2.0))/sigma;\n";
     ss << "return tmp;\n";
     ss << "}\n";
 }
commit d5dac04897ca6953c72f7d4563c7f7ffd9c962c4
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date:   Tue Dec 10 10:53:41 2013 +0800

    GPU Calc: Optimized NORMINV
    
    AMLOEXT-285
    
    Change-Id: I362d51a2e1dd750dfbafc7a8830c4a8b7611daed
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index 4af1fd3..d818062 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -4868,58 +4868,59 @@ void OpNorminv::GenSlidingWindowFunction(
     ss << "{\n";
     ss <<"    double q,t,z;\n";
     ss <<"    double x,mue,sigma;\n";
+    ss <<"    double tmp0,tmp1,tmp2;\n";
     ss <<"    int gid0=get_global_id(0);\n";
-#ifdef ISNAN
-    FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
-    const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
-    formula::SingleVectorRefToken *>(tmpCur0);
-    FormulaToken *tmpCur1 = vSubArguments[1]->GetFormulaToken();
-    const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const
-    formula::SingleVectorRefToken *>(tmpCur1);
-    FormulaToken *tmpCur2 = vSubArguments[2]->GetFormulaToken();
-    const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const
-    formula::SingleVectorRefToken *>(tmpCur2);
-    ss << "    int buffer_x_len = ";
-    ss << tmpCurDVR0->GetArrayLength();
-    ss << ";\n";
-    ss << "    int buffer_mue_len = ";
-    ss << tmpCurDVR1->GetArrayLength();
-    ss << ";\n";
-    ss << "    int buffer_sigma_len = ";
-    ss << tmpCurDVR2->GetArrayLength();
-    ss << ";\n";
+    size_t i = vSubArguments.size();
+    ss <<"\n";
+    for (i = 0; i < vSubArguments.size(); i++)
+    {
+        FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+        assert(pCur);
+        if (pCur->GetType() == formula::svSingleVectorRef)
+        {
+#ifdef  ISNAN
+                const formula::SingleVectorRefToken* pSVR =
+                dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+            ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n";
 #endif
-#ifdef ISNAN
-    ss <<"    if((gid0)>=buffer_x_len || isNan(";
-    ss << vSubArguments[0]->GenSlidingWindowDeclRef();
-    ss <<"))\n";
-    ss <<"        x = 0;\n";
-    ss <<"    else \n";
+        }
+        else if (pCur->GetType() == formula::svDouble)
+        {
+#ifdef  ISNAN
+            ss << "{\n";
 #endif
-    ss <<"         x ="<<vSubArguments[0]->GenSlidingWindowDeclRef();
-    ss << ";\n";
-#ifdef ISNAN
-    ss <<"    if((gid0)>=buffer_mue_len || isNan(";
-    ss << vSubArguments[1]->GenSlidingWindowDeclRef();
-    ss <<"))\n";
-    ss <<"        mue = 0;\n";
-    ss <<"    else \n";
+        }
+        else
+        {
+#ifdef  ISNAN
 #endif
-    ss <<"        mue ="<<vSubArguments[1]->GenSlidingWindowDeclRef();
-    ss << ";\n";
-#ifdef ISNAN
-    ss <<"    if((gid0)>=buffer_sigma_len || isNan(";
-    ss << vSubArguments[2]->GenSlidingWindowDeclRef();
-    ss <<"))\n";
-    ss <<"    sigma = 0;\n";
-    ss <<"else \n";
+        }
+#ifdef  ISNAN
+        if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
+        {
+            ss << "    if (isNan(";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << "))\n";
+            ss << "        tmp"<<i<<"= 0;\n";
+            ss << "    else\n";
+            ss << "        tmp"<<i<<"=\n";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << ";\n}\n";
+        }
+        else
+        {
+            ss << "tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss <<";\n";
+        }
 #endif
-    ss <<"     sigma ="<<vSubArguments[2]->GenSlidingWindowDeclRef();
-    ss << ";\n";
+    }
+    ss <<"    x = tmp0;\n";
+    ss <<"    mue = tmp1;\n";
+    ss <<"    sigma = tmp2;\n";
     ss <<"    q = x -0.5;\n";
     ss <<"    if(fabs(q)<=.425)\n";
     ss <<"   {\n";
-    ss <<"        t=0.180625-q*q;\n";
+    ss <<"        t=0.180625-pow(q,2);\n";
     ss <<"        z=\n"
     "q*\n"
     "(\n"
@@ -5068,7 +5069,7 @@ void OpNorminv::GenSlidingWindowFunction(
                 "*t+1.0\n"
             ");\n";
     ss<<"}\n";
-    ss<<"if(q<0.0) z=-z;\n";
+    ss << "z = q < 0.0 ? (-1)*z : z;\n";
     ss<<"}\n";
     ss<<"double tmp =  z*sigma + mue;\n";
     ss<<"return tmp;\n";
commit 19013b913249c035e8519a46b9634b675e2026f1
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date:   Fri Dec 6 10:27:39 2013 +0800

    GPU Calc: Optimized NEGBINOMDIST
    
    AMLOEXT-282
    
    Change-Id: Ie6dcd77fc11b91647722b5a9a73deb0d6a97989c
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 7796b57..9d28359 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -1494,7 +1494,6 @@ void ScOpenclTest::testStatisticalFormulaNegbinomdist()
     {
         double fLibre = pDoc->GetValue(ScAddress(3,i,0));
         double fExcel = pDocRes->GetValue(ScAddress(3,i,0));
-        std::cout<<fLibre<<"\t"<<fExcel<<"\n";
         CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
     }
     xDocSh->DoClose();
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index 1769056..4af1fd3 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -3708,64 +3708,63 @@ void OpNegbinomdist::GenSlidingWindowFunction(
     }
     ss << ")\n";
     ss << "{\n\t";
-    ss << "double f,s,p;\n\t";
-    ss << " int gid0=get_global_id(0);\n\t";
-#ifdef ISNAN
-    FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
-    const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
-    formula::SingleVectorRefToken *>(tmpCur0);
-
-    FormulaToken *tmpCur1 = vSubArguments[1]->GetFormulaToken();
-    const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const
-    formula::SingleVectorRefToken *>(tmpCur1);
-
-    FormulaToken *tmpCur2 = vSubArguments[2]->GetFormulaToken();
-    const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const
-    formula::SingleVectorRefToken *>(tmpCur2);
-    ss<< "int buffer_f_len = ";
-    ss<< tmpCurDVR0->GetArrayLength();
-    ss << ";\n\t";
-
-    ss<< "int buffer_s_len = ";
-    ss<< tmpCurDVR1->GetArrayLength();
-    ss << ";\n\t";
-
-    ss<< "int buffer_p_len = ";
-    ss<< tmpCurDVR2->GetArrayLength();
-    ss << ";\n\t";
+    ss << "double f,s,p,tmp0,tmp1,tmp2;\n";
+    ss << " int gid0=get_global_id(0);\n";
+    size_t i = vSubArguments.size();
+    ss <<"\n";
+    for (i = 0; i < vSubArguments.size(); i++)
+    {
+        FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+        assert(pCur);
+        if (pCur->GetType() == formula::svSingleVectorRef)
+        {
+#ifdef  ISNAN
+                const formula::SingleVectorRefToken* pSVR =
+                dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+            ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n";
 #endif
-#ifdef ISNAN
-    ss<<"if((gid0)>=buffer_p_len || isNan(";
-    ss << vSubArguments[2]->GenSlidingWindowDeclRef();
-    ss<<"))\n\t\t";
-    ss<<"p = 0;\n\telse \n\t\t";
+        }
+        else if (pCur->GetType() == formula::svDouble)
+        {
+#ifdef  ISNAN
+            ss << "{\n";
 #endif
-    ss << "  p = "<<vSubArguments[2]->GenSlidingWindowDeclRef();
-    ss << " ;\n\t";
-#ifdef ISNAN
-    ss<<"if((gid0)>=buffer_s_len || isNan(";
-    ss << vSubArguments[1]->GenSlidingWindowDeclRef();
-    ss<<"))\n\t\t";
-    ss<<"s = 0;\n\telse \n\t\t";
+        }
+        else
+        {
+#ifdef  ISNAN
 #endif
-    ss << "  s = "<<vSubArguments[1]->GenSlidingWindowDeclRef();
-    ss << " ;\n\t";
-#ifdef ISNAN
-    ss<<"if((gid0)>=buffer_f_len || isNan(";
-    ss << vSubArguments[0]->GenSlidingWindowDeclRef();
-    ss<<"))\n\t\t";
-    ss<<"f = 0;\n\telse \n\t\t";
+        }
+#ifdef  ISNAN
+        if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
+        {
+            ss << "    if (isNan(";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << "))\n";
+            ss << "        tmp"<<i<<"= 0;\n";
+            ss << "    else\n";
+            ss << "        tmp"<<i<<"=\n";
+            ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss << ";\n}\n";
+        }
+        else
+        {
+            ss << "tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+            ss <<";\n";
+        }
 #endif
-    ss << "  f = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
-    ss << " ;\n\t";
+    }
+    ss << " p = tmp2;\n";
+    ss << " s = tmp1;\n";
+    ss << " f = tmp0;\n";
     ss << " double q = 1.0 - p;\n\t";
     ss << " double fFactor = pow(p,s);\n\t";
     ss << " for(int i=0; i<f; i++)\n\t";
     ss << " {\n\t";
-    ss << "   fFactor *= ((double)i+s)/((double)i+1.0)*q;\n\t";
+    ss << "  fFactor *= ((double)i+s)*pow(((double)i+1.0),-1.0)/pow(q,-1);\n";
     ss << " }\n\t";
-    ss << " double tmp=fFactor;\n\t";
-    ss << " return tmp;\n";
+    ss << " double temp=fFactor;\n\t";
+    ss << " return temp;\n";
     ss << "}\n";
 }
 
commit 7e8aedcd8e0d683aaf891d6373d4cf5f33ddbe39
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date:   Fri Dec 6 10:40:15 2013 +0800

    GPU Calc: Optimized PEARSON
    
    AMLOEXT-281
    
    Change-Id: I98d17f007a77aedff3778b251b6cfd399d34464c
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index 4d657fc..1769056 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -3787,16 +3787,72 @@ void OpPearson::GenSlidingWindowFunction(
         vSubArguments[i]->GenSlidingWindowDecl(ss);
     }
     ss << ")\n";
-    ss << "{\n\t";
-    ss << "int gid0=get_global_id(0);\n\t";
-    ss << "double fCount = 0.0;\n\t";
-    ss << "double fSumX = 0.0;\n\t";
-    ss << "double fSumY = 0.0;\n\t";
-    ss << "double fSumDeltaXDeltaY = 0.0;\n\t";
-    ss << "double fSumSqrDeltaX    = 0.0;\n\t";
-    ss << "double fSumSqrDeltaY    = 0.0;\n\t";
-    ss << "double fInx;\n\t";
-    ss << "double fIny;\n\t";
+    ss << "{\n";
+    ss << "    int gid0=get_global_id(0);\n";
+    ss << "    double fCount = 0.0;\n";
+    ss << "    double fSumX = 0.0;\n";
+    ss << "    double fSumY = 0.0;\n";
+    ss << "    double fSumDeltaXDeltaY = 0.0;\n";
+    ss << "    double fInx;\n";
+    ss << "    double fIny;\n";
+    size_t i = vSubArguments.size();
+    ss <<"\n";
+    for (i = 0; i < vSubArguments.size(); i++)
+    {
+        FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+        assert(pCur);
+        if (pCur->GetType() == formula::svDoubleVectorRef)
+        {
+            const formula::DoubleVectorRefToken* pDVR =
+            dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+            size_t nCurWindowSize = pDVR->GetRefRowSize();
+            ss << "for (int i = ";
+            if (!pDVR->IsStartFixed() && pDVR->IsEndFixed()) {
+#ifdef  ISNAN
+                ss << "gid0; i < " << pDVR->GetArrayLength();
+                ss << " && i < " << nCurWindowSize  << "; i++){\n";
+#else
+                ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+            } else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed()) {
+#ifdef  ISNAN
+                ss << "0; i < " << pDVR->GetArrayLength();
+                ss << " && i < gid0+"<< nCurWindowSize << "; i++){\n";
+#else
+                ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
+#endif
+            } else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed()){
+#ifdef  ISNAN
+                ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+                ss << " &&  i < "<< nCurWindowSize << "; i++){\n";
+#else
+                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+            }
+            else {
+#ifdef  ISNAN
+                ss << "0; i < "<< nCurWindowSize << "; i++){\n";
+#else
+                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+            }
+        }
+        else if (pCur->GetType() == formula::svSingleVectorRef)
+        {
+#ifdef  ISNAN
+                const formula::SingleVectorRefToken* pSVR =
+                dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+            ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n";
+#endif
+        }
+        else if (pCur->GetType() == formula::svDouble)
+        {
+#ifdef  ISNAN
+            ss << "{\n";
+#endif
+        }
+    ss << "\n}\n";
+    }
 #ifdef ISNAN
     FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
     const formula::DoubleVectorRefToken*tmpCurDVR0= dynamic_cast<const
@@ -3806,55 +3862,55 @@ void OpPearson::GenSlidingWindowFunction(
     const formula::DoubleVectorRefToken*tmpCurDVR1= dynamic_cast<const
     formula::DoubleVectorRefToken *>(tmpCur1);
 
-    ss<< "int buffer_fInx_len = ";
-    ss<< tmpCurDVR0->GetArrayLength();
-    ss << ";\n\t";
+    ss << "    int buffer_fInx_len = ";
+    ss << tmpCurDVR0->GetArrayLength();
+    ss << ";\n";
 
-    ss<< "int buffer_fIny_len = ";
-    ss<< tmpCurDVR1->GetArrayLength();
-    ss << ";\n\t";
+    ss << "    int buffer_fIny_len = ";
+    ss << tmpCurDVR1->GetArrayLength();
+    ss << ";\n";
 #endif
-    ss << "for(int i=0; i<"<<CurWindowSize<<"; i++)\n\t";
-    ss << "{\n\t";
+    ss << "    for(int i=0; i<"<<CurWindowSize<<"; i++)\n";
+    ss << "    {\n";
 #ifdef ISNAN
-    ss<<"if((gid0+i)>=buffer_fInx_len || isNan(";
+    ss <<"        if((gid0+i)>=buffer_fInx_len || isNan(";
     ss << vSubArguments[0]->GenSlidingWindowDeclRef();
-    ss<<"))\n\t\t";
-    ss<<"fInx = 0;\n\telse \n\t";
+    ss <<"))\n";
+    ss <<"            fInx = 0;\n";
+    ss <<"        else\n";
 #endif
-    ss << "  fInx = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
-    ss << "  ;\n\t";
+    ss << "          fInx = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss << ";\n";
 #ifdef ISNAN
-    ss<<"if((gid0+i)>=buffer_fIny_len || isNan(";
+    ss <<"        if((gid0+i)>=buffer_fIny_len || isNan(";
     ss << vSubArguments[1]->GenSlidingWindowDeclRef();
-    ss<<"))\n\t\t";
-    ss<<"fIny = 0;\n\telse \n\t";
-#endif
-    ss << "  fIny = "<<vSubArguments[1]->GenSlidingWindowDeclRef();
-    ss << "  ;\n\t";
-    ss << "  double fValX = fInx;\n\t";
-    ss << "  double fValY = fIny;\n\t";
-    ss << "  fSumX += fValX;\n\t";
-    ss << "  fSumY += fValY;\n\t";
-    ss << "  fCount = fCount + 1;\n\t";
-    ss << "}\n\t";
-    ss << "const double fMeanX = fSumX / fCount;\n\t";
-    ss << "const double fMeanY = fSumY / fCount;\n\t";
-    ss << "for(int i=0; i<"<<CurWindowSize<<"; i++)\n\t";
-    ss << "{\n\t";
-    ss << "  fInx = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
-    ss << " ;\n\t";
-    ss << "  fIny = "<<vSubArguments[1]->GenSlidingWindowDeclRef();
-    ss << " ;\n\t";
-    ss << "  const double fValX = fInx;\n\t";
-    ss << "  const double fValY = fIny;\n\t";
-    ss << "  fSumDeltaXDeltaY += (fValX - fMeanX) * (fValY - fMeanY);\n\t";
-    ss << "  fSumSqrDeltaX    += (fValX - fMeanX) * (fValX - fMeanX);\n\t";
-    ss << "  fSumSqrDeltaY    += (fValY - fMeanY) * (fValY - fMeanY);\n\t";
-    ss << "}\n\t";
-    ss << "double tmp = ( fSumDeltaXDeltaY / ";
-    ss << "sqrt( fSumSqrDeltaX * fSumSqrDeltaY));\n\t";
-    ss << "return tmp;\n";
+    ss <<"))\n";
+    ss <<"            fIny = 0;\n";
+    ss <<"        else\n";
+#endif
+    ss << "          fIny = "<<vSubArguments[1]->GenSlidingWindowDeclRef();
+    ss << "  ;\n";
+    ss << "       fSumX += fInx;\n";
+    ss << "       fSumY += fIny;\n";
+    ss << "       fCount = fCount + 1;\n";
+    ss << "     }\n";
+    ss << "       double fMeanX = fSumX / fCount;\n";
+    ss << "       double fMeanY = fSumY / fCount;\n";
+    ss << "       fSumX = 0.0;\n";
+    ss << "       fSumY = 0.0;\n";
+    ss << "       for(int i=0; i<"<<CurWindowSize<<"; i++)\n";
+    ss << "       {\n";
+    ss << "           fInx = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss << " ;\n";
+    ss << "           fIny = "<<vSubArguments[1]->GenSlidingWindowDeclRef();
+    ss << " ;\n";
+    ss << "           fSumDeltaXDeltaY += (fInx - fMeanX) * (fIny - fMeanY);\n";
+    ss << "           fSumX += pow(fInx - fMeanX,2);\n";
+    ss << "           fSumY += pow(fIny - fMeanY,2);\n";
+    ss << "       }\n";
+    ss << "      double tmp = ( fSumDeltaXDeltaY / ";
+    ss << "sqrt( fSumX * fSumY));\n\t";
+    ss << "      return tmp;\n";
     ss << "}\n";
 }
 
commit 3005ed48f14e4712e7d9d2fa6db859a6ebe8a781
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date:   Fri Dec 6 10:44:03 2013 +0800

    GPU Calc: Optimized RSQ
    
    AMLOEXT-280
    
    Change-Id: I92bc0daeb74e7322479e4f8e57b816b7de45b1b0
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: Wei Wei <weiwei at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index edf2910..4d657fc 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -4266,16 +4266,73 @@ void OpRsq::GenSlidingWindowFunction(
         vSubArguments[i]->GenSlidingWindowDecl(ss);
     }
     ss << ")\n";
-    ss << "{\n\t";
-    ss << "int gid0=get_global_id(0);\n\t";
-    ss << "double fCount = 0.0;\n\t";
-    ss << "double fSumX = 0.0;\n\t";
-    ss << "double fSumY = 0.0;\n\t";
-    ss << "double fSumDeltaXDeltaY = 0.0;\n\t";
-    ss << "double fSumSqrDeltaX    = 0.0;\n\t";
-    ss << "double fSumSqrDeltaY    = 0.0;\n\t";
-    ss << "double fInx;\n\t";
-    ss << "double fIny;\n\t";
+    ss << "{\n";
+    ss << "    int gid0=get_global_id(0);\n";
+    ss << "    double fCount = 0.0;\n";
+    ss << "    double fSumX = 0.0;\n";
+    ss << "    double fSumY = 0.0;\n";
+    ss << "    double fSumDeltaXDeltaY = 0.0;\n";
+    ss << "    double fInx;\n";
+    ss << "    double fIny;\n";
+    ss << "    double tmp0,tmp1;\n";
+    size_t i = vSubArguments.size();
+    ss <<"\n";
+    for (i = 0; i < vSubArguments.size(); i++)
+    {
+        FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+        assert(pCur);
+        if (pCur->GetType() == formula::svDoubleVectorRef)
+        {
+            const formula::DoubleVectorRefToken* pDVR =
+            dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+            size_t nCurWindowSize = pDVR->GetRefRowSize();
+            ss << "for (int i = ";
+            if (!pDVR->IsStartFixed() && pDVR->IsEndFixed()) {
+#ifdef  ISNAN
+                ss << "gid0; i < " << pDVR->GetArrayLength();
+                ss << " && i < " << nCurWindowSize  << "; i++){\n";
+#else
+                ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+            } else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed()) {
+#ifdef  ISNAN
+                ss << "0; i < " << pDVR->GetArrayLength();
+                ss << " && i < gid0+"<< nCurWindowSize << "; i++){\n";
+#else
+                ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
+#endif
+            } else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed()){
+#ifdef  ISNAN
+                ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+                ss << " &&  i < "<< nCurWindowSize << "; i++){\n";
+#else
+                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+            }
+            else {
+#ifdef  ISNAN
+                ss << "0; i < "<< nCurWindowSize << "; i++){\n";
+#else
+                ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+            }
+        }
+        else if (pCur->GetType() == formula::svSingleVectorRef)
+        {
+#ifdef  ISNAN
+                const formula::SingleVectorRefToken* pSVR =
+                dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+            ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n";
+#endif
+        }
+        else if (pCur->GetType() == formula::svDouble)
+        {
+#ifdef  ISNAN
+            ss << "{\n";
+#endif
+        }
+    ss << "\n}\n";
+    }
 #ifdef ISNAN
     FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
     const formula::DoubleVectorRefToken*tmpCurDVR0= dynamic_cast<const
@@ -4283,54 +4340,53 @@ void OpRsq::GenSlidingWindowFunction(
     FormulaToken *tmpCur1 = vSubArguments[1]->GetFormulaToken();
     const formula::DoubleVectorRefToken*tmpCurDVR1= dynamic_cast<const
     formula::DoubleVectorRefToken *>(tmpCur1);
-    ss<< "int buffer_fInx_len = ";
-    ss<< tmpCurDVR0->GetArrayLength();
-    ss << ";\n\t";
-
-    ss<< "int buffer_fIny_len = ";
-    ss<< tmpCurDVR1->GetArrayLength();
-    ss << ";\n\t";
+    ss << "    int buffer_fInx_len = ";
+    ss << tmpCurDVR0->GetArrayLength();
+    ss << ";\n";
+    ss << "    int buffer_fIny_len = ";
+    ss << tmpCurDVR1->GetArrayLength();
+    ss << ";\n";
 #endif
-    ss << "for(int i=0; i<"<<nCurWindowSize<<"; i++)\n\t";
-    ss << "{\n\t";
+    ss << "   for(int i=0; i<"<<nCurWindowSize<<"; i++)\n";
+    ss << "   {\n";
 #ifdef ISNAN
-    ss<<"if((gid0+i)>=buffer_fInx_len || isNan(";
+    ss << "     if((gid0+i)>=buffer_fInx_len || isNan(";
     ss << vSubArguments[0]->GenSlidingWindowDeclRef();
-    ss<<"))\n\t\t";
-    ss<<"fInx = 0;\n\telse \n\t";
+    ss << "))\n";
+    ss << "         fInx = 0;\n";
+    ss << "     else\n";
 #endif
-    ss << "  fInx = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
-    ss << "  ;\n\t";
+    ss << "        fInx = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss << ";\n";
 #ifdef ISNAN
-    ss<<"if((gid0+i)>=buffer_fIny_len || isNan(";
+    ss << "      if((gid0+i)>=buffer_fIny_len || isNan(";
     ss << vSubArguments[1]->GenSlidingWindowDeclRef();
-    ss<<"))\n\t\t";
-    ss<<"fIny = 0;\n\telse \n\t";
-#endif
-    ss << "  fIny = "<<vSubArguments[1]->GenSlidingWindowDeclRef();
-    ss << "  ;\n\t";
-    ss << "  double fValX = fInx;\n\t";
-    ss << "  double fValY = fIny;\n\t";
-    ss << "  fSumX += fValX;\n\t";
-    ss << "  fSumY += fValY;\n\t";
-    ss << "  fCount = fCount + 1;\n\t";
-    ss << "}\n\t";
-    ss << "const double fMeanX = fSumX / fCount;\n\t";
-    ss << "const double fMeanY = fSumY / fCount;\n\t";
-    ss << "for(int i=0; i<"<<nCurWindowSize<<"; i++)\n\t";
-    ss << "{\n\t";
-    ss << "  fInx = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
-    ss << " ;\n\t";
-    ss << "  fIny = "<<vSubArguments[1]->GenSlidingWindowDeclRef();
-    ss << " ;\n\t";
-    ss << "  const double fValX = fInx;\n\t";
-    ss << "  const double fValY = fIny;\n\t";
-    ss << "  fSumDeltaXDeltaY += (fValX - fMeanX) * (fValY - fMeanY);\n\t";
-    ss << "  fSumSqrDeltaX    += (fValX - fMeanX) * (fValX - fMeanX);\n\t";
-    ss << "  fSumSqrDeltaY    += (fValY - fMeanY) * (fValY - fMeanY);\n\t";
-    ss << "}\n\t";
-    ss << "double tmp = ( fSumDeltaXDeltaY / sqrt( fSumSqrDeltaX * fSumSqrDeltaY));\n\t";
-    ss << "return (tmp * tmp);\n";
+    ss << "))\n";
+    ss << "          fIny = 0;\n";
+    ss << "      else\n";
+#endif
+    ss << "        fIny = "<<vSubArguments[1]->GenSlidingWindowDeclRef();
+    ss << " ;\n";
+    ss << "      fSumX += fInx;\n";
+    ss << "      fSumY += fIny;\n";
+    ss << "      fCount = fCount + 1;\n";
+    ss << "    }\n";
+    ss << "    double fMeanX = fSumX / fCount;\n";
+    ss << "    double fMeanY = fSumY / fCount;\n";
+    ss << "    fSumX = 0.0;\n";
+    ss << "    fSumY = 0.0;\n";
+    ss << "    for(int i=0; i<"<<nCurWindowSize<<"; i++)\n";
+    ss << "    {\n";
+    ss << "        fInx = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss << " ;\n";
+    ss << "        fIny = "<<vSubArguments[1]->GenSlidingWindowDeclRef();
+    ss << " ;\n";
+    ss << "        fSumDeltaXDeltaY += (fInx - fMeanX) * (fIny - fMeanY);\n";
+    ss << "        fSumX    += pow(fInx - fMeanX,2);\n";
+    ss << "        fSumY    += pow(fIny - fMeanY,2);\n";
+    ss << "    }\n";
+    ss << "    double tmp = pow( fSumDeltaXDeltaY,2) / (fSumX * fSumY);\n";
+    ss << "    return tmp ;\n";
     ss << "}\n";
 }
 


More information about the Libreoffice-commits mailing list