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

fengzeng fengzeng at multicorewareinc.com
Tue Nov 5 22:12:11 CET 2013


 sc/qa/unit/data/xls/opencl/math/tanh.xls |binary
 sc/qa/unit/opencl-test.cxx               |   24 ++++++++++++++++++++++++
 sc/source/core/opencl/formulagroupcl.cxx |    4 ++++
 sc/source/core/opencl/op_math.cxx        |   31 +++++++++++++++++++++++++++++++
 sc/source/core/opencl/op_math.hxx        |    8 ++++++++
 sc/source/core/tool/token.cxx            |    1 +
 6 files changed, 68 insertions(+)

New commits:
commit d8a23a6239abb78cb3d4a4c631de288869135406
Author: fengzeng <fengzeng at multicorewareinc.com>
Date:   Mon Nov 4 16:50:16 2013 +0800

    GPU Calc: implemented TANH
    
    AMLOEXT-61 FIX
    
    Change-Id: I7c8dcc23d85aa809f134446dcab97e51405d58c2
    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 900bcd8..b2f403a 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1040,6 +1040,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i], new OpTan));
                 break;
+            case ocTanHyp:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i], new OpTanH));
+                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 c5c213c..d7286be 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -199,6 +199,37 @@ void OpTan::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    return tmp;\n";
     ss << "}";
 }
+void OpTanH::GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments)
+{
+    FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
+    const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast<const
+          formula::SingleVectorRefToken *>(tmpCur);
+    ss << "\ndouble " << sSymName;
+    ss << "_"<< BinFuncName() <<"(";
+    for (unsigned i = 0; i < vSubArguments.size(); i++)
+    {
+        if (i)
+            ss << ",";
+        vSubArguments[i]->GenSlidingWindowDecl(ss);
+    }
+    ss << ")\n";
+    ss << "{\n";
+    ss << "    int gid0=get_global_id(0);\n";
+    ss << "    double arg0 = "<< vSubArguments[0]->GenSlidingWindowDeclRef();
+    ss << ";\n";
+#ifdef ISNAN
+    ss << "    if(isNan(arg0)||(gid0>=";
+    ss << tmpCurDVR->GetArrayLength();
+    ss << "))\n";
+    ss << "        arg0 = 0;\n";
+#endif
+    ss << "    double tmp=tanh(arg0);\n";
+    ss << "    return tmp;\n";
+    ss << "}";
+}
+
+
 }}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index ed5a4e9..d7ce226 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -60,6 +60,14 @@ public:
 
     virtual std::string BinFuncName(void) const { return "Tan"; }
 };
+class OpTanH: public Normal
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+
+    virtual std::string BinFuncName(void) const { return "TanH"; }
+};
 }}
 
 #endif
commit e508d9ad054e9baf34e954f54e31046c90f80d2b
Author: fengzeng <fengzeng at multicorewareinc.com>
Date:   Mon Nov 4 16:47:01 2013 +0800

    GPU Calc: unit test cases for TANH
    
    Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-61 BUG
    
    Change-Id: I1db0693cdacdf437c413e56e3c97f0ff4d913211
    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/xls/opencl/math/tanh.xls b/sc/qa/unit/data/xls/opencl/math/tanh.xls
new file mode 100644
index 0000000..a19efd3
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/tanh.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 21c839a..6085a78 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -129,6 +129,7 @@ public:
     void testFinacialPVFormula();
     void testMathFormulaSin();
     void testMathFormulaTan();
+    void testMathFormulaTanH();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -187,6 +188,7 @@ public:
     CPPUNIT_TEST(testFinacialPVFormula);
     CPPUNIT_TEST(testMathFormulaSin);
     CPPUNIT_TEST(testMathFormulaTan);
+    CPPUNIT_TEST(testMathFormulaTanH);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1223,6 +1225,28 @@ void ScOpenclTest::testMathFormulaTan()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-61]
+void ScOpenclTest::testMathFormulaTanH()
+{
+    if (!detectOpenCLDevice())
+            return;
+    ScDocShellRef xDocSh = loadDoc("opencl/math/tanh.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/math/tanh.", XLS);
+    ScDocument* pDocRes = xDocShRes->GetDocument();
+    CPPUNIT_ASSERT(pDocRes);
+    for (SCROW i = 0; i <= 15; ++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-63]
 void ScOpenclTest::testFinacialPriceFormula()
 {
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index d6f3280..ee9e1ce 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1373,6 +1373,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocBW:
             case ocSin:
             case ocTan:
+            case ocTanHyp:
             // Don't change the state.
             break;
             default:


More information about the Libreoffice-commits mailing list