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

yangzhang yangzhang at multicorewareinc.com
Tue Nov 5 20:32:22 CET 2013


 sc/qa/unit/data/ods/opencl/math/Abs.ods  |binary
 sc/qa/unit/opencl-test.cxx               |   28 +++++++++++++++++++++++++++
 sc/source/core/opencl/formulagroupcl.cxx |    5 ++++
 sc/source/core/opencl/op_math.cxx        |   32 +++++++++++++++++++++++++++++++
 sc/source/core/opencl/op_math.hxx        |    8 +++++++
 sc/source/core/tool/token.cxx            |    1 
 6 files changed, 74 insertions(+)

New commits:
commit 01f6f620395a86abe1e7f503ae4b3b5f7124e144
Author: yangzhang <yangzhang at multicorewareinc.com>
Date:   Mon Nov 4 15:36:56 2013 +0800

    GPU Calc: implement fix for ABS
    
    AMLOEXT-47 FIX
    
    Change-Id: I438ad01d717dbc34ea8bc45e8f6de4f7d0c2bf2c
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index f0fd68b..d3ad8bc 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1023,6 +1023,11 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
             case ocSinHyp:
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i],new OpSinh));
+                break;
+            case ocAbs:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i], new OpAbs));
+                break;
             case ocExternal:
                 if ( !(pChild->GetExternal().compareTo(OUString(
                     "com.sun.star.sheet.addin.Analysis.getEffect"))))
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 32d2eb5..b3afda2 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -110,6 +110,38 @@ void OpSinh::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "}";
 }
 
+void OpAbs::GenSlidingWindowFunction(std::stringstream &ss,
+    const std::string sSymName, SubArguments &vSubArguments)
+{
+    ss << "\ndouble " << sSymName;
+    ss << "_"<< BinFuncName() <<"(";
+    for (unsigned i = 0; i < vSubArguments.size(); i++)
+    {
+        if (i)
+            ss << ",";
+        vSubArguments[i]->GenSlidingWindowDecl(ss);
+    }
+    ss << ") {\n";
+    ss << "    int gid0   = get_global_id(0);\n";
+    ss << "    double tmp = " << GetBottom() << ";\n";
+#ifdef ISNAN
+    FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
+    const formula::SingleVectorRefToken*tmpCurDVR0=
+        dynamic_cast<const formula::SingleVectorRefToken *>(tmpCur0);
+    ss << "    int buffer_len = ";
+    ss << tmpCurDVR0->GetArrayLength();
+    ss << ";\n";
+    ss << "    if((gid0)>=buffer_len || isNan(";
+    ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss << "))\n";
+    ss << "        tmp = " << GetBottom() << ";\n    else \n";
+#endif
+    ss << "        tmp = ";
+    ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss << ";\n";
+    ss << "    return fabs(tmp);\n";
+    ss << "}";
+}
 
 }}
 
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index 7399a6a..1e59c41 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -38,6 +38,14 @@ public:
             const std::string sSymName, SubArguments &vSubArguments);
     virtual std::string BinFuncName(void) const { return "Sinh"; }
 };
+
+class OpAbs:public Normal{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+    virtual std::string GetBottom(void) { return "0.0"; }
+    virtual std::string BinFuncName(void) const { return "ScAbs"; }
+};
 }}
 
 #endif
commit 73cde39d6314fcc426165d1fea204f78de847ffb
Author: yangzhang <yangzhang at multicorewareinc.com>
Date:   Mon Nov 4 14:58:13 2013 +0800

    GPU Calc: unit test cases for ABS
    
    Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-47 BUG
    
    Change-Id: Ie33b4e5fad47f58a33ecdb0405521e7df694148c
    Signed-off-by: haochen <haochen at multicorewareinc.com>
    Signed-off-by: I-Jui (Ray) Sung <ray at multicorewareinc.com>

diff --git a/sc/qa/unit/data/ods/opencl/math/Abs.ods b/sc/qa/unit/data/ods/opencl/math/Abs.ods
new file mode 100644
index 0000000..2e55c73
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/Abs.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 88232aa..90867ba 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -123,6 +123,7 @@ public:
     void testFinancialDurationFormula();
     void testFinancialCoupnumFormula();
     void testMathFormulaSinh();
+    void testMathFormulaAbs();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -177,6 +178,7 @@ public:
     CPPUNIT_TEST(testFinancialDurationFormula);
     CPPUNIT_TEST(testFinancialCoupnumFormula);
     CPPUNIT_TEST(testMathFormulaSinh);
+    CPPUNIT_TEST(testMathFormulaAbs);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -775,6 +777,32 @@ void ScOpenclTest::testFinacialFvscheduleFormula()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-47]
+void ScOpenclTest::testMathFormulaAbs()
+{
+    if (!detectOpenCLDevice())
+        return;
+    ScDocShellRef xDocSh =
+        loadDoc("opencl/math/Abs.", ODS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes =
+        loadDoc("opencl/math/Abs.", ODS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+
+    // Verify ABS Function
+    for (SCROW i = 1; i <= 1000; ++i)
+    {
+        double fLibre = pDoc->GetValue(ScAddress(1,i,0));
+        double fExcel = pDocRes->GetValue(ScAddress(1,i,0));
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+    }
+    xDocSh->DoClose();
+    xDocShRes->DoClose();
+}
 //[AMLOEXT-69]
 void ScOpenclTest::testFinacialSYDFormula()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 6333abb..c9d8d70 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1369,6 +1369,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocISPMT:
             case ocLaufz:
             case ocSinHyp:
+            case ocAbs:
             // Don't change the state.
             break;
             default:


More information about the Libreoffice-commits mailing list