sc/qa/unit/data/xls/opencl/math/sin.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, 65 insertions(+), 2 deletions(-)
New commits: commit 4b08a4109ce12530c34c9fe05e1077ce4587f15e Author: fengzeng <fengz...@multicorewareinc.com> Date: Mon Nov 4 16:25:48 2013 +0800 GPU Calc: implement fix for SIN AMLOEXT-58 FIX Change-Id: I68d23a66fd46b239911f8ba686b0492ca7783267 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 72cf329..e4a28ba 100644 --- a/sc/source/core/opencl/formulagroupcl.cxx +++ b/sc/source/core/opencl/formulagroupcl.cxx @@ -1032,6 +1032,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments( mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpPV)); break; + case ocSin: + mvSubArguments.push_back(SoPHelper(ts, + ft->Children[i], new OpSin)); + 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 b3afda2..3d7d4c9 100644 --- a/sc/source/core/opencl/op_math.cxx +++ b/sc/source/core/opencl/op_math.cxx @@ -109,7 +109,35 @@ void OpSinh::GenSlidingWindowFunction(std::stringstream &ss, ss << " return tmp;\n"; ss << "}"; } - +void OpSin::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=sin(arg0);\n"; + ss << " return tmp;\n"; + ss << "}"; +} void OpAbs::GenSlidingWindowFunction(std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments) { diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx index 1e59c41..1dbfec9 100644 --- a/sc/source/core/opencl/op_math.hxx +++ b/sc/source/core/opencl/op_math.hxx @@ -38,7 +38,13 @@ public: const std::string sSymName, SubArguments &vSubArguments); virtual std::string BinFuncName(void) const { return "Sinh"; } }; - +class OpSin: public Normal +{ +public: + virtual void GenSlidingWindowFunction(std::stringstream &ss, + const std::string sSymName, SubArguments &vSubArguments); + virtual std::string BinFuncName(void) const { return "Sin"; } +}; class OpAbs:public Normal{ public: virtual void GenSlidingWindowFunction(std::stringstream &ss, commit 89da92c9434ae1069aa195545e2813d418e837f6 Author: fengzeng <fengz...@multicorewareinc.com> Date: Mon Nov 4 16:20:25 2013 +0800 GPU Calc: unit test cases for SIN Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test AMLOEXT-58 BUG Change-Id: I484b86650e3e7bb11aa59aad6ae01be152aa2cef 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/sin.xls b/sc/qa/unit/data/xls/opencl/math/sin.xls new file mode 100644 index 0000000..71ea0d1 Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/sin.xls differ diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx index 3186ed7..684bea7 100644 --- a/sc/qa/unit/opencl-test.cxx +++ b/sc/qa/unit/opencl-test.cxx @@ -127,6 +127,7 @@ public: void testMathFormulaSinh(); void testMathFormulaAbs(); void testFinacialPVFormula(); + void testMathFormulaSin(); CPPUNIT_TEST_SUITE(ScOpenclTest); CPPUNIT_TEST(testSharedFormulaXLS); CPPUNIT_TEST(testFinacialFormula); @@ -183,6 +184,7 @@ public: CPPUNIT_TEST(testMathFormulaSinh); CPPUNIT_TEST(testMathFormulaAbs); CPPUNIT_TEST(testFinacialPVFormula); + CPPUNIT_TEST(testMathFormulaSin); CPPUNIT_TEST_SUITE_END(); private: @@ -1175,6 +1177,28 @@ void ScOpenclTest::testStatisticalFormulaNegbinomdist() xDocSh->DoClose(); xDocShRes->DoClose(); } +//[AMLOEXT-58] +void ScOpenclTest::testMathFormulaSin() +{ + if (!detectOpenCLDevice()) + return; + ScDocShellRef xDocSh = loadDoc("opencl/math/sin.", XLS); + ScDocument* pDoc = xDocSh->GetDocument(); + CPPUNIT_ASSERT(pDoc); + enableOpenCL(); + pDoc->CalcAll(); + ScDocShellRef xDocShRes = loadDoc("opencl/math/sin.", 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 ac0be80..16b8bb2 100644 --- a/sc/source/core/tool/token.cxx +++ b/sc/source/core/tool/token.cxx @@ -1371,6 +1371,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r ) case ocSinHyp: case ocAbs: case ocBW: + case ocSin: // Don't change the state. break; default: _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits