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

fengzeng fengzeng at multicorewareinc.com
Tue Nov 5 21:49:44 CET 2013


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

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

    GPU Calc: implemented TAN
    
    AMLOEXT-60 FIX
    
    Change-Id: Ibdbc0f22e152f5b73191f3a16e9e5489c0007fc3
    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 a0a2d3a..a710f22 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1036,6 +1036,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
                 mvSubArguments.push_back(SoPHelper(ts,
                          ft->Children[i], new OpSin));
                 break;
+            case ocTan:
+                mvSubArguments.push_back(SoPHelper(ts,
+                         ft->Children[i], new OpTan));
+                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 3d7d4c9..c5c213c 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -170,7 +170,35 @@ void OpAbs::GenSlidingWindowFunction(std::stringstream &ss,
     ss << "    return fabs(tmp);\n";
     ss << "}";
 }
-
+void OpTan::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=tan(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 1dbfec9..ed5a4e9 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -52,6 +52,14 @@ public:
     virtual std::string GetBottom(void) { return "0.0"; }
     virtual std::string BinFuncName(void) const { return "ScAbs"; }
 };
+class OpTan: public Normal
+{
+public:
+    virtual void GenSlidingWindowFunction(std::stringstream &ss,
+            const std::string sSymName, SubArguments &vSubArguments);
+
+    virtual std::string BinFuncName(void) const { return "Tan"; }
+};
 }}
 
 #endif
commit e7ff395a3f70573c0dbb4093e86ffe57e935fece
Author: fengzeng <fengzeng at multicorewareinc.com>
Date:   Mon Nov 4 16:32:44 2013 +0800

    GPU Calc: unit test cases for TAN
    
    Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
    
    AMLOEXT-60 BUG
    
    Change-Id: I29433afcc8403fd6938d39667b18e786f4e5b6fc
    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/tan.xls b/sc/qa/unit/data/xls/opencl/math/tan.xls
new file mode 100644
index 0000000..2a73718
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/tan.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 415b99c..87c6bad 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -126,6 +126,7 @@ public:
     void testMathFormulaAbs();
     void testFinacialPVFormula();
     void testMathFormulaSin();
+    void testMathFormulaTan();
     CPPUNIT_TEST_SUITE(ScOpenclTest);
     CPPUNIT_TEST(testSharedFormulaXLS);
     CPPUNIT_TEST(testFinacialFormula);
@@ -183,6 +184,7 @@ public:
     CPPUNIT_TEST(testMathFormulaAbs);
     CPPUNIT_TEST(testFinacialPVFormula);
     CPPUNIT_TEST(testMathFormulaSin);
+    CPPUNIT_TEST(testMathFormulaTan);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1197,6 +1199,28 @@ void ScOpenclTest::testMathFormulaSin()
     xDocSh->DoClose();
     xDocShRes->DoClose();
 }
+//[AMLOEXT-60]
+void ScOpenclTest::testMathFormulaTan()
+{
+    if (!detectOpenCLDevice())
+            return;
+    ScDocShellRef xDocSh = loadDoc("opencl/math/tan.", XLS);
+    ScDocument* pDoc = xDocSh->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+    enableOpenCL();
+    pDoc->CalcAll();
+    ScDocShellRef xDocShRes = loadDoc("opencl/math/tan.", 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 16b8bb2..d6f3280 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1372,6 +1372,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
             case ocAbs:
             case ocBW:
             case ocSin:
+            case ocTan:
             // Don't change the state.
             break;
             default:


More information about the Libreoffice-commits mailing list