[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - 2 commits - sc/qa sc/source
yangzhang
yangzhang at multicorewareinc.com
Tue Nov 5 20:43:49 CET 2013
sc/qa/unit/data/ods/opencl/math/Abs.ods |binary
sc/qa/unit/opencl-test.cxx | 28 +++++++++++++++++++++++++++
sc/source/core/opencl/formulagroupcl.cxx | 5 ++++
sc/source/core/opencl/op_math.cxx | 32 +++++++++++++++++++++++++++++++
sc/source/core/opencl/op_math.hxx | 8 +++++++
sc/source/core/tool/token.cxx | 1
6 files changed, 74 insertions(+)
New commits:
commit bab01caa314a98e715d25c19d719c96b838310b3
Author: yangzhang <yangzhang at multicorewareinc.com>
Date: Mon Nov 4 15:36:56 2013 +0800
GPU Calc: implement fix for ABS
AMLOEXT-47 FIX
Change-Id: I438ad01d717dbc34ea8bc45e8f6de4f7d0c2bf2c
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 3e80351..0b69d4e 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1023,6 +1023,11 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
case ocSinHyp:
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i],new OpSinh));
+ break;
+ case ocAbs:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpAbs));
+ 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 32d2eb5..b3afda2 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -110,6 +110,38 @@ void OpSinh::GenSlidingWindowFunction(std::stringstream &ss,
ss << "}";
}
+void OpAbs::GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments)
+{
+ ss << "\ndouble " << sSymName;
+ ss << "_"<< BinFuncName() <<"(";
+ for (unsigned i = 0; i < vSubArguments.size(); i++)
+ {
+ if (i)
+ ss << ",";
+ vSubArguments[i]->GenSlidingWindowDecl(ss);
+ }
+ ss << ") {\n";
+ ss << " int gid0 = get_global_id(0);\n";
+ ss << " double tmp = " << GetBottom() << ";\n";
+#ifdef ISNAN
+ FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR0=
+ dynamic_cast<const formula::SingleVectorRefToken *>(tmpCur0);
+ ss << " int buffer_len = ";
+ ss << tmpCurDVR0->GetArrayLength();
+ ss << ";\n";
+ ss << " if((gid0)>=buffer_len || isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << "))\n";
+ ss << " tmp = " << GetBottom() << ";\n else \n";
+#endif
+ ss << " tmp = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ ss << " return fabs(tmp);\n";
+ ss << "}";
+}
}}
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index 7399a6a..1e59c41 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -38,6 +38,14 @@ public:
const std::string sSymName, SubArguments &vSubArguments);
virtual std::string BinFuncName(void) const { return "Sinh"; }
};
+
+class OpAbs:public Normal{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual std::string GetBottom(void) { return "0.0"; }
+ virtual std::string BinFuncName(void) const { return "ScAbs"; }
+};
}}
#endif
commit e753429f1c51aed08b972367437c87978f12e83a
Author: yangzhang <yangzhang at multicorewareinc.com>
Date: Mon Nov 4 14:58:13 2013 +0800
GPU Calc: unit test cases for ABS
Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-47 BUG
Change-Id: Ie33b4e5fad47f58a33ecdb0405521e7df694148c
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/ods/opencl/math/Abs.ods b/sc/qa/unit/data/ods/opencl/math/Abs.ods
new file mode 100644
index 0000000..2e55c73
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/Abs.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index f0d1e88..3a9493b 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -125,6 +125,7 @@ public:
void testFinancialDurationFormula();
void testFinancialCoupnumFormula();
void testMathFormulaSinh();
+ void testMathFormulaAbs();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -179,6 +180,7 @@ public:
CPPUNIT_TEST(testFinancialDurationFormula);
CPPUNIT_TEST(testFinancialCoupnumFormula);
CPPUNIT_TEST(testMathFormulaSinh);
+ CPPUNIT_TEST(testMathFormulaAbs);
CPPUNIT_TEST_SUITE_END();
private:
@@ -777,6 +779,32 @@ void ScOpenclTest::testFinacialFvscheduleFormula()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-47]
+void ScOpenclTest::testMathFormulaAbs()
+{
+ if (!detectOpenCLDevice())
+ return;
+ ScDocShellRef xDocSh =
+ loadDoc("opencl/math/Abs.", ODS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes =
+ loadDoc("opencl/math/Abs.", ODS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+
+ // Verify ABS Function
+ for (SCROW i = 1; i <= 1000; ++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-69]
void ScOpenclTest::testFinacialSYDFormula()
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 6333abb..c9d8d70 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1369,6 +1369,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocISPMT:
case ocLaufz:
case ocSinHyp:
+ case ocAbs:
// Don't change the state.
break;
default:
More information about the Libreoffice-commits
mailing list