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 14412c045c0f9a06ff2b3f4bdb9b3542ede4ebfe Author: fengzeng <fengz...@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 <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 e4a28ba..900bcd8 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 02e44285f47f8f0933de595c528bae6314fae5c2 Author: fengzeng <fengz...@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 <haoc...@multicorewareinc.com> Signed-off-by: I-Jui (Ray) Sung <r...@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 684bea7..21c839a 100644 --- a/sc/qa/unit/opencl-test.cxx +++ b/sc/qa/unit/opencl-test.cxx @@ -128,6 +128,7 @@ public: void testMathFormulaAbs(); void testFinacialPVFormula(); void testMathFormulaSin(); + void testMathFormulaTan(); CPPUNIT_TEST_SUITE(ScOpenclTest); CPPUNIT_TEST(testSharedFormulaXLS); CPPUNIT_TEST(testFinacialFormula); @@ -185,6 +186,7 @@ public: CPPUNIT_TEST(testMathFormulaAbs); CPPUNIT_TEST(testFinacialPVFormula); CPPUNIT_TEST(testMathFormulaSin); + CPPUNIT_TEST(testMathFormulaTan); CPPUNIT_TEST_SUITE_END(); private: @@ -1199,6 +1201,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: _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits