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 6786d9b887f821160f7d77b9a5854bc0b019b38a Author: fengzeng <fengz...@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 <haoc...@multicorewareinc.com> Signed-off-by: I-Jui (Ray) Sung <r...@multicorewareinc.com> diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx index a710f22..cd040d6 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 f69d6457840216a87093a503a648ee3c34a04e78 Author: fengzeng <fengz...@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 <haoc...@multicorewareinc.com> Signed-off-by: I-Jui (Ray) Sung <r...@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 87c6bad..87414c0 100644 --- a/sc/qa/unit/opencl-test.cxx +++ b/sc/qa/unit/opencl-test.cxx @@ -127,6 +127,7 @@ public: void testFinacialPVFormula(); void testMathFormulaSin(); void testMathFormulaTan(); + void testMathFormulaTanH(); CPPUNIT_TEST_SUITE(ScOpenclTest); CPPUNIT_TEST(testSharedFormulaXLS); CPPUNIT_TEST(testFinacialFormula); @@ -185,6 +186,7 @@ public: CPPUNIT_TEST(testFinacialPVFormula); CPPUNIT_TEST(testMathFormulaSin); CPPUNIT_TEST(testMathFormulaTan); + CPPUNIT_TEST(testMathFormulaTanH); CPPUNIT_TEST_SUITE_END(); private: @@ -1221,6 +1223,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: _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits