[Libreoffice-commits] core.git: Branch 'feature/calc-group-interpreter-4' - 36 commits - sc/qa sc/source
fengzeng
fengzeng at multicorewareinc.com
Thu Nov 14 18:41:10 PST 2013
sc/qa/unit/data/ods/opencl/math/ArcTan2.ods |binary
sc/qa/unit/data/ods/opencl/math/BitLshift.ods |binary
sc/qa/unit/data/ods/opencl/math/BitOr.ods |binary
sc/qa/unit/data/ods/opencl/math/BitRshift.ods |binary
sc/qa/unit/data/ods/opencl/math/BitXor.ods |binary
sc/qa/unit/data/xls/opencl/math/averageifs.xls |binary
sc/qa/unit/data/xls/opencl/math/combina.xls |binary
sc/qa/unit/data/xls/opencl/math/countifs.xls |binary
sc/qa/unit/data/xls/opencl/math/even.xls |binary
sc/qa/unit/data/xls/opencl/math/log.xls |binary
sc/qa/unit/data/xls/opencl/math/mod.xls |binary
sc/qa/unit/data/xls/opencl/math/sqrtpi.xls |binary
sc/qa/unit/data/xls/opencl/math/sumsq.xls |binary
sc/qa/unit/data/xls/opencl/math/trunc.xls |binary
sc/qa/unit/data/xls/opencl/statistical/ChiInv.xls |binary
sc/qa/unit/data/xls/opencl/statistical/Poisson.xls |binary
sc/qa/unit/data/xls/opencl/statistical/Skew.xls |binary
sc/qa/unit/data/xls/opencl/statistical/Skewp.xls |binary
sc/qa/unit/opencl-test.cxx | 459 +++++++++
sc/source/core/opencl/formulagroupcl.cxx | 74 +
sc/source/core/opencl/op_math.cxx | 799 +++++++++++++++++
sc/source/core/opencl/op_math.hxx | 107 ++
sc/source/core/opencl/op_statistical.cxx | 967 ++++++++++++++++++++-
sc/source/core/opencl/op_statistical.hxx | 29
sc/source/core/opencl/opbase.cxx | 3
sc/source/core/opencl/opinlinefun_math.hxx | 16
sc/source/core/tool/token.cxx | 17
27 files changed, 2467 insertions(+), 4 deletions(-)
New commits:
commit 2a9a7ba72667bf621f35d76306f88385c7d0b5aa
Author: fengzeng <fengzeng at multicorewareinc.com>
Date: Mon Nov 11 11:37:50 2013 +0800
GPU Calc: unit test cases for SQRTPI
Need to turn on NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-182 BUG
Change-Id: I314e4b8cc4434d20346c908a7eb2f274838e0d11
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/sqrtpi.xls b/sc/qa/unit/data/xls/opencl/math/sqrtpi.xls
new file mode 100644
index 0000000..2acf5b2
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/sqrtpi.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index a3d3d62..87a0a35 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -217,6 +217,7 @@ public:
void testStatisticalFormulaPoisson();
void testMathFormulaSumSQ();
void testStatisticalFormulaSkewp();
+ void testMathFormulaSqrtPi();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -363,6 +364,7 @@ public:
CPPUNIT_TEST(testStatisticalFormulaPoisson);
CPPUNIT_TEST(testMathFormulaSumSQ);
CPPUNIT_TEST(testStatisticalFormulaSkewp);
+ CPPUNIT_TEST(testMathFormulaSqrtPi);
CPPUNIT_TEST_SUITE_END();
private:
@@ -4079,6 +4081,28 @@ void ScOpenclTest::testMathFormulaCombina()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-182]
+void ScOpenclTest::testMathFormulaSqrtPi()
+{
+ if (!detectOpenCLDevice())
+ return;
+ ScDocShellRef xDocSh = loadDoc("opencl/math/sqrtpi.", XLS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes = loadDoc("opencl/math/sqrtpi.", XLS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ for (SCROW i = 0; i < 20; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(2,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(2,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
ScOpenclTest::ScOpenclTest()
: ScBootstrapFixture( "/sc/qa/unit/data" )
{
commit 306dd0ad9a33e02e33430503ede6a9087a01dbe0
Author: fengzeng <fengzeng at multicorewareinc.com>
Date: Mon Nov 11 11:45:02 2013 +0800
GPU Calc: implemented SQRTPI
AMLOEXT-182 FIX
Change-Id: Iceab026b8945863280d2393f9beb4145dfe45fce
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 8c1a5b7..4b80151 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1530,6 +1530,12 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
new OpAccrint));
}
+ else if ( !(pChild->GetExternal().compareTo(OUString(
+ "com.sun.star.sheet.addin.Analysis.getSqrtpi"))))
+ {
+ mvSubArguments.push_back(SoPHelper(ts, ft->Children[i],
+ new OpSqrtPi));
+ }
break;
default:
throw UnhandledToken(pChild, "unhandled opcode");
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index bdcf585..8406ea1 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1668,6 +1668,58 @@ void OpSumSQ::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return sum;\n";
ss << "}";
}
+void OpSqrtPi::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 << "{\n";
+ ss << " int gid0=get_global_id(0);\n";
+ ss << " double arg0 = 0.0f;\n";
+ FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
+ assert(tmpCur);
+ if(ocPush == vSubArguments[0]->GetFormulaToken()->GetOpCode())
+ {
+ if(tmpCur->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken*tmpCurDVR=
+ dynamic_cast
+ <const formula::SingleVectorRefToken *>(tmpCur);
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#ifdef ISNAN
+ ss << " if(isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ")||(gid0>=";
+ ss << tmpCurDVR->GetArrayLength();
+ ss << "))\n";
+ ss << " { arg0 = 0.0f; }\n";
+#endif
+ }
+ else if(tmpCur->GetType() == formula::svDouble)
+ {
+ ss << " arg0=";
+ ss << tmpCur->GetDouble() << ";\n";
+ }
+ }
+ else
+ {
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ }
+ ss << " return (double)sqrt(arg0 *";
+ ss << " 3.1415926535897932384626433832795f);\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 9475284..f6ead91 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -306,6 +306,14 @@ public:
virtual std::string BinFuncName(void) const { return "Mod"; }
};
+class OpSqrtPi: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+
+ virtual std::string BinFuncName(void) const { return "SqrtPi"; }
+};
class OpCombina: public Normal
{
commit e8d2be05acba8ebef3f244ce22b9d8ae19d2942c
Author: shiming zhang <shiming at multicorewareinc.com>
Date: Mon Nov 11 10:38:49 2013 +0800
GPU Calc: unit test cases for SKEWP
Need to turn on NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-81 BUG
Change-Id: I53e181c967b1ce7b2735539f4f714c9a7719cb7a
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/statistical/Skewp.xls b/sc/qa/unit/data/xls/opencl/statistical/Skewp.xls
new file mode 100644
index 0000000..deeca27
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/Skewp.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 85e2d41..a3d3d62 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -216,6 +216,7 @@ public:
void testStatisticalFormulaChiInv();
void testStatisticalFormulaPoisson();
void testMathFormulaSumSQ();
+ void testStatisticalFormulaSkewp();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -361,6 +362,7 @@ public:
CPPUNIT_TEST(testStatisticalFormulaChiInv);
CPPUNIT_TEST(testStatisticalFormulaPoisson);
CPPUNIT_TEST(testMathFormulaSumSQ);
+ CPPUNIT_TEST(testStatisticalFormulaSkewp);
CPPUNIT_TEST_SUITE_END();
private:
@@ -1743,6 +1745,31 @@ void ScOpenclTest::testStatisticalFormulaSkew()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-81]
+void ScOpenclTest::testStatisticalFormulaSkewp()
+{
+ if (!detectOpenCLDevice())
+ return;
+
+ ScDocShellRef xDocSh = loadDoc("opencl/statistical/Skewp.", XLS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+
+ ScDocShellRef xDocShRes = loadDoc("opencl/statistical/Skewp.", XLS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ // Check the results of formula cells in the shared formula range.
+ for (SCROW i = 1; i <= 20; ++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-82]
void ScOpenclTest::testStatisticalFormulaPearson()
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 14cd987..3d99294 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1446,6 +1446,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocChiInv:
case ocPoissonDist:
case ocSumSQ:
+ case ocSkewp:
// Don't change the state.
break;
default:
commit 6fd8a627fa53ec5483d86e04e9d72130094a73de
Author: shiming zhang <shiming at multicorewareinc.com>
Date: Mon Nov 11 11:02:30 2013 +0800
GPU Calc: implemented SKEWP
AMLOEXT-81 FIX
Change-Id: I77ea979ca1f046ecc8a865cc7d19cd676fa70cbd
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 59d1e46..8c1a5b7 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1337,6 +1337,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpSumSQ));
break;
+ case ocSkewp:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpSkewp));
+ break;
case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getEffect"))))
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index 9e78511..d02313a 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -1011,6 +1011,345 @@ void OpSkew::GenSlidingWindowFunction(std::stringstream &ss,
ss << "(fCount - 1.0)) / (fCount - 2.0);\n";
ss << "}\n";
}
+void OpSkewp::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 fSum = 0.0;\n";
+ ss << " double fMean = 0.0;\n";
+ ss << " double vSum = 0.0;\n";
+ ss << " double fCount = 0.0;\n";
+ ss << " double arg = 0.0;\n";
+ unsigned i = vSubArguments.size();
+ while (i--)
+ {
+ FormulaToken* pCur = vSubArguments[i]->GetFormulaToken();
+ assert(pCur);
+ if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
+ {
+ if (pCur->GetType() == formula::svDoubleVectorRef)
+ {
+ const formula::DoubleVectorRefToken* pDVR =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+ size_t nCurWindowSize = pDVR->GetRefRowSize();
+ ss << " for (int i = ";
+ if (!pDVR->IsStartFixed() && pDVR->IsEndFixed())
+ {
+#ifdef ISNAN
+ ss << "gid0; i < " << pDVR->GetArrayLength();
+ ss << " && i < " << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+ else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+ {
+#ifdef ISNAN
+ ss << "0; i < " << pDVR->GetArrayLength();
+ ss << " && i < gid0+"<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+ else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+ {
+#ifdef ISNAN
+ ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+ ss << " && i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+ else
+ {
+#ifdef ISNAN
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+
+ ss << " arg = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef ISNAN
+ ss << " if (isNan(arg))\n";
+ ss << " continue;\n";
+#endif
+ ss << " fSum += arg;\n";
+ ss << " fCount += 1;\n";
+ ss << " }\n";
+ }
+ else if (pCur->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken* pSVR =
+ dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+ assert(pSVR);
+#ifdef ISNAN
+ ss << " if (gid0 < " << pSVR->GetArrayLength() << ")\n";
+ ss << " {\n";
+ ss << " if (!isNan(";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef() << "))\n";
+ ss << " {\n";
+#endif
+ ss << " arg=";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " fSum += arg;\n";
+ ss << " fCount += 1;\n";
+#ifdef ISNAN
+ ss << " }\n";
+ ss << " }\n";
+#endif
+ }
+ else
+ {
+ ss << " arg=" << pCur->GetDouble() << ";\n";
+ ss << " fSum += arg;\n";
+ ss << " fCount += 1;\n";
+ }
+ }
+ else
+ {
+ ss << " arg=";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " fSum += arg;\n";
+ ss << " fCount += 1;\n";
+ }
+
+ if(i == 0)
+ {
+ ss << " if(fCount <= 2)\n";
+ ss << " return 0;\n";
+ ss << " else\n";
+ ss << " fMean = fSum / " << "fCount" << ";\n";
+ }
+ }
+ i = vSubArguments.size();
+ while (i--)
+ {
+ FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+ assert(pCur);
+ if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
+ {
+ if (pCur->GetType() == formula::svDoubleVectorRef)
+ {
+ const formula::DoubleVectorRefToken* pDVR =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+ size_t nCurWindowSize = pDVR->GetRefRowSize();
+ ss << " for (int i = ";
+ if (!pDVR->IsStartFixed() && pDVR->IsEndFixed())
+ {
+#ifdef ISNAN
+ ss << "gid0; i < " << pDVR->GetArrayLength();
+ ss << " && i < " << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+ else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+ {
+#ifdef ISNAN
+ ss << "0; i < " << pDVR->GetArrayLength();
+ ss << " && i < gid0+"<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+ else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+ {
+#ifdef ISNAN
+ ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+ ss << " && i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+ else
+ {
+#ifdef ISNAN
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+
+ ss << " arg = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef ISNAN
+ ss << " if (isNan(arg))\n";
+ ss << " continue;\n";
+#endif
+ ss << " vSum += (arg - fMean) * (arg - fMean);\n";
+ ss << " }\n";
+ }
+ else if (pCur->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken* pSVR =
+ dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+ assert(pSVR);
+#ifdef ISNAN
+ ss << " if (gid0 < " << pSVR->GetArrayLength() << ")\n";
+ ss << " {\n";
+ ss << " if (!isNan(";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef() << "))\n";
+ ss << " {\n";
+#endif
+ ss << " arg=";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " vSum += (arg - fMean) * (arg - fMean);\n";
+#ifdef ISNAN
+ ss << " }\n";
+ ss << " }\n";
+#endif
+ }
+ else
+ {
+ ss << " arg = " << pCur->GetDouble() << ";\n";
+ ss << " vSum += (arg - fMean) * (arg - fMean);\n";
+ }
+ }
+ else
+ {
+ ss << " arg=";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " vSum += (arg - fMean) * (arg - fMean);\n";
+ }
+ }
+ ss << " double fStdDev = sqrt(vSum/fCount);\n";
+ ss << " double dx = 0.0;\n";
+ ss << " double xcube = 0.0;\n";
+ ss << " if(fStdDev == 0.0)\n";
+ ss << " return DBL_MAX;\n";
+ i = vSubArguments.size();
+ while (i--)
+ {
+ FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+ assert(pCur);
+ if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
+ {
+ if (pCur->GetType() == formula::svDoubleVectorRef)
+ {
+ const formula::DoubleVectorRefToken* pDVR =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+ size_t nCurWindowSize = pDVR->GetRefRowSize();
+ ss << " for (int i = ";
+ if (!pDVR->IsStartFixed() && pDVR->IsEndFixed())
+ {
+#ifdef ISNAN
+ ss << "gid0; i < " << pDVR->GetArrayLength();
+ ss << " && i < " << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+ else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+ {
+#ifdef ISNAN
+ ss << "0; i < " << pDVR->GetArrayLength();
+ ss << " && i < gid0+"<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+ else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+ {
+#ifdef ISNAN
+ ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+ ss << " && i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+ else
+ {
+#ifdef ISNAN
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+
+ ss << " arg = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef ISNAN
+ ss << " if (isNan(arg))\n";
+ ss << " continue;\n";
+#endif
+ ss << " dx = (arg - fMean) / fStdDev;\n";
+ ss << " xcube = xcube + (dx * dx * dx);\n";
+ ss << " }\n";
+ }
+ else if (pCur->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken* pSVR =
+ dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+ assert(pSVR);
+#ifdef ISNAN
+ ss << " if (gid0 < " << pSVR->GetArrayLength() << ")\n";
+ ss << " {\n";
+ ss << " if (!isNan(";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef() << "))\n";
+ ss << " {\n";
+#endif
+ ss << " arg = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " dx = (arg - fMean) / fStdDev;\n";
+ ss << " xcube = xcube+(dx*dx*dx);\n";
+#ifdef ISNAN
+ ss << " }\n";
+ ss << " }\n";
+#endif
+ }
+ else
+ {
+ ss << " arg = " << pCur->GetDouble() << ";\n";
+ ss << " dx = (arg - fMean) / fStdDev;\n";
+ ss << " xcube = xcube + (dx * dx * dx);\n";
+ }
+ }
+ else
+ {
+ ss << " arg = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " dx = (arg - fMean) / fStdDev;\n";
+ ss << " xcube = xcube + (dx * dx * dx);\n";
+ }
+ }
+ ss << " return xcube / fCount;\n";
+ ss << "}\n";
+}
void OpFisher::GenSlidingWindowFunction(
std::stringstream &ss, const std::string sSymName, SubArguments &vSubArguments)
{
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index 5f1681f..e80075e 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -35,6 +35,13 @@ public:
const std::string sSymName, SubArguments &vSubArguments);
virtual std::string BinFuncName(void) const { return "Var"; }
};
+class OpSkewp: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual std::string BinFuncName(void) const { return "Skewp"; }
+};
class OpWeibull: public Normal
{
public:
commit d3e7cdb04e334f4114d1201c9bcf428f00e28dc8
Author: fengzeng <fengzeng at multicorewareinc.com>
Date: Mon Nov 11 10:25:37 2013 +0800
GPU Calc: unit test cases for SUMSQ
Need to enable NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-59 BUG
Change-Id: Ia6222c2f3b68c82949c9b4686f9db7ad7cc7bf75
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/sumsq.xls b/sc/qa/unit/data/xls/opencl/math/sumsq.xls
new file mode 100644
index 0000000..54f00b6
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/math/sumsq.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index c577c2b..85e2d41 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -215,6 +215,7 @@ public:
void testMathFormulaBitXor();
void testStatisticalFormulaChiInv();
void testStatisticalFormulaPoisson();
+ void testMathFormulaSumSQ();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -359,6 +360,7 @@ public:
CPPUNIT_TEST(testMathFormulaBitXor);
CPPUNIT_TEST(testStatisticalFormulaChiInv);
CPPUNIT_TEST(testStatisticalFormulaPoisson);
+ CPPUNIT_TEST(testMathFormulaSumSQ);
CPPUNIT_TEST_SUITE_END();
private:
@@ -1373,6 +1375,28 @@ void ScOpenclTest::testMathFormulaSin()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-59]
+void ScOpenclTest::testMathFormulaSumSQ()
+{
+ if (!detectOpenCLDevice())
+ return;
+ ScDocShellRef xDocSh = loadDoc("opencl/math/sumsq.", XLS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes = loadDoc("opencl/math/sumsq.", XLS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ for (SCROW i = 0; i < 20; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(5,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(5,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
//[AMLOEXT-60]
void ScOpenclTest::testMathFormulaTan()
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 6b4fadb..14cd987 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1445,6 +1445,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocBitXor:
case ocChiInv:
case ocPoissonDist:
+ case ocSumSQ:
// Don't change the state.
break;
default:
commit 9097241e0b84520bb92dc6127f301585db239e1b
Author: fengzeng <fengzeng at multicorewareinc.com>
Date: Mon Nov 11 10:32:06 2013 +0800
GPU Calc: implemented SUMSQ
AMLOEXT-59 FIX
Change-Id: I33c8241febef766db4ff46e5ed875b46d5e1275c
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 1968272..59d1e46 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1333,6 +1333,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i],new OpPoisson));
break;
+ case ocSumSQ:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpSumSQ));
+ 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 4c86830..bdcf585 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1554,6 +1554,120 @@ void OpBitRshift::GenSlidingWindowFunction(std::stringstream &ss,
ss << "num * pow(2.0, fabs(shift_amount)));\n";
ss << "}";
}
+void OpSumSQ::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 << "{\n";
+ ss << " int gid0=get_global_id(0);\n";
+ ss << " double sum = 0.0f, arg;\n";
+ for( unsigned i=0; i < vSubArguments.size(); ++i)
+ {
+ FormulaToken *tmpCur = vSubArguments[i]->GetFormulaToken();
+ assert(tmpCur);
+ if(ocPush == vSubArguments[i]->GetFormulaToken()->GetOpCode())
+ {
+ if (tmpCur->GetType() == formula::svDoubleVectorRef)
+ {
+ const formula::DoubleVectorRefToken* pDVR =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(tmpCur);
+ size_t nCurWindowSize = pDVR->GetRefRowSize();
+ ss << " for (int i = ";
+ if (!pDVR->IsStartFixed() && pDVR->IsEndFixed())
+ {
+#ifdef ISNAN
+ ss << "gid0; i < " << pDVR->GetArrayLength();
+ ss << " && i < " << nCurWindowSize << "; ++i)\n";
+ ss << " {\n";
+#else
+ ss << "gid0; i < "<< nCurWindowSize << "; ++i)\n";
+ ss << " {\n";
+#endif
+ }
+ else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+ {
+#ifdef ISNAN
+ ss << "0; i < " << pDVR->GetArrayLength();
+ ss << " && i < gid0+"<< nCurWindowSize << "; ++i)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < gid0+"<< nCurWindowSize << "; ++i)\n";
+ ss << " {\n";
+#endif
+ }
+ else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+ {
+#ifdef ISNAN
+ ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+ ss << " && i < "<< nCurWindowSize << "; ++i)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; ++i)\n";
+ ss << " {\n";
+#endif
+ }
+ else
+ {
+#ifdef ISNAN
+ ss << "0; i < "<< nCurWindowSize << "; ++i)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; ++i)\n";
+ ss << " {\n";
+#endif
+ }
+ ss << " arg = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#ifdef ISNAN
+ ss << " if (isNan(arg))\n";
+ ss << " continue;\n";
+#endif
+ ss << " sum += arg*arg;\n";
+ ss << " }\n";
+ }
+ else if(tmpCur->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken* tmpCurDVR=
+ dynamic_cast<
+ const formula::SingleVectorRefToken *>(tmpCur);
+ ss << " arg = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#ifdef ISNAN
+ ss << " if(isNan(arg)||(gid0>=";
+ ss << tmpCurDVR->GetArrayLength();
+ ss << "))\n";
+ ss << " arg = 0.0f;\n";
+ ss << " sum += arg * arg;\n";
+#endif
+ }
+ else if(tmpCur->GetType() == formula::svDouble)
+ {
+ ss << " arg = ";
+ ss << tmpCur->GetDouble() << ";\n";
+ ss << " sum += arg*arg;\n";
+ }
+ }
+ else
+ {
+ ss << " arg = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ ss << " sum += arg*arg;\n";
+ }
+ }
+ ss << " return sum;\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 b6d2432..9475284 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -218,6 +218,14 @@ public:
virtual std::string BinFuncName(void) const { return "Cot"; }
};
+class OpSumSQ: public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+
+ virtual std::string BinFuncName(void) const { return "SumSQ"; }
+};
class OpCoth: public Normal
{
public:
commit 36ee170b03cb18bb314d007aeb94cd8f68cd85c3
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date: Sun Nov 10 11:00:18 2013 +0800
GPU Calc: unit test cases for POISSON
Need to turn on NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-150 BUG
Change-Id: I29324659b31d98905ead88d0d0cf44361ad1df16
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/statistical/Poisson.xls b/sc/qa/unit/data/xls/opencl/statistical/Poisson.xls
new file mode 100644
index 0000000..135c5fe
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/Poisson.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index c576896..c577c2b 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -214,6 +214,7 @@ public:
void testMathFormulaBitRshift();
void testMathFormulaBitXor();
void testStatisticalFormulaChiInv();
+ void testStatisticalFormulaPoisson();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -357,6 +358,7 @@ public:
CPPUNIT_TEST(testMathFormulaBitRshift);
CPPUNIT_TEST(testMathFormulaBitXor);
CPPUNIT_TEST(testStatisticalFormulaChiInv);
+ CPPUNIT_TEST(testStatisticalFormulaPoisson);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3406,6 +3408,29 @@ void ScOpenclTest::testMathFormulaBitAnd()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-150]
+void ScOpenclTest::testStatisticalFormulaPoisson()
+{
+ if (!detectOpenCLDevice())
+ return;
+ ScDocShellRef xDocSh = loadDoc("opencl/statistical/Poisson.", XLS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes = loadDoc("opencl/statistical/Poisson.", XLS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ // Check the results of formula cells in the shared formula range.
+ for (SCROW i = 1; i <= 19; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(3,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(3,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
//[AMLOEXT-151]
void ScOpenclTest::testStatisticalFormulaExpondist()
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index cd2018b..6b4fadb 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1444,6 +1444,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocBitRshift:
case ocBitXor:
case ocChiInv:
+ case ocPoissonDist:
// Don't change the state.
break;
default:
commit e2dfbf666e2b358930aff4a55755cb6779fb8dc8
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date: Sun Nov 10 11:06:36 2013 +0800
GPU Calc: implemented POISSON
AMLOEXT-150 FIX
Change-Id: I2ea5128b4b116a91477c1a339a65d3a052f4ebca
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 1698500..1968272 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1329,6 +1329,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i],new OpChiInv));
break;
+ case ocPoissonDist:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i],new OpPoisson));
+ break;
case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getEffect"))))
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index 4144cd6..9e78511 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -4305,7 +4305,154 @@ void OpBetaDist::BinInlineFun(std::set<std::string>& decls,
funs.insert(lcl_GetBetaHelperContFrac);funs.insert(GetLogBeta);
funs.insert(GetBeta);funs.insert(lcl_getLanczosSum);
}
-
+void OpPoisson::BinInlineFun(std::set<std::string>& decls,
+ std::set<std::string>& funs)
+{
+ decls.insert(fHalfMachEpsDecl);
+ funs.insert("");
+ decls.insert(fMaxGammaArgumentDecl);
+ funs.insert("");
+ decls.insert(fBigInvDecl);
+ funs.insert("");
+ decls.insert(GetLogGammaDecl);
+ funs.insert(GetLogGamma);
+ decls.insert(lcl_GetLogGammaHelperDecl);
+ funs.insert(lcl_GetLogGammaHelper);
+ decls.insert(lcl_GetGammaHelperDecl);
+ funs.insert(lcl_GetGammaHelper);
+ decls.insert(lcl_getLanczosSumDecl);
+ funs.insert(lcl_getLanczosSum);
+ decls.insert(GetUpRegIGammaDecl);
+ funs.insert(GetUpRegIGamma);
+ decls.insert(GetGammaContFractionDecl);
+ funs.insert(GetGammaContFraction);
+ decls.insert(GetGammaSeriesDecl);
+ funs.insert(GetGammaSeries);
+}
+void OpPoisson::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 << "{\n";
+ ss << " double x,lambda,tmp;\n";
+ ss << " int bCumulative;\n";
+ ss << " int gid0=get_global_id(0);\n";
+#ifdef ISNAN
+ FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR0= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur0);
+ FormulaToken *tmpCur1 = vSubArguments[1]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR1= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur1);
+ FormulaToken *tmpCur2 = vSubArguments[2]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVR2= dynamic_cast<const
+ formula::SingleVectorRefToken *>(tmpCur2);
+ ss << " int buffer_x_len = ";
+ ss << tmpCurDVR0->GetArrayLength();
+ ss << ";\n";
+ ss << " int buffer_lambda_len = ";
+ ss << tmpCurDVR1->GetArrayLength();
+ ss << ";\n";
+ ss << " int buffer_bCumulative_len = ";
+ ss << tmpCurDVR2->GetArrayLength();
+ ss << ";\n";
+#endif
+#ifdef ISNAN
+ ss <<" if((gid0)>=buffer_x_len || isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss <<"))\n";
+ ss <<" x = 0;\n";
+ ss <<" else \n";
+#endif
+ ss <<" x ="<<vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#ifdef ISNAN
+ ss <<" if((gid0)>=buffer_lambda_len || isNan(";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss <<"))\n";
+ ss <<" lambda = 0;\n";
+ ss <<" else \n";
+#endif
+ ss <<" lambda ="<<vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#ifdef ISNAN
+ ss <<" if((gid0)>=buffer_bCumulative_len || isNan(";
+ ss << vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss <<"))\n";
+ ss <<" bCumulative = 0;\n";
+ ss <<"else \n";
+#endif
+ ss <<" bCumulative ="<<vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ ss << " if (!bCumulative)\n";
+ ss << " {\n";
+ ss << " if(lambda == 0.0)\n";
+ ss << " {\n";
+ ss << " return 0;\n";
+ ss << " }\n";
+ ss << " else\n";
+ ss << " {\n";
+ ss << " if (lambda >712)\n";
+ ss << " {\n";
+ ss << " tmp = (exp(x*log(lambda)-lambda-GetLogGamma(x+1.0)));\n";
+ ss << " return tmp;\n";
+ ss << " }\n";
+ ss << " else\n";
+ ss << " {\n";
+ ss << " double fPoissonVar = 1.0;\n";
+ ss << " for ( int f = 0; f < x; ++f )\n";
+ ss << " fPoissonVar *= lambda / ( (double)f + 1.0 );\n";
+ ss << " tmp = ( fPoissonVar * exp( -lambda ) );\n";
+ ss << " return tmp;\n";
+ ss << " }\n";
+ ss << " }\n";
+ ss << " } \n";
+ ss << " else\n";
+ ss << " {\n";
+ ss << " if (lambda == 0.0)\n";
+ ss << " {\n";
+ ss << " return 1;\n";
+ ss << " }\n";
+ ss << " else\n";
+ ss << " {\n";
+ ss << " if (lambda > 712 )\n";
+ ss << " {\n";
+ ss << " tmp = (GetUpRegIGamma(x+1.0,lambda));\n";
+ ss << " return tmp;\n";
+ ss << " }\n";
+ ss << " else\n";
+ ss << " {\n";
+ ss << " if (x >= 936.0)\n";
+ ss << " {\n";
+ ss << " return 1;\n";
+ ss << " }\n";
+ ss << " else\n";
+ ss << " {\n";
+ ss << " double fSummand = exp(-lambda);\n";
+ ss << " double fSum = fSummand;\n";
+ ss << " int nEnd = (int) (x + 0.5);\n";
+ ss << " for (int i = 1; i <= nEnd; i++)\n";
+ ss << " {\n";
+ ss << " fSummand = (fSummand*lambda)/(double)i;\n";
+ ss << " fSum += fSummand;\n";
+ ss << " }\n";
+ ss << " tmp = fSum;\n";
+ ss << " return tmp;\n";
+ ss << " }\n";
+ ss << " }\n";
+ ss << " }\n";
+ ss << " }\n";
+ ss << "}\n";
+}
void OpBetaDist::GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments)
{
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index ed88bf2..5f1681f 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -291,6 +291,14 @@ class OpChiInv:public Normal{
virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>&);
virtual std::string BinFuncName(void) const { return "OpChiInv"; }
};
+class OpPoisson:public Normal{
+ public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>&);
+ virtual std::string BinFuncName(void) const { return "OpPoisson"; }
+};
+
class OpGammaInv: public Normal
{
public:
commit da42f6d0d7691cacd3c6831477c416f5c67dac65
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date: Sun Nov 10 10:32:15 2013 +0800
GPU Calc: unit test cases for CHIINV
Need to enable NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-173 BUG
Change-Id: I630f4f7c994dacc601421e96290db5e2408ca569
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/statistical/ChiInv.xls b/sc/qa/unit/data/xls/opencl/statistical/ChiInv.xls
new file mode 100644
index 0000000..9de54c1
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/ChiInv.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 27c41e3..c576896 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -213,6 +213,7 @@ public:
void testMathFormulaBitLshift();
void testMathFormulaBitRshift();
void testMathFormulaBitXor();
+ void testStatisticalFormulaChiInv();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -355,6 +356,7 @@ public:
CPPUNIT_TEST(testMathFormulaBitLshift);
CPPUNIT_TEST(testMathFormulaBitRshift);
CPPUNIT_TEST(testMathFormulaBitXor);
+ CPPUNIT_TEST(testStatisticalFormulaChiInv);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3864,6 +3866,29 @@ void ScOpenclTest::testMathFormulaLog()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-173]
+void ScOpenclTest::testStatisticalFormulaChiInv()
+{
+ if (!detectOpenCLDevice())
+ return;
+ ScDocShellRef xDocSh = loadDoc("opencl/statistical/ChiInv.", XLS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes = loadDoc("opencl/statistical/ChiInv.", XLS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ // Check the results of formula cells in the shared formula range.
+ for (SCROW i = 1; i <= 10; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(2,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(2,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
//[ AMLOEXT-176 ]
void ScOpenclTest::testMathCountIfsFormula()
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 21b5bcc..cd2018b 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1443,6 +1443,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocBitLshift:
case ocBitRshift:
case ocBitXor:
+ case ocChiInv:
// Don't change the state.
break;
default:
commit e1089bdd8a5ad64ac05117d9a27b95d20bc6ac90
Author: hongyu zhong <hongyu at multicorewareinc.com>
Date: Sun Nov 10 10:44:13 2013 +0800
GPU Calc: implemented CHIINV
AMLOEXT-173 FIX
Change-Id: I04f09bf111f9dff50353beb4e4d094365574f8ba
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 d55c8d1..1698500 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1325,6 +1325,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpBitXor));
break;
+ case ocChiInv:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i],new OpChiInv));
+ break;
case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getEffect"))))
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index 636afd0..4144cd6 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -1873,6 +1873,146 @@ void OpRsq::GenSlidingWindowFunction(
ss << "return (tmp * tmp);\n";
ss << "}\n";
}
+
+void OpChiInv::BinInlineFun(std::set<std::string>& decls,
+ std::set<std::string>& funs)
+{
+ decls.insert(fMachEpsDecl);
+ funs.insert("");
+ decls.insert(fBigInvDecl);
+ funs.insert("");
+ decls.insert(fHalfMachEpsDecl);
+ funs.insert("");
+ decls.insert(lcl_IterateInverseChiInvDecl);
+ funs.insert(lcl_IterateInverseChiInv);
+ decls.insert(GetChiDistDecl);
+ funs.insert(GetChiDist);
+ decls.insert(lcl_HasChangeOfSignDecl);
+ funs.insert(lcl_HasChangeOfSign);
+ decls.insert(GetUpRegIGammaDecl);
+ funs.insert(GetUpRegIGamma);
+ decls.insert(GetGammaContFractionDecl);
+ funs.insert(GetGammaContFraction);
+ decls.insert(GetGammaSeriesDecl);
+ funs.insert(GetGammaSeries);
+}
+void OpChiInv::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 << "{\n";
+ ss << " double tmp0,tmp1,tmp;\n";
+ ss << " int gid0=get_global_id(0);\n";
+ size_t i = vSubArguments.size();
+ size_t nItems = 0;
+ ss <<"\n ";
+ for (i = 0; i < vSubArguments.size(); i++)
+ {
+ FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+ assert(pCur);
+ if (pCur->GetType() == formula::svDoubleVectorRef)
+ {
+ const formula::DoubleVectorRefToken* pDVR =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+ size_t nCurWindowSize = pDVR->GetRefRowSize();
+ ss << "for (int i = ";
+ if (!pDVR->IsStartFixed() && pDVR->IsEndFixed()) {
+#ifdef ISNAN
+ ss << "gid0; i < " << pDVR->GetArrayLength();
+ ss << " && i < " << nCurWindowSize << "; i++){\n";
+#else
+ ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+ } else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed()) {
+#ifdef ISNAN
+ ss << "0; i < " << pDVR->GetArrayLength();
+ ss << " && i < gid0+"<< nCurWindowSize << "; i++){\n";
+#else
+ ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
+#endif
+ } else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed()){
+#ifdef ISNAN
+ ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+ ss << " && i < "<< nCurWindowSize << "; i++){\n";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+ }
+ else {
+#ifdef ISNAN
+ ss << "0; i < "<< nCurWindowSize << "; i++){\n";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+#endif
+ }
+ nItems += nCurWindowSize;
+ }
+ else if (pCur->GetType() == formula::svSingleVectorRef)
+ {
+#ifdef ISNAN
+ const formula::SingleVectorRefToken* pSVR =
+ dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+ ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n";
+#else
+ nItems += 1;
+#endif
+ }
+ else if (pCur->GetType() == formula::svDouble)
+ {
+#ifdef ISNAN
+ ss << "{\n";
+#endif
+ nItems += 1;
+ }
+ else
+ {
+#ifdef ISNAN
+#endif
+ nItems += 1;
+ }
+#ifdef ISNAN
+ if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
+ {
+ ss << "if (isNan(";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << "))\n";
+ ss << " tmp"<<i<<"= 0;\n";
+ ss << "else\n";
+ ss <<"tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n}\n";
+ }
+ else
+ {
+ ss << "tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ }
+#else
+ ss << "tmp"<<i<<"="<<vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+#endif
+ }
+ ss << " tmp1 = floor(tmp1);";
+ ss << " if (tmp1 < 1.0 || tmp0 <= 0.0 || tmp0 > 1.0 )\n";
+ ss << " {\n";
+ ss << " return DBL_MIN;\n";
+ ss << " }\n";
+ ss << " bool bConvError;\n";
+ ss << " double fVal = lcl_IterateInverseChiInv";
+ ss << "(tmp0, tmp1, tmp1*0.5, tmp1, &bConvError);\n";
+ ss << " if(bConvError)\n";
+ ss << " return DBL_MIN;\n";
+ ss << " return fVal;\n";
+ ss << "}\n";
+}
void OpNormdist::GenSlidingWindowFunction(
std::stringstream &ss, const std::string sSymName,
SubArguments &vSubArguments)
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index e9ab0e6..ed88bf2 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -284,6 +284,13 @@ public:
virtual std::string BinFuncName(void) const { return "ChiSqInv"; }
virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& );
};
+class OpChiInv:public Normal{
+ public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>&);
+ virtual std::string BinFuncName(void) const { return "OpChiInv"; }
+};
class OpGammaInv: public Normal
{
public:
commit bc2a88cd045b78361716592944b297bf9941efbc
Author: yangzhang <yangzhang at multicorewareinc.com>
Date: Sun Nov 10 10:18:22 2013 +0800
GPU Calc: unit test cases for BITXOR
Need open macro NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-178 BUG
Change-Id: Iab8988244328ab9be2ccf0d69ee862c82cf05738
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/BitXor.ods b/sc/qa/unit/data/ods/opencl/math/BitXor.ods
new file mode 100644
index 0000000..c8e812a
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/BitXor.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index ffdb01a..27c41e3 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -212,6 +212,7 @@ public:
void testMathFormulaBitOr();
void testMathFormulaBitLshift();
void testMathFormulaBitRshift();
+ void testMathFormulaBitXor();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -353,6 +354,7 @@ public:
CPPUNIT_TEST(testMathFormulaBitOr);
CPPUNIT_TEST(testMathFormulaBitLshift);
CPPUNIT_TEST(testMathFormulaBitRshift);
+ CPPUNIT_TEST(testMathFormulaBitXor);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3885,6 +3887,29 @@ void ScOpenclTest::testMathCountIfsFormula()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-178]
+void ScOpenclTest::testMathFormulaBitXor()
+{
+ if (!detectOpenCLDevice())
+ return;
+ ScDocShellRef xDocSh = loadDoc("opencl/math/BitXor.", ODS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes = loadDoc("opencl/math/BitXor.", ODS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ // Verify BitXor Function
+ for (SCROW i = 1; i <= 20; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(2,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(2,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
//[ AMLOEXT-179]
void ScOpenclTest::testMathAverageIfsFormula()
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index f0d2d7c..21b5bcc 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1442,6 +1442,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocBitOr:
case ocBitLshift:
case ocBitRshift:
+ case ocBitXor:
// Don't change the state.
break;
default:
commit d157c605e1711d4f6530f106d7cff70f458d57b7
Author: yangzhang <yangzhang at multicorewareinc.com>
Date: Sun Nov 10 10:22:51 2013 +0800
GPU Calc: implemented for BITXOR
AMLOEXT-178 FIX
Change-Id: I7815b6455270cd85e8de95f2afc52fa7029ca478
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 dc9c7c2..d55c8d1 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1321,6 +1321,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpBitRshift));
break;
+ case ocBitXor:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpBitXor));
+ 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 59d2f66..4c86830 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1422,6 +1422,48 @@ void OpBitOr::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return (long)num1 | (long)num2;\n";
ss << "}";
}
+void OpBitXor::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 num1 = " << GetBottom() << ";\n";
+ ss << " double num2 = " << GetBottom() << ";\n";
+#ifdef ISNAN
+ FormulaToken *iNum1 = vSubArguments[0]->GetFormulaToken();
+ const formula::SingleVectorRefToken* tmpCurDVRNum1=
+ dynamic_cast<const formula::SingleVectorRefToken *>(iNum1);
+ FormulaToken *iNum2 = vSubArguments[1]->GetFormulaToken();
+ const formula::SingleVectorRefToken* tmpCurDVRNum2=
+ dynamic_cast<const formula::SingleVectorRefToken *>(iNum2);
+ ss << " int buffer_num1_len = " << tmpCurDVRNum1->GetArrayLength() << ";\n";
+ ss << " int buffer_num2_len = " << tmpCurDVRNum2->GetArrayLength() << ";\n";
+
+ ss << " if((gid0)>=buffer_num1_len || isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << "))\n";
+ ss << " num1 = " << GetBottom() << ";\n";
+ ss << " else\n ";
+#endif
+ ss << " num1 = floor(" << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ");\n";
+#ifdef ISNAN
+ ss << " if((gid0)>=buffer_num2_len || isNan(";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n";
+ ss << " num2 = " << GetBottom() << ";\n";
+ ss << " else\n ";
+#endif
+ ss << " num2 = floor(" << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << ");\n";
+ ss << " return (long)num1 ^ (long)num2;\n";
+ ss << "}";
+}
void OpBitLshift::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 c794e4a..b6d2432 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -175,6 +175,13 @@ public:
virtual std::string GetBottom(void) { return "0.0"; }
virtual std::string BinFuncName(void) const { return "ScBitOr"; }
};
+class OpBitXor: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 "ScBitXor"; }
+};
class OpBitLshift:public Normal{
public:
virtual void GenSlidingWindowFunction(std::stringstream &ss,
commit 45b05b4edc19b0d693ca42fa64b276bbfca0a3da
Author: yangzhang <yangzhang at multicorewareinc.com>
Date: Sun Nov 10 10:07:46 2013 +0800
GPU Calc: unit test cases for BITRSHFIT
Need to enable NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-168 BUG
Change-Id: Id7c8b783b44915b4410bba500e520ff48b9f3a1f
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/BitRshift.ods b/sc/qa/unit/data/ods/opencl/math/BitRshift.ods
new file mode 100644
index 0000000..f1039df
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/BitRshift.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 5a10ec7..ffdb01a 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -211,6 +211,7 @@ public:
void testMathFormulaArcTan2();
void testMathFormulaBitOr();
void testMathFormulaBitLshift();
+ void testMathFormulaBitRshift();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -351,6 +352,7 @@ public:
CPPUNIT_TEST(testMathFormulaArcTan2);
CPPUNIT_TEST(testMathFormulaBitOr);
CPPUNIT_TEST(testMathFormulaBitLshift);
+ CPPUNIT_TEST(testMathFormulaBitRshift);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3792,6 +3794,29 @@ void ScOpenclTest::testMathFormulaBitLshift()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-168]
+void ScOpenclTest::testMathFormulaBitRshift()
+{
+ if (!detectOpenCLDevice())
+ return;
+ ScDocShellRef xDocSh = loadDoc("opencl/math/BitRshift.", ODS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes = loadDoc("opencl/math/BitRshift.", ODS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ // Verify BitRshift Function
+ for (SCROW i = 1; i <= 20; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(2,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(2,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
//[AMLOEXT-169]
void ScOpenclTest::testMathFormulaFloor()
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index c1c9e89..f0d2d7c 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1441,6 +1441,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocArcTan2:
case ocBitOr:
case ocBitLshift:
+ case ocBitRshift:
// Don't change the state.
break;
default:
commit e3d95705a1199f728f2bfa13d4a6c86cbd1940ef
Author: yangzhang <yangzhang at multicorewareinc.com>
Date: Sun Nov 10 10:11:40 2013 +0800
GPU Calc: implemented BITRSHFIT
AMLOEXT-168 FIX
Change-Id: I5596ea32861eeb7eb36d9800d410ebada0721745
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 1879109..dc9c7c2 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1317,6 +1317,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpBitLshift));
break;
+ case ocBitRshift:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpBitRshift));
+ 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 1ca61bb..59d2f66 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1466,7 +1466,52 @@ void OpBitLshift::GenSlidingWindowFunction(std::stringstream &ss,
ss << "num / pow(2.0, fabs(shift_amount)));\n";
ss << "}";
}
+void OpBitRshift::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 num = " << GetBottom() << ";\n";
+ ss << " double shift_amount = " << GetBottom() << ";\n";
+#ifdef ISNAN
+ FormulaToken *iNum = vSubArguments[0]->GetFormulaToken();
+ const formula::SingleVectorRefToken* tmpCurDVRNum=
+ dynamic_cast<const formula::SingleVectorRefToken*>(iNum);
+ FormulaToken *iShiftAmount = vSubArguments[1]->GetFormulaToken();
+ const formula::SingleVectorRefToken* tmpCurDVRShiftAmount=
+ dynamic_cast<const formula::SingleVectorRefToken*>(iShiftAmount);
+ ss << " int buffer_num_len = ";
+ ss << tmpCurDVRNum->GetArrayLength() << ";\n";
+ ss << " int buffer_shift_amount_len = ";
+ ss << tmpCurDVRShiftAmount->GetArrayLength() << ";\n";
+ ss << " if((gid0)>=buffer_num_len || isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << "))\n";
+ ss << " num = " << GetBottom() << ";\n";
+ ss << " else\n ";
+#endif
+ ss << " num = floor(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ");\n";
+#ifdef ISNAN
+ ss << " if((gid0)>=buffer_shift_amount_len || isNan(";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n";
+ ss << " shift_amount = " <<GetBottom()<< ";\n";
+ ss << " else\n ";
+#endif
+ ss << " shift_amount = floor(";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ");\n";
+ ss << " return floor(";
+ ss << "shift_amount >= 0 ? num / pow(2.0, shift_amount) : ";
+ ss << "num * pow(2.0, fabs(shift_amount)));\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 33cc6a2..c794e4a 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -182,6 +182,13 @@ public:
virtual std::string GetBottom(void) { return "0.0"; }
virtual std::string BinFuncName(void) const { return "ScBitLshift"; }
};
+class OpBitRshift: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 "ScBitRshift"; }
+};
class OpLn: public CheckVariables
{
public:
commit 478f0f10adb3df3deeef6fdba72d9d0507c26f49
Author: yangzhang <yangzhang at multicorewareinc.com>
Date: Sun Nov 10 09:52:22 2013 +0800
GPU Calc: unit test cases for BITLSHFIT
Need to turn on NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-167 BUG
Change-Id: Id20ca1ee503f593460b99d9701c77c5c63d9d845
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/BitLshift.ods b/sc/qa/unit/data/ods/opencl/math/BitLshift.ods
new file mode 100644
index 0000000..e1ebd4a
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/BitLshift.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 38d3c1b..5a10ec7 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -210,6 +210,7 @@ public:
void testStatisticalFormulaSkew();
void testMathFormulaArcTan2();
void testMathFormulaBitOr();
+ void testMathFormulaBitLshift();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -349,6 +350,7 @@ public:
CPPUNIT_TEST(testStatisticalFormulaSkew);
CPPUNIT_TEST(testMathFormulaArcTan2);
CPPUNIT_TEST(testMathFormulaBitOr);
+ CPPUNIT_TEST(testMathFormulaBitLshift);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3767,6 +3769,29 @@ void ScOpenclTest::testStatisticalFormulaChiDist()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-167]
+void ScOpenclTest::testMathFormulaBitLshift()
+{
+ if (!detectOpenCLDevice())
+ return;
+ ScDocShellRef xDocSh = loadDoc("opencl/math/BitLshift.", ODS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes = loadDoc("opencl/math/BitLshift.", ODS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ // Verify BitLshift Function
+ for (SCROW i = 1; i <= 20; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(2,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(2,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
//[AMLOEXT-169]
void ScOpenclTest::testMathFormulaFloor()
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 0f22c97..c1c9e89 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1440,6 +1440,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocSchiefe:
case ocArcTan2:
case ocBitOr:
+ case ocBitLshift:
// Don't change the state.
break;
default:
commit ab030018c28f9475e48066e9802e711beca6118b
Author: yangzhang <yangzhang at multicorewareinc.com>
Date: Sun Nov 10 10:02:00 2013 +0800
GPU Calc: implemented BITLSHFIT
AMLOEXT-167 FIX
Change-Id: Ia91542a64c44d541114fee3c3655120d0350a286
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 64329b0..1879109 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1313,6 +1313,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpBitOr));
break;
+ case ocBitLshift:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpBitLshift));
+ 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 185d67d..1ca61bb 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1422,7 +1422,50 @@ void OpBitOr::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return (long)num1 | (long)num2;\n";
ss << "}";
}
-
+void OpBitLshift::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 num = " << GetBottom() << ";\n";
+ ss << " double shift_amount = " << GetBottom() << ";\n";
+#ifdef ISNAN
+ FormulaToken *iNum = vSubArguments[0]->GetFormulaToken();
+ const formula::SingleVectorRefToken* tmpCurDVRNum=
+ dynamic_cast<const formula::SingleVectorRefToken*>(iNum);
+ FormulaToken *iShiftAmount = vSubArguments[1]->GetFormulaToken();
+ const formula::SingleVectorRefToken* tmpCurDVRShiftAmount=
+ dynamic_cast<const formula::SingleVectorRefToken*>(iShiftAmount);
+ ss << " int buffer_num_len = "<< tmpCurDVRNum->GetArrayLength()<<";\n";
+ ss << " int buffer_shift_amount_len = ";
+ ss << tmpCurDVRShiftAmount->GetArrayLength() << ";\n";
+ ss << " if((gid0)>=buffer_num_len || isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << "))\n";
+ ss << " num = " << GetBottom() << ";\n";
+ ss << " else\n ";
+#endif
+ ss << " num = floor(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ");\n";
+#ifdef ISNAN
+ ss << " if((gid0)>=buffer_shift_amount_len || isNan(";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n";
+ ss << " shift_amount = " << GetBottom() << ";\n";
+ ss << " else\n ";
+#endif
+ ss << " shift_amount = floor(";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ");\n";
+ ss << " return floor(" << "shift_amount >= 0 ? ";
+ ss << "num * pow(2.0, shift_amount) : ";
+ ss << "num / pow(2.0, fabs(shift_amount)));\n";
+ ss << "}";
+}
}}
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index 20526d8..33cc6a2 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -175,6 +175,13 @@ public:
virtual std::string GetBottom(void) { return "0.0"; }
virtual std::string BinFuncName(void) const { return "ScBitOr"; }
};
+class OpBitLshift: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 "ScBitLshift"; }
+};
class OpLn: public CheckVariables
{
public:
commit 97e4c96355d45dccc7b23d6581653baf68b2f701
Author: yangzhang <yangzhang at multicorewareinc.com>
Date: Sun Nov 10 09:29:12 2013 +0800
GPU Calc: unit test cases for BITOR
Need to turn on NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-152 BUG
Change-Id: Id29e7854452f93bdaf38490f484dea5af218bd56
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/BitOr.ods b/sc/qa/unit/data/ods/opencl/math/BitOr.ods
new file mode 100644
index 0000000..517dcc1
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/BitOr.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 084063f..38d3c1b 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -209,6 +209,7 @@ public:
void testMathFormulaTrunc();
void testStatisticalFormulaSkew();
void testMathFormulaArcTan2();
+ void testMathFormulaBitOr();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -347,6 +348,7 @@ public:
CPPUNIT_TEST(testMathFormulaTrunc);
CPPUNIT_TEST(testStatisticalFormulaSkew);
CPPUNIT_TEST(testMathFormulaArcTan2);
+ CPPUNIT_TEST(testMathFormulaBitOr);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3419,6 +3421,32 @@ void ScOpenclTest::testStatisticalFormulaExpondist()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-152]
+void ScOpenclTest::testMathFormulaBitOr()
+{
+ if (!detectOpenCLDevice())
+ return;
+ ScDocShellRef xDocSh =
+ loadDoc("opencl/math/BitOr.", ODS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes =
+ loadDoc("opencl/math/BitOr.", ODS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ // Verify BitOr Function
+ for (SCROW i = 1; i <= 20; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(2,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(2,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, fabs(0.0001*fExcel));
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
+
//[AMLOEXT-153]
void ScOpenclTest::testMathFormulaOdd()
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 4d85db0..0f22c97 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1439,6 +1439,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocTrunc:
case ocSchiefe:
case ocArcTan2:
+ case ocBitOr:
// Don't change the state.
break;
default:
commit 125f77db17628aa0cf1704665b285a38c4c2a9a0
Author: yangzhang <yangzhang at multicorewareinc.com>
Date: Sun Nov 10 09:38:30 2013 +0800
GPU Calc: implemented BITOR
AMLOEXT-152 FIX
Change-Id: I52747c3b2535e9bba3d167305a3ec5488a23411f
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 2190fd0..64329b0 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1309,6 +1309,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpArcTan2));
break;
+ case ocBitOr:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpBitOr));
+ 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 ae13159..185d67d 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1381,7 +1381,47 @@ void OpFloor::GenSlidingWindowFunction(
ss <<" return trunc(arg0/arg1)*arg1;\n";
ss << "}\n";
}
-
+void OpBitOr::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 num1 = " << GetBottom() << ";\n";
+ ss << " double num2 = " << GetBottom() << ";\n";
+#ifdef ISNAN
+ FormulaToken *iNum1 = vSubArguments[0]->GetFormulaToken();
+ const formula::SingleVectorRefToken* tmpCurDVRNum1=
+ dynamic_cast<const formula::SingleVectorRefToken *>(iNum1);
+ FormulaToken *iNum2 = vSubArguments[1]->GetFormulaToken();
+ const formula::SingleVectorRefToken* tmpCurDVRNum2=
+ dynamic_cast<const formula::SingleVectorRefToken *>(iNum2);
+ ss << " int buffer_num1_len = "<<tmpCurDVRNum1->GetArrayLength()<<";\n";
+ ss << " int buffer_num2_len = "<<tmpCurDVRNum2->GetArrayLength()<<";\n";
+ ss << " if((gid0)>=buffer_num1_len || isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << "))\n";
+ ss << " num1 = " << GetBottom() << ";\n";
+ ss << " else \n ";
+#endif
+ ss << " num1 = floor(" << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ");\n";
+#ifdef ISNAN
+ ss << " if((gid0)>=buffer_num2_len || isNan(";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n";
+ ss << " num2 = " << GetBottom() << ";\n";
+ ss << " else\n ";
+#endif
+ ss << " num2 = floor(" << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << ");\n";
+ ss << " return (long)num1 | (long)num2;\n";
+ ss << "}";
+}
}}
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index 71cb279..20526d8 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -168,6 +168,13 @@ public:
virtual std::string GetBottom(void) { return "0.0"; }
virtual std::string BinFuncName(void) const { return "ScBitAnd"; }
};
+class OpBitOr: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 "ScBitOr"; }
+};
class OpLn: public CheckVariables
{
public:
commit 28b7754c30a5d747174eaa334a951acf5420bd97
Author: yangzhang <yangzhang at multicorewareinc.com>
Date: Sun Nov 10 09:20:22 2013 +0800
GPU Calc: unit test cases for ATAN2
Need to turn on NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-174 BUG
Change-Id: I83e5d89079eb8f1dd315d23888e4d7058f48bcae
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/ArcTan2.ods b/sc/qa/unit/data/ods/opencl/math/ArcTan2.ods
new file mode 100644
index 0000000..89f6bc5
Binary files /dev/null and b/sc/qa/unit/data/ods/opencl/math/ArcTan2.ods differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 7601696..084063f 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -208,6 +208,7 @@ public:
void testMathFormulaMod();
void testMathFormulaTrunc();
void testStatisticalFormulaSkew();
+ void testMathFormulaArcTan2();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -345,6 +346,7 @@ public:
CPPUNIT_TEST(testMathFormulaMod);
CPPUNIT_TEST(testMathFormulaTrunc);
CPPUNIT_TEST(testStatisticalFormulaSkew);
+ CPPUNIT_TEST(testMathFormulaArcTan2);
CPPUNIT_TEST_SUITE_END();
private:
@@ -3319,6 +3321,33 @@ void ScOpenclTest:: testFinacialNPER1Formula()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-147]
+void ScOpenclTest::testMathFormulaArcTan2()
+{
+ if (!detectOpenCLDevice())
+ return;
+ ScDocShellRef xDocSh =
+ loadDoc("opencl/math/ArcTan2.", ODS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+ ScDocShellRef xDocShRes =
+ loadDoc("opencl/math/ArcTan2.", ODS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ // Verify ATan2 Function
+ for (SCROW i = 1; i <= 17; ++i)
+ {
+ double fLibre = pDoc->GetValue(ScAddress(2,i,0));
+ double fExcel = pDocRes->GetValue(ScAddress(2,i,0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(fExcel, fLibre, 0.000001);
+ }
+ xDocSh->DoClose();
+ xDocShRes->DoClose();
+}
+
+
//[AMLOEXT-148]
void ScOpenclTest::testStatisticalFormulaChiSqInv()
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index 94a4ff0..4d85db0 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1438,6 +1438,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocMod:
case ocTrunc:
case ocSchiefe:
+ case ocArcTan2:
// Don't change the state.
break;
default:
commit 7ad126a917f062d91a5fd49e27f0ad0cacd807b7
Author: yangzhang <yangzhang at multicorewareinc.com>
Date: Sun Nov 10 09:23:34 2013 +0800
GPU Calc: implemented ATAN2
AMLOEXT-174 FIX
Change-Id: I1dcff6d785c10fbc72f70bd0fc95f73859ef8452
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 74d2e37..2190fd0 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1305,6 +1305,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpSkew));
break;
+ case ocArcTan2:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpArcTan2));
+ 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 eb49a6b..ae13159 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1037,6 +1037,45 @@ void OpArcSinHyp::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return asinh(tmp);\n";
ss << "}";
}
+void OpArcTan2::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 x_num = " << GetBottom() << ";\n";
+ ss << " double y_num = " << GetBottom() << ";\n";
+#ifdef ISNAN
+ FormulaToken *iXNum = vSubArguments[0]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVRX=
+ dynamic_cast<const formula::SingleVectorRefToken *>(iXNum);
+ FormulaToken *iYNum = vSubArguments[1]->GetFormulaToken();
+ const formula::SingleVectorRefToken*tmpCurDVRY=
+ dynamic_cast<const formula::SingleVectorRefToken *>(iYNum);
+ ss << " int buffer_x_len = " << tmpCurDVRX->GetArrayLength() << ";\n";
+ ss << " int buffer_y_len = " << tmpCurDVRY->GetArrayLength() << ";\n";
+ ss << " if((gid0)>=buffer_x_len || isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << "))\n";
+ ss << " x_num = " << GetBottom() << ";\n";
+ ss << " else \n ";
+#endif
+ ss << " x_num = "<< vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef ISNAN
+ ss << " if((gid0)>=buffer_y_len || isNan(";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n";
+ ss << " y_num = " << GetBottom() << ";\n";
+ ss << " else \n ";
+#endif
+ ss << " y_num = "<< vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " return atan2(y_num, x_num);\n";
+ ss << "}";
+}
void OpArcTan::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 7d7a740..71cb279 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -140,6 +140,13 @@ public:
virtual std::string BinFuncName(void) const { return "Trunc"; }
};
+class OpArcTan2: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 "ScATan2"; }
+};
class OpArcTan:public Normal{
public:
virtual void GenSlidingWindowFunction(std::stringstream &ss,
commit c4880f2ad2d33ad02faa361a55900350f298a59b
Author: fengzeng <fengzeng at multicorewareinc.com>
Date: Sun Nov 10 08:38:49 2013 +0800
GPU Calc: unit test cases for SKEW
Need to turn on NO_FALLBACK_TO_SWINTERP in formulagroupcl.cxx for test
AMLOEXT-80 BUG
Change-Id: I639318c1f431d7ed728d68e6b1ef66c2cac1b32f
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/statistical/Skew.xls b/sc/qa/unit/data/xls/opencl/statistical/Skew.xls
new file mode 100644
index 0000000..1a58309
Binary files /dev/null and b/sc/qa/unit/data/xls/opencl/statistical/Skew.xls differ
diff --git a/sc/qa/unit/opencl-test.cxx b/sc/qa/unit/opencl-test.cxx
index 7a9c6d2..7601696 100644
--- a/sc/qa/unit/opencl-test.cxx
+++ b/sc/qa/unit/opencl-test.cxx
@@ -207,6 +207,7 @@ public:
void testMathFormulaLog();
void testMathFormulaMod();
void testMathFormulaTrunc();
+ void testStatisticalFormulaSkew();
CPPUNIT_TEST_SUITE(ScOpenclTest);
CPPUNIT_TEST(testSharedFormulaXLS);
CPPUNIT_TEST(testFinacialFormula);
@@ -343,6 +344,7 @@ public:
CPPUNIT_TEST(testMathFormulaLog);
CPPUNIT_TEST(testMathFormulaMod);
CPPUNIT_TEST(testMathFormulaTrunc);
+ CPPUNIT_TEST(testStatisticalFormulaSkew);
CPPUNIT_TEST_SUITE_END();
private:
@@ -1678,6 +1680,31 @@ void ScOpenclTest::testStatisticalFormulaVar()
xDocSh->DoClose();
xDocShRes->DoClose();
}
+//[AMLOEXT-80]
+void ScOpenclTest::testStatisticalFormulaSkew()
+{
+ if (!detectOpenCLDevice())
+ return;
+
+ ScDocShellRef xDocSh = loadDoc("opencl/statistical/Skew.", XLS);
+ ScDocument* pDoc = xDocSh->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+ enableOpenCL();
+ pDoc->CalcAll();
+
+ ScDocShellRef xDocShRes = loadDoc("opencl/statistical/Skew.", XLS);
+ ScDocument* pDocRes = xDocShRes->GetDocument();
+ CPPUNIT_ASSERT(pDocRes);
+ // Check the results of formula cells in the shared formula range.
+ for (SCROW i = 1; i <= 20; ++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-82]
void ScOpenclTest::testStatisticalFormulaPearson()
{
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index f065e83..94a4ff0 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1437,6 +1437,7 @@ void ScTokenArray::CheckToken( const FormulaToken& r )
case ocLog:
case ocMod:
case ocTrunc:
+ case ocSchiefe:
// Don't change the state.
break;
default:
commit ed44807e6962fd3db8f8cca7b47aad65edf02ed6
Author: fengzeng <fengzeng at multicorewareinc.com>
Date: Sun Nov 10 09:03:29 2013 +0800
GPU Calc: implemented for SKEW
AMLOEXT-80 FIX
Change-Id: I22131ff7688237c7cb77335d6a8cadd4e40ff78d
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 7a59504f..74d2e37 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1301,6 +1301,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpTrunc));
break;
+ case ocSchiefe:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpSkew));
+ break;
case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getEffect"))))
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index a686e5d..636afd0 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -671,7 +671,346 @@ void OpWeibull::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return tmp;\n";
ss << "}\n";
}
+void OpSkew::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 fSum = 0.0;\n";
+ ss << " double fMean = 0.0;\n";
+ ss << " double vSum = 0.0;\n";
+ ss << " double fCount = 0.0;\n";
+ ss << " double arg = 0.0;\n";
+ unsigned i = vSubArguments.size();
+ while (i--)
+ {
+ FormulaToken* pCur = vSubArguments[i]->GetFormulaToken();
+ assert(pCur);
+ if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
+ {
+ if (pCur->GetType() == formula::svDoubleVectorRef)
+ {
+ const formula::DoubleVectorRefToken* pDVR =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+ size_t nCurWindowSize = pDVR->GetRefRowSize();
+ ss << " for (int i = ";
+ if (!pDVR->IsStartFixed() && pDVR->IsEndFixed())
+ {
+#ifdef ISNAN
+ ss << "gid0; i < " << pDVR->GetArrayLength();
+ ss << " && i < " << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+ else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+ {
+#ifdef ISNAN
+ ss << "0; i < " << pDVR->GetArrayLength();
+ ss << " && i < gid0+"<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+ else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+ {
+#ifdef ISNAN
+ ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+ ss << " && i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+ else
+ {
+#ifdef ISNAN
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+
+ ss << " arg = ";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef ISNAN
+ ss << " if (isNan(arg))\n";
+ ss << " continue;\n";
+#endif
+ ss << " fSum += arg;\n";
+ ss << " fCount += 1;\n";
+ ss << " }\n";
+ }
+ else if (pCur->GetType() == formula::svSingleVectorRef)
+ {
+ const formula::SingleVectorRefToken* pSVR =
+ dynamic_cast< const formula::SingleVectorRefToken* >(pCur);
+ assert(pSVR);
+#ifdef ISNAN
+ ss << " if (gid0 < " << pSVR->GetArrayLength() << ")\n";
+ ss << " {\n";
+ ss << " if (!isNan(";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef() << "))\n";
+ ss << " {\n";
+#endif
+ ss << " arg=";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " fSum += arg;\n";
+ ss << " fCount += 1;\n";
+#ifdef ISNAN
+ ss << " }\n";
+ ss << " }\n";
+#endif
+ }
+ else
+ {
+ ss << " arg=" << pCur->GetDouble() << ";\n";
+ ss << " fSum += arg;\n";
+ ss << " fCount += 1;\n";
+ }
+ }
+ else
+ {
+ ss << " arg=";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " fSum += arg;\n";
+ ss << " fCount += 1;\n";
+ }
+
+ if(i == 0)
+ {
+ ss << " if(fCount <= 2)\n";
+ ss << " return 0;\n";
+ ss << " else\n";
+ ss << " fMean = fSum / " << "fCount" << ";\n";
+ }
+ }
+ i = vSubArguments.size();
+ while (i--)
+ {
+ FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
+ assert(pCur);
+ if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
+ {
+ if (pCur->GetType() == formula::svDoubleVectorRef)
+ {
+ const formula::DoubleVectorRefToken* pDVR =
+ dynamic_cast<const formula::DoubleVectorRefToken *>(pCur);
+ size_t nCurWindowSize = pDVR->GetRefRowSize();
+ ss << " for (int i = ";
+ if (!pDVR->IsStartFixed() && pDVR->IsEndFixed())
+ {
+#ifdef ISNAN
+ ss << "gid0; i < " << pDVR->GetArrayLength();
+ ss << " && i < " << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "gid0; i < "<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+ else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+ {
+#ifdef ISNAN
+ ss << "0; i < " << pDVR->GetArrayLength();
+ ss << " && i < gid0+"<< nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < gid0+"<< nCurWindowSize << "; i++)\n";
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list