[Libreoffice-commits] core.git: 11 commits - sc/source
haochen
haochen at multicorewareinc.com
Mon May 19 00:17:17 PDT 2014
sc/source/core/opencl/formulagroupcl.cxx | 31 -
sc/source/core/opencl/op_addin.cxx | 65 ++
sc/source/core/opencl/op_addin.hxx | 7
sc/source/core/opencl/op_financial.cxx | 74 +-
sc/source/core/opencl/op_logical.cxx | 7
sc/source/core/opencl/op_math.cxx | 212 ++++---
sc/source/core/opencl/op_statistical.cxx | 844 +++++++++++++++----------------
sc/source/core/opencl/opbase.cxx | 4
sc/source/core/opencl/opencl_device.cxx | 18
9 files changed, 680 insertions(+), 582 deletions(-)
New commits:
commit 86cac77fc143b85452c22b2ca06810696a0d15ed
Author: haochen <haochen at multicorewareinc.com>
Date: Mon May 19 14:57:15 2014 +0800
GPU Calc:Fixed compiling warning in opbase.cxx&op_math.cxx
Change-Id: I885bf77a85f7f479a8a9632e64af306be243cdd0
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 2be3146..c2a20eb 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -990,8 +990,6 @@ void OpSinh::GenSlidingWindowFunction(std::stringstream &ss,
const std::string &sSymName, SubArguments &vSubArguments)
{
FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
- static_cast<const
- formula::SingleVectorRefToken *>(tmpCur);
ss << "\ndouble " << sSymName;
ss << "_"<< BinFuncName() <<"(";
for (unsigned i = 0; i < vSubArguments.size(); i++)
diff --git a/sc/source/core/opencl/opbase.cxx b/sc/source/core/opencl/opbase.cxx
index 6bc5214..dfda160 100644
--- a/sc/source/core/opencl/opbase.cxx
+++ b/sc/source/core/opencl/opbase.cxx
@@ -42,7 +42,7 @@ VectorRef::VectorRef(const std::string &s, FormulaTreeNodeRef ft, int idx):
VectorRef::~VectorRef()
{
if (mpClmem) {
- cl_int ret = clReleaseMemObject(mpClmem);
+ clReleaseMemObject(mpClmem);
}
}
commit 2b0a05c7b0eeec7fc75fa80e57c51d5142446e67
Author: haochen <haochen at multicorewareinc.com>
Date: Tue May 13 10:29:11 2014 +0800
GPU Calc: Fix bug
For arraybound of slidingwindows parameters in COVAR formula
Change-Id: I17a601edfbc720d4e3e40fc31bf6efd73b4ac65b
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index c64588a..88541e2 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -8067,21 +8067,31 @@ void OpCovar::GenSlidingWindowFunction(std::stringstream& ss,
size_t nCurWindowSizeY = pCurDVRY->GetRefRowSize();
if(nCurWindowSizeX == nCurWindowSizeY)
{
- ss << " for(int i = ";
+ ss << " for( ";
if (!pCurDVRX->IsStartFixed() && pCurDVRX->IsEndFixed()) {
- ss << "gid0; i < " << nCurWindowSizeX << "; i++) {\n";
- ss << " arg0 = ";
- ss << vSubArguments[0]->GenSlidingWindowDeclRef()<< ";\n";
- ss << " arg1 = ";
- ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
-#ifdef ISNAN
- ss << " if(isNan(arg0) || isNan(arg1) || (i >= ";
- ss << pCurDVRX->GetArrayLength() << ") || (i >=";
- ss << pCurDVRY->GetArrayLength() << ")) {\n";
+ ss << "int i = gid0; i < " << nCurWindowSizeX;
+ ss << " && i < " << pCurDVRX->GetArrayLength() << " && i < ";
+ ss << pCurDVRY->GetArrayLength() << "; i++){\n";
+#ifdef ISNAN
+ ss << " if(isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ") ||";
+ ss << " isNan("<< vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << ")) {\n";
ss << " arg0 = 0.0;\n";
ss << " arg1 = 0.0;\n";
ss << " --cnt;\n";
ss << " }\n";
+ ss << "else{\n";
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " arg1 = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+ ss << "}\n";
+#else
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " arg1 = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
#endif
ss << " ++cnt;\n";
ss << " vSum0 += arg0;\n";
@@ -8089,19 +8099,28 @@ void OpCovar::GenSlidingWindowFunction(std::stringstream& ss,
ss << " }\n";
}
else if (pCurDVRX->IsStartFixed() && !pCurDVRX->IsEndFixed()) {
- ss << "0; i < gid0 + " << nCurWindowSizeX << "; i++) {\n";
- ss << " arg0 = ";
- ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
- ss << " arg1 = ";
- ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+ ss << "int i = 0; i < gid0 + " << nCurWindowSizeX << " && ";
+ ss << " i < " << pCurDVRX->GetArrayLength() << " && ";
+ ss << " i < " << pCurDVRY->GetArrayLength() << "; i++) {\n";
#ifdef ISNAN
- ss << " if(isNan(arg0) || isNan(arg1) || (i >= ";
- ss << pCurDVRX->GetArrayLength() << ") || (i >=";
- ss << pCurDVRY->GetArrayLength() << ")) {\n";
+ ss << " if(isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ") ||";
+ ss << " isNan(" << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << ")) {\n";
ss << " arg0 = 0.0;\n";
ss << " arg1 = 0.0;\n";
ss << " --cnt;\n";
ss << " }\n";
+ ss << "else{\n";
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " arg1 = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";}\n";
+#else
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef()<< ";\n";
+ ss << " arg1 = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
#endif
ss << " ++cnt;\n";
ss << " vSum0 += arg0;\n";
@@ -8109,19 +8128,28 @@ void OpCovar::GenSlidingWindowFunction(std::stringstream& ss,
ss << " }\n";
}
else if (pCurDVRX->IsStartFixed() && pCurDVRX->IsEndFixed()) {
- ss << "0; i < " << nCurWindowSizeX << "; i++) {\n";
- ss << " arg0 = ";
- ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
- ss << " arg1 = ";
- ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+ ss << "int i = 0; i < " << nCurWindowSizeX << " && i < ";
+ ss << pCurDVRX->GetArrayLength() << " && i < ";
+ ss << pCurDVRY->GetArrayLength() << "; i++) {\n";
#ifdef ISNAN
- ss << " if(isNan(arg0) || isNan(arg1) || (i >= ";
- ss << pCurDVRX->GetArrayLength() << ") || (i >=";
- ss << pCurDVRY->GetArrayLength() << ")) {\n";
+ ss << " if(isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ") ||";
+ ss << " isNan(" << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << ")) {\n";
ss << " arg0 = 0.0;\n";
ss << " arg1 = 0.0;\n";
ss << " --cnt;\n";
ss << " }\n";
+ ss << "else{\n";
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " arg1 = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";}\n";
+#else
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " arg1 = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
#endif
ss << " ++cnt;\n";
ss << " vSum0 += arg0;\n";
@@ -8129,19 +8157,30 @@ void OpCovar::GenSlidingWindowFunction(std::stringstream& ss,
ss << " }\n";
}
else {
- ss << "0; i < " << nCurWindowSizeX << "; i++) {\n";
- ss << " arg0 = ";
- ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
- ss << " arg1 = ";
- ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+ ss << "int i = 0; i < " << nCurWindowSizeX << " && ";
+ ss << " i + gid0 < " << pCurDVRX->GetArrayLength();
+ ss << " && i + gid0 < " << pCurDVRX->GetArrayLength();
+ ss << "; i++) {\n";
#ifdef ISNAN
- ss << " if(isNan(arg0) || isNan(arg1) || (i + gid0 >= ";
- ss << pCurDVRX->GetArrayLength() << ") || (i + gid0 >=";
- ss << pCurDVRY->GetArrayLength() << ")) {\n";
+ ss << "if ((isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ")) || ";
+ ss << "(isNan("<< vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << "))) {\n";
ss << " arg0 = 0.0;\n";
ss << " arg1 = 0.0;\n";
ss << " --cnt;\n";
ss << " }\n";
+ ss << " else {\n";
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " arg1 = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " }\n";
+#else
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " arg1 = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
#endif
ss << " ++cnt;\n";
ss << " vSum0 += arg0;\n";
@@ -8154,68 +8193,109 @@ void OpCovar::GenSlidingWindowFunction(std::stringstream& ss,
ss << " else {\n";
ss << " vMean0 = vSum0 / cnt;\n";
ss << " vMean1 = vSum1 / cnt;\n";
- ss << " for(int i = ";
+ ss << " for(";
if (!pCurDVRX->IsStartFixed() && pCurDVRX->IsEndFixed()) {
- ss << "gid0; i < " << nCurWindowSizeX << "; i++) {\n";
- ss << "arg0 = " << vSubArguments[0]->GenSlidingWindowDeclRef()
- << ";\n";
- ss << "arg1 = " << vSubArguments[1]->GenSlidingWindowDeclRef()
- << ";\n";
+ ss << "int i = gid0; i < " << nCurWindowSizeX;
+ ss << " && i < " << pCurDVRX->GetArrayLength() << " && i < ";
+ ss << pCurDVRY->GetArrayLength() << "; i++){\n";
#ifdef ISNAN
- ss << " if(isNan(arg0) || isNan(arg1) || (i >= ";
- ss << pCurDVRX->GetArrayLength() << ") || (i >=";
- ss << pCurDVRY->GetArrayLength() << ")) {\n";
+ ss << " if(isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ") ||";
+ ss << " isNan(" << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << ")){\n";
ss << " arg0 = vMean0;\n";
ss << " arg1 = vMean1;\n";
ss << " }\n";
-#endif
- ss << " vSum += (arg0 - vMean0) * (arg1 - vMean1);\n";
- ss << " }\n";
- } else if (pCurDVRX->IsStartFixed() && !pCurDVRX->IsEndFixed()) {
- ss << "0; i < gid0 + " << nCurWindowSizeX << "; i++) {\n";
+ ss << " else{\n";
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " arg1 = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";}\n";
+#else
ss << " arg0 = ";
ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
ss << " arg1 = ";
ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+#endif
+ ss << " vSum += (arg0 - vMean0) * (arg1 - vMean1);\n";
+ ss << " }\n";
+ }
+ else if (pCurDVRX->IsStartFixed() && !pCurDVRX->IsEndFixed()) {
+ ss << "int i = 0; i < gid0 + " << nCurWindowSizeX << " && ";
+ ss << " i < " << pCurDVRX->GetArrayLength() << " && ";
+ ss << " i < " << pCurDVRY->GetArrayLength() << "; i++) {\n";
#ifdef ISNAN
- ss << " if(isNan(arg0) || isNan(arg1) || (i >= ";
- ss << pCurDVRX->GetArrayLength() << ") || (i >=";
- ss << pCurDVRY->GetArrayLength() << ")) {\n";
+ ss << " if(isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ") || ";
+ ss << "isNan(" << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << ")) {\n";
ss << " arg0 = vMean0;\n";
ss << " arg1 = vMean1;\n";
ss << " }\n";
-#endif
- ss << " vSum += (arg0 - vMean0) * (arg1 - vMean1);\n";
- ss << " }\n";
- } else if (pCurDVRX->IsStartFixed() && pCurDVRX->IsEndFixed()) {
- ss << "0; i < " << nCurWindowSizeX << "; i++) {\n";
+ ss << "else{\n";
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " arg1 = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";}\n";
+#else
ss << " arg0 = ";
ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
ss << " arg1 = ";
ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+#endif
+ ss << " vSum += (arg0 - vMean0) * (arg1 - vMean1);\n";
+ ss << " }\n";
+ }
+ else if (pCurDVRX->IsStartFixed() && pCurDVRX->IsEndFixed()) {
+ ss << "int i = 0; i < " << nCurWindowSizeX << " && i < ";
+ ss << pCurDVRX->GetArrayLength() << " && i < ";
+ ss << pCurDVRY->GetArrayLength() << "; i++) {\n";
#ifdef ISNAN
- ss << " if(isNan(arg0) || isNan(arg1) || (i >= ";
- ss << pCurDVRX->GetArrayLength() << ") || (i >=";
- ss << pCurDVRY->GetArrayLength() << ")) {\n";
+ ss << " if(isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ") || ";
+ ss << "isNan(" << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << ")) {\n";
ss << " arg0 = vMean0;\n";
ss << " arg1 = vMean1;\n";
ss << " }\n";
-#endif
- ss << " vSum += (arg0 - vMean0) * (arg1 - vMean1);\n";
- ss << " }\n";
- } else {
- ss << "0; i < " << nCurWindowSizeX << "; i++) {\n";
+ ss << "else{\n";
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " arg1 = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";}\n";
+#else
ss << " arg0 = ";
ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
ss << " arg1 = ";
ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+#endif
+ ss << " vSum += (arg0 - vMean0) * (arg1 - vMean1);\n";
+ ss << " }\n";
+ }
+ else {
+ ss << "int i = 0; i < " << nCurWindowSizeX << " && ";
+ ss << " i + gid0 < " << pCurDVRX->GetArrayLength();
+ ss << " && i + gid0 < " << pCurDVRX->GetArrayLength();
+ ss << "; i++) {\n";
#ifdef ISNAN
- ss << " if(isNan(arg0) || isNan(arg1) || (i + gid0 >= ";
- ss << pCurDVRX->GetArrayLength() << ") || (i + gid0 >= ";
- ss << pCurDVRY->GetArrayLength() << ")) {\n";
+ ss << "if((isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ")) || ";
+ ss << "(isNan(" << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << "))) {\n";
ss << " arg0 = vMean0;\n";
ss << " arg1 = vMean1;\n";
ss << " }\n";
+ ss << " else{\n";
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " arg1 = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " }\n";
+#else
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef()<< ";\n";
+ ss << " arg1 = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
#endif
ss << " vSum += (arg0 - vMean0) * (arg1 - vMean1);\n";
ss << " }\n";
commit d72763ce095f0b879e5baa1713a934225ccb39f7
Author: haochen <haochen at multicorewareinc.com>
Date: Tue May 13 10:27:30 2014 +0800
GPU Calc: Fix bug
For arraybound of slidingwindows parameters in Intercept formula
Change-Id: I6c96073e859ef7550033e9a46e6cafb11e8bfe0a
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index 6dfe344..c64588a 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -5850,121 +5850,212 @@ void OpKurt:: GenSlidingWindowFunction(std::stringstream &ss,
void OpIntercept::GenSlidingWindowFunction(std::stringstream &ss,
const std::string &sSymName, SubArguments &vSubArguments)
{
- FormulaToken *pCur = vSubArguments[0]->GetFormulaToken();
- assert(pCur);
- const formula::DoubleVectorRefToken* pCurDVR =
- static_cast<const formula::DoubleVectorRefToken *>(pCur);
- size_t nCurWindowSize = pCurDVR->GetRefRowSize();
- FormulaToken *pCur1 = vSubArguments[1]->GetFormulaToken();
- assert(pCur1);
- const formula::DoubleVectorRefToken* pCurDVR1 =
- static_cast<const formula::DoubleVectorRefToken *>(pCur1);
- size_t nCurWindowSize1 = pCurDVR1->GetRefRowSize();
ss << "\ndouble " << sSymName;
- ss << "_"<< BinFuncName() <<"( ";
+ 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 fSumX = 0.0;\n";
ss << " double fSumY = 0.0;\n";
+ ss << " double fMeanX = 0.0;\n";
+ ss << " double fMeanY = 0.0;\n";
ss << " double fSumDeltaXDeltaY = 0.0;\n";
ss << " double fSumSqrDeltaX = 0.0;\n";
- ss << " int length="<<nCurWindowSize;
- ss << ";\n";
- ss << " int length1= "<<nCurWindowSize1;
- ss << ";\n";
- ss << " if(length!=length1)\n";
- ss << " return 0;\n";
- ss << " double tmp = 0;\n";
- for (unsigned i = 0; i < vSubArguments.size(); i++)
+ ss << " double fCount = 0.0;\n";
+ ss << " double argX = 0.0;\n";
+ ss << " double argY = 0.0;\n";
+ if(vSubArguments.size() != 2)
{
- pCur = vSubArguments[i]->GetFormulaToken();
- assert(pCur);
- if (pCur->GetType() == formula::svDoubleVectorRef)
- {
+ ss << " return NAN;\n";
+ ss << "}\n";
+ return ;
+ }
+ FormulaToken *pCur = vSubArguments[1]->GetFormulaToken();
+ FormulaToken *pCur1 = vSubArguments[0]->GetFormulaToken();
+ assert(pCur);
+ assert(pCur1);
+ if (pCur->GetType() == formula::svDoubleVectorRef&&
+ pCur1->GetType() == formula::svDoubleVectorRef)
+ {
+ const formula::DoubleVectorRefToken* pDVR =
+ static_cast<const formula::DoubleVectorRefToken *>(pCur);
+ const formula::DoubleVectorRefToken* pDVR1 =
+ static_cast<const formula::DoubleVectorRefToken *>(pCur1);
+ size_t nCurWindowSize = pDVR->GetRefRowSize();
+ size_t nCurWindowSize1 = pDVR1->GetRefRowSize();
+ size_t arrayLength = pDVR->GetArrayLength()<
+ pDVR1->GetArrayLength() ? pDVR->GetArrayLength():
+ pDVR1->GetArrayLength();
+ if(nCurWindowSize != nCurWindowSize1)
+ {
+ ss << " return NAN;\n";
+ ss << "}\n";
+ return ;
}
- else if (pCur->GetType() == formula::svSingleVectorRef)
+ ss << " for (int i = ";
+ if ((!pDVR->IsStartFixed() && pDVR->IsEndFixed())
+ &&(!pDVR1->IsStartFixed() && pDVR1->IsEndFixed()))
{
#ifdef ISNAN
- ss << "return HUGE_VAL";
+ ss << "gid0; i < " << arrayLength;
+ ss << " && i < " << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "gid0; i < " << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
#endif
}
- else if (pCur->GetType() == formula::svDouble)
+ else if ((pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+ &&(pDVR1->IsStartFixed() && !pDVR1->IsEndFixed()))
{
#ifdef ISNAN
- ss << "return HUGE_VAL";
+ ss << "0; i < " << arrayLength ;
+ ss << " && i < gid0+" << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < gid0+" << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
#endif
}
- }
- ss << " for (int i = 0; i <" << nCurWindowSize << "; i++)\n";
- ss << " {\n";
- ss << " double arg0 = ";
- ss << vSubArguments[0]->GenSlidingWindowDeclRef();
- ss << ";\n";
- ss << " double arg1 = ";
- ss << vSubArguments[1]->GenSlidingWindowDeclRef();
- ss << ";\n";
-#ifdef ISNAN
- ss << " if(isNan(arg0)||((gid0+i)>=";
- ss << pCurDVR->GetArrayLength();
- ss << "))\n";
- ss << " {\n";
- ss << " length--;\n";
- ss << " continue;\n";
- ss << " }\n";
+ else if ((!pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+ &&(!pDVR1->IsStartFixed() && !pDVR1->IsEndFixed()))
+ {
+#ifdef ISNAN
+ ss << "0; i + gid0 < " << arrayLength;
+ ss << " && i < " << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < " << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
#endif
-#ifdef ISNAN
- ss << " if(isNan(arg1)||((gid0+i)>=";
- ss << pCurDVR1->GetArrayLength();
- ss << "))\n";
- ss << " {\n";
- ss << " length--;\n";
- ss << " continue;\n";
- ss << " }\n";
+ }
+ else if ((pDVR->IsStartFixed() && pDVR->IsEndFixed())
+ &&(pDVR1->IsStartFixed() && pDVR1->IsEndFixed()))
+ {
+#ifdef ISNAN
+ ss << "0; i < " << arrayLength << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < " << arrayLength << "; i++)\n";
+ ss << " {\n";
#endif
- ss << " fSumY+=arg0;\n";
- ss << " fSumX+=arg1;\n";
- ss << " }\n";
- ss <<" double fMeanX = fSumX / length;\n";
- ss <<" double fMeanY = fSumY / length;\n";
- ss << " for (int i = 0; i <" << nCurWindowSize << "; i++)\n";
- ss << " {\n";
- ss << " double arg0 = ";
- ss << vSubArguments[0]->GenSlidingWindowDeclRef();
- ss << ";\n";
- ss << " double arg1 = ";
- ss << vSubArguments[1]->GenSlidingWindowDeclRef();
- ss << ";\n";
-#ifdef ISNAN
- ss << " if(isNan(arg0)||((gid0+i)>=";
- ss << pCurDVR->GetArrayLength();
- ss << "))\n";
- ss << " {\n";
- ss << " continue;\n";
- ss << " }\n";
+ }
+ else
+ {
+#ifdef ISNAN
+ ss << "0; i < " << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < " << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
#endif
-#ifdef ISNAN
- ss << " if(isNan(arg1)||((gid0+i)>=";
- ss <<pCurDVR1->GetArrayLength();
- ss <<"))\n";
- ss << " {\n";
- ss << " continue;\n";
- ss << " }\n";
+ ss << " break;\n";
+ ss << " }";
+ ss << " return NAN;\n";
+ ss << "}\n";
+ return ;
+ }
+
+ ss << " argX = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " argY = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef ISNAN
+ ss << " if (isNan(argX) || isNan(argY))\n";
+ ss << " continue;\n";
#endif
- ss << " fSumDeltaXDeltaY+=(arg1 - fMeanX) * (arg0 - fMeanY);";
- ss << ";\n";
- ss << " fSumSqrDeltaX += pow(arg1 - fMeanX, 2);\n";
- ss << " }\n";
- ss << " tmp = fMeanY - fSumDeltaXDeltaY / fSumSqrDeltaX";
- ss << "* fMeanX;\n";
- ss << " return tmp;\n";
- ss << "}";
+ ss << " fSumX += argX;\n";
+ ss << " fSumY += argY;\n";
+ ss << " fCount += 1.0;\n";
+ ss << " }\n";
+
+ ss << " if (fCount < 1.0)\n";
+ ss << " return NAN;\n";
+ ss << " else\n";
+ ss << " {\n";
+ ss << " fMeanX = fSumX * pow(fCount,-1.0);\n";
+ ss << " fMeanY = fSumY * pow(fCount,-1.0);\n";
+
+ ss << " for (int i = ";
+ if ((!pDVR->IsStartFixed() && pDVR->IsEndFixed())
+ &&(!pDVR1->IsStartFixed() && pDVR1->IsEndFixed()))
+ {
+#ifdef ISNAN
+ ss << "gid0; i < " << arrayLength;
+ ss << " && i < " << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "gid0; i < " << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+ else if ((pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+ &&(pDVR1->IsStartFixed() && !pDVR1->IsEndFixed()))
+ {
+#ifdef ISNAN
+ ss << "0; i < " << arrayLength ;
+ 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())
+ &&(!pDVR1->IsStartFixed() && !pDVR1->IsEndFixed()))
+ {
+#ifdef ISNAN
+ ss << "0; i + gid0 < " << arrayLength;
+ ss << " && i < " << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < " << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+ else
+ {
+#ifdef ISNAN
+ ss << "0; i < " << arrayLength << "; i++)\n";
+ ss << " {\n";
+#else
+ ss << "0; i < " << arrayLength << "; i++)\n";
+ ss << " {\n";
+#endif
+ }
+
+ ss << " argX = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+ ss << " argY = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+#ifdef ISNAN
+ ss << " if (isNan(argX) || isNan(argY))\n";
+ ss << " continue;\n";
+#endif
+ ss << " fSumDeltaXDeltaY += (argX-fMeanX)*(argY-fMeanY);\n";
+ ss << " fSumSqrDeltaX += (argX-fMeanX) * (argX-fMeanX);\n";
+ ss << " }\n";
+ ss << " if(fSumSqrDeltaX == 0.0)\n";
+ ss << " return NAN;\n";
+ ss << " else\n";
+ ss << " {\n";
+ ss << " return fMeanY -";
+ ss << " (fSumDeltaXDeltaY*pow(fSumSqrDeltaX,-1.0))*fMeanX;\n";
+ ss << " }\n";
+ ss << " }\n";
+ ss << "}\n";
+ }
+ else
+ {
+ ss << " return NAN;\n";
+ ss << "}\n";
+ }
}
void OpLogInv:: GenSlidingWindowFunction(std::stringstream &ss,
const std::string &sSymName, SubArguments &vSubArguments)
commit b113a08b0ac9aa4ace49fb3c2fc0df9093d61777
Author: haochen <haochen at multicorewareinc.com>
Date: Tue May 13 10:22:31 2014 +0800
GPU Calc: Fixed style&error problem in op_statistical(line 5849-9461)
Change-Id: I85f7bdeb153a8bcee0fe9678db93bc43cf2bc659
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index e891bba..6dfe344 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -5982,7 +5982,6 @@ void OpLogInv:: GenSlidingWindowFunction(std::stringstream &ss,
ss << " double tmp;\n";
ss << " double arg0,arg1,arg2,arg3;\n";
size_t i = vSubArguments.size();
- size_t nItems = 0;
for (i = 0; i < vSubArguments.size(); i++)
{
FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
@@ -6022,7 +6021,6 @@ void OpLogInv:: GenSlidingWindowFunction(std::stringstream &ss,
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
#endif
}
- nItems += nCurWindowSize;
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
@@ -6283,10 +6281,10 @@ void OpForecast::GenSlidingWindowFunction(std::stringstream &ss,
ss << " for (int i = 0; i <" << nCurWindowSize << "; i++)\n";
ss << " {\n";
ss << " double arg1 = ";
- ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef(true);
ss << ";\n";
ss << " double arg2 = ";
- ss << vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss << vSubArguments[2]->GenSlidingWindowDeclRef(true);
ss << ";\n";
#ifdef ISNAN
ss << " if(isNan(arg1)||((gid0+i)>=";
@@ -6314,10 +6312,10 @@ void OpForecast::GenSlidingWindowFunction(std::stringstream &ss,
ss << " for (int i = 0; i <" << nCurWindowSize << "; i++)\n";
ss << " {\n";
ss << " double arg1 = ";
- ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef(true);
ss << ";\n";
ss << " double arg2 = ";
- ss << vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss << vSubArguments[2]->GenSlidingWindowDeclRef(true);
ss << ";\n";
#ifdef ISNAN
ss << " if(isNan(arg1)||((gid0+i)>=";
@@ -6371,7 +6369,6 @@ void OpLogNormDist::GenSlidingWindowFunction(std::stringstream &ss,
ss << " int gid0=get_global_id(0);\n";
ss << " double arg0,arg1,arg2,arg3;\n";
size_t i = vSubArguments.size();
- size_t nItems = 0;
for (i = 0; i < vSubArguments.size(); i++)
{
FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
@@ -6411,7 +6408,6 @@ void OpLogNormDist::GenSlidingWindowFunction(std::stringstream &ss,
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
#endif
}
- nItems += nCurWindowSize;
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
@@ -6516,7 +6512,7 @@ void OpGammaDist::GenSlidingWindowFunction(std::stringstream &ss,
ss << " double tmp;\n";
ss << " double arg0,arg1,arg2,arg3;\n";
size_t i = vSubArguments.size();
- size_t nItems = 0;
+
for (i = 0; i < vSubArguments.size(); i++)
{
FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
@@ -6556,7 +6552,6 @@ void OpGammaDist::GenSlidingWindowFunction(std::stringstream &ss,
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
#endif
}
- nItems += nCurWindowSize;
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
@@ -6633,7 +6628,6 @@ void OpChiDist::GenSlidingWindowFunction(
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++)
{
@@ -6680,7 +6674,6 @@ void OpChiDist::GenSlidingWindowFunction(
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
#endif
}
- nItems += nCurWindowSize;
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
@@ -6689,7 +6682,6 @@ void OpChiDist::GenSlidingWindowFunction(
static_cast< const formula::SingleVectorRefToken* >(pCur);
ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n";
#else
- nItems += 1;
#endif
}
else if (pCur->GetType() == formula::svDouble)
@@ -6697,13 +6689,11 @@ void OpChiDist::GenSlidingWindowFunction(
#ifdef ISNAN
ss << "{\n";
#endif
- nItems += 1;
}
else
{
#ifdef ISNAN
#endif
- nItems += 1;
}
#ifdef ISNAN
if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
@@ -6772,7 +6762,7 @@ void OpBinomdist::GenSlidingWindowFunction(
ss << " double tmp0,tmp1,tmp2,tmp3;\n";
ss << " int gid0=get_global_id(0);\n";
size_t i = vSubArguments.size();
- size_t nItems = 0;
+
ss <<"\n ";
//while (i-- > 1)
for (i = 0; i < vSubArguments.size(); i++)
@@ -6820,7 +6810,6 @@ void OpBinomdist::GenSlidingWindowFunction(
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
#endif
}
- nItems += nCurWindowSize;
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
@@ -6829,7 +6818,6 @@ void OpBinomdist::GenSlidingWindowFunction(
static_cast< const formula::SingleVectorRefToken* >(pCur);
ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n";
#else
- nItems += 1;
#endif
}
else if (pCur->GetType() == formula::svDouble)
@@ -6837,13 +6825,11 @@ void OpBinomdist::GenSlidingWindowFunction(
#ifdef ISNAN
ss << "{\n";
#endif
- nItems += 1;
}
else
{
#ifdef ISNAN
#endif
- nItems += 1;
}
#ifdef ISNAN
if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
@@ -7148,7 +7134,7 @@ void OpGammaInv::GenSlidingWindowFunction(std::stringstream &ss,
ss << " double tmp;\n";
ss << " double arg0,arg1,arg2;\n";
size_t i = vSubArguments.size();
- size_t nItems = 0;
+
for (i = 0; i < vSubArguments.size(); i++)
{
FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
@@ -7188,7 +7174,6 @@ void OpGammaInv::GenSlidingWindowFunction(std::stringstream &ss,
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
#endif
}
- nItems += nCurWindowSize;
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
@@ -7362,7 +7347,7 @@ void OpFInv::GenSlidingWindowFunction(std::stringstream &ss,
ss << " double tmp;\n";
ss << " double arg0,arg1,arg2;\n";
size_t i = vSubArguments.size();
- size_t nItems = 0;
+
for (i = 0; i < vSubArguments.size(); i++)
{
FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
@@ -7402,7 +7387,6 @@ void OpFInv::GenSlidingWindowFunction(std::stringstream &ss,
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
#endif
}
- nItems += nCurWindowSize;
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
@@ -7596,7 +7580,7 @@ void OpFTest::GenSlidingWindowFunction(std::stringstream &ss,
#ifdef ISNAN
ss << "0; i < "<< pDVR->GetRefRowSize() << "; i++){\n";
ss << " double arg"<<i<<" = ";
- ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef(true);
ss << ";\n";
#ifdef ISNAN
ss << " if(isNan(arg"<<i<<")||((gid0+i)>=";
@@ -7677,7 +7661,6 @@ void OpB::GenSlidingWindowFunction(std::stringstream &ss,
ss << " double tmp;\n";
ss << " double arg0,arg1,arg2,arg3;\n";
size_t i = vSubArguments.size();
- size_t nItems = 0;
for (i = 0; i < vSubArguments.size(); i++)
{
FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
@@ -7717,7 +7700,6 @@ void OpB::GenSlidingWindowFunction(std::stringstream &ss,
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
#endif
}
- nItems += nCurWindowSize;
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
@@ -8240,7 +8222,7 @@ void OpBetaDist::GenSlidingWindowFunction(std::stringstream &ss,
ss << " double tmp;\n";
ss << " double arg0,arg1,arg2,arg3,arg4,arg5;\n";
size_t i = vSubArguments.size();
- size_t nItems = 0;
+
for (i = 0; i < vSubArguments.size(); i++)
{
FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
@@ -8280,7 +8262,7 @@ void OpBetaDist::GenSlidingWindowFunction(std::stringstream &ss,
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
#endif
}
- nItems += nCurWindowSize;
+
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
@@ -8393,7 +8375,6 @@ void OpBetainv::GenSlidingWindowFunction(
ss << " double tmp0,tmp1,tmp2,tmp3,tmp4;\n";
ss << " int gid0=get_global_id(0);\n";
size_t i = vSubArguments.size();
- size_t nItems = 0;
ss <<"\n ";
//while (i-- > 1)
for (i = 0; i < vSubArguments.size(); i++)
@@ -8435,7 +8416,6 @@ void OpBetainv::GenSlidingWindowFunction(
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
#endif
}
- nItems += nCurWindowSize;
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
@@ -8444,7 +8424,6 @@ void OpBetainv::GenSlidingWindowFunction(
static_cast< const formula::SingleVectorRefToken* >(pCur);
ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n";
#else
- nItems += 1;
#endif
}
else if (pCur->GetType() == formula::svDouble)
@@ -8452,13 +8431,12 @@ void OpBetainv::GenSlidingWindowFunction(
#ifdef ISNAN
ss << "{\n";
#endif
- nItems += 1;
}
else
{
#ifdef ISNAN
#endif
- nItems += 1;
+
}
#ifdef ISNAN
if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
@@ -8730,7 +8708,7 @@ void OpHypGeomDist::GenSlidingWindowFunction(std::stringstream &ss,
ss << " int gid0=get_global_id(0);\n";
ss << " double arg0,arg1,arg2,arg3;\n";
size_t i = vSubArguments.size();
- size_t nItems = 0;
+
for (i = 0; i < vSubArguments.size(); i++)
{
FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
@@ -8762,7 +8740,6 @@ void OpHypGeomDist::GenSlidingWindowFunction(std::stringstream &ss,
ss << "0; i < "<< nCurWindowSize << "; i++){\n";
#endif
}
- nItems += nCurWindowSize;
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
@@ -8869,7 +8846,6 @@ void OpMinA::GenSlidingWindowFunction(
ss << " int gid0=get_global_id(0);\n";
ss << " double tmp0 = 1.79769e+308;\n";
size_t i = vSubArguments.size();
- size_t nItems = 0;
ss <<"\n";
for (i = 0; i < vSubArguments.size(); i++)
{
@@ -8919,7 +8895,6 @@ void OpMinA::GenSlidingWindowFunction(
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
#endif
}
- nItems += nCurWindowSize;
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
@@ -8938,7 +8913,6 @@ void OpMinA::GenSlidingWindowFunction(
isMixed = svSingleVectorRefNULL;
ss << " if (gid0 < " << pSVR->GetArrayLength() << "){\n";
#else
- nItems += 1;
#endif
}
else if (pCur->GetType() == formula::svDouble)
@@ -8947,13 +8921,11 @@ void OpMinA::GenSlidingWindowFunction(
ss << " {\n";
isMixed = svDoubleDouble;
#endif
- nItems += 1;
}
else
{
#ifdef ISNAN
#endif
- nItems += 1;
}
#ifdef ISNAN
@@ -9055,7 +9027,7 @@ vSubArguments)
ss << " int gid0=get_global_id(0);\n";
ss << " double nCount = 0.0;\n";
size_t i = vSubArguments.size();
- size_t nItems = 0;
+
ss <<"\n";
for (i = 0; i < vSubArguments.size(); i++)
{
@@ -9105,7 +9077,6 @@ vSubArguments)
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
#endif
}
- nItems += nCurWindowSize;
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
@@ -9124,7 +9095,6 @@ vSubArguments)
isMixed = svSingleVectorRefNULL;
ss << " if (gid0 < " << pSVR->GetArrayLength() << "){\n";
#else
- nItems += 1;
#endif
}
else if (pCur->GetType() == formula::svDouble)
@@ -9133,13 +9103,11 @@ vSubArguments)
ss << " {\n";
isMixed = svDoubleDouble;
#endif
- nItems += 1;
}
else
{
#ifdef ISNAN
#endif
- nItems += 1;
}
#ifdef ISNAN
@@ -9227,7 +9195,7 @@ vSubArguments)
ss << " int gid0=get_global_id(0);\n";
ss << " double tmp0 = 2.22507e-308;\n";
size_t i = vSubArguments.size();
- size_t nItems = 0;
+
ss <<"\n";
for (i = 0; i < vSubArguments.size(); i++)
{
@@ -9277,7 +9245,6 @@ vSubArguments)
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
#endif
}
- nItems += nCurWindowSize;
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
@@ -9296,7 +9263,6 @@ vSubArguments)
isMixed = svSingleVectorRefNULL;
ss << " if (gid0 < " << pSVR->GetArrayLength() << "){\n";
#else
- nItems += 1;
#endif
}
else if (pCur->GetType() == formula::svDouble)
@@ -9305,13 +9271,11 @@ vSubArguments)
ss << " {\n";
isMixed = svDoubleDouble;
#endif
- nItems += 1;
}
else
{
#ifdef ISNAN
#endif
- nItems += 1;
}
#ifdef ISNAN
@@ -9414,7 +9378,6 @@ vSubArguments)
ss << " double tmp0 = 0.0;\n";
ss << " double nCount = 0.0;\n";
size_t i = vSubArguments.size();
- size_t nItems = 0;
ss <<"\n";
for (i = 0; i < vSubArguments.size(); i++)
{
@@ -9464,7 +9427,6 @@ vSubArguments)
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
#endif
}
- nItems += nCurWindowSize;
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
@@ -9483,7 +9445,6 @@ vSubArguments)
isMixed = svSingleVectorRefNULL;
ss << " if (gid0 < " << pSVR->GetArrayLength() << "){\n";
#else
- nItems += 1;
#endif
}
else if (pCur->GetType() == formula::svDouble)
@@ -9492,13 +9453,11 @@ vSubArguments)
ss << " {\n";
isMixed = svDoubleDouble;
#endif
- nItems += 1;
}
else
{
#ifdef ISNAN
#endif
- nItems += 1;
}
#ifdef ISNAN
commit ad6695b5eb7584b86a6c2add6821c2ac314ad51a
Author: haochen <haochen at multicorewareinc.com>
Date: Tue May 13 10:12:40 2014 +0800
GPU Calc: Fixed style&error problem in op_statistical(line 4037-5849)
Change-Id: I5a24bcc91f8c19472aab529e82648d06d13e46d9
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index e095f03..e891bba 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -4036,6 +4036,7 @@ void OpPearson::GenSlidingWindowFunction(
ss << "}\n";
}
+
void OpGammaLn::GenSlidingWindowFunction(
std::stringstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
{
@@ -4602,65 +4603,8 @@ void OpRsq::GenSlidingWindowFunction(
ss << " double fInx;\n";
ss << " double fIny;\n";
ss << " double tmp0,tmp1;\n";
- size_t i = vSubArguments.size();
+ vSubArguments.size();
ss <<"\n";
- for (i = 0; i < vSubArguments.size(); i++)
- {
- pCur = vSubArguments[i]->GetFormulaToken();
- assert(pCur);
- if (pCur->GetType() == formula::svDoubleVectorRef)
- {
- const formula::DoubleVectorRefToken* pDVR =
- static_cast<const formula::DoubleVectorRefToken *>(pCur);
- 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
- }
- }
- else if (pCur->GetType() == formula::svSingleVectorRef)
- {
-#ifdef ISNAN
- const formula::SingleVectorRefToken* pSVR =
- static_cast< const formula::SingleVectorRefToken* >(pCur);
- ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n";
-#endif
- }
- else if (pCur->GetType() == formula::svDouble)
- {
-#ifdef ISNAN
- ss << "{\n";
-#endif
- }
- ss << "\n}\n";
- }
-#ifdef ISNAN
FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
const formula::DoubleVectorRefToken*tmpCurDVR0= static_cast<const
formula::DoubleVectorRefToken *>(tmpCur0);
@@ -4673,25 +4617,20 @@ void OpRsq::GenSlidingWindowFunction(
ss << " int buffer_fIny_len = ";
ss << tmpCurDVR1->GetArrayLength();
ss << ";\n";
-#endif
ss << " for(int i=0; i<"<<nCurWindowSize<<"; i++)\n";
ss << " {\n";
-#ifdef ISNAN
ss << " if((gid0+i)>=buffer_fInx_len || isNan(";
ss << vSubArguments[0]->GenSlidingWindowDeclRef();
ss << "))\n";
ss << " fInx = 0;\n";
ss << " else\n";
-#endif
ss << " fInx = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
ss << ";\n";
-#ifdef ISNAN
ss << " if((gid0+i)>=buffer_fIny_len || isNan(";
ss << vSubArguments[1]->GenSlidingWindowDeclRef();
ss << "))\n";
ss << " fIny = 0;\n";
ss << " else\n";
-#endif
ss << " fIny = "<<vSubArguments[1]->GenSlidingWindowDeclRef();
ss << " ;\n";
ss << " fSumX += fInx;\n";
@@ -4704,8 +4643,18 @@ void OpRsq::GenSlidingWindowFunction(
ss << " fSumY = 0.0;\n";
ss << " for(int i=0; i<"<<nCurWindowSize<<"; i++)\n";
ss << " {\n";
+ ss << " if((gid0+i)>=buffer_fInx_len || isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << "))\n";
+ ss << " fInx = 0;\n";
+ ss << " else\n";
ss << " fInx = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
- ss << " ;\n";
+ ss << ";\n";
+ ss << " if((gid0+i)>=buffer_fIny_len || isNan(";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << "))\n";
+ ss << " fIny = 0;\n";
+ ss << " else\n";
ss << " fIny = "<<vSubArguments[1]->GenSlidingWindowDeclRef();
ss << " ;\n";
ss << " fSumDeltaXDeltaY += (fInx - fMeanX) * (fIny - fMeanY);\n";
@@ -4756,7 +4705,6 @@ void OpChiInv::GenSlidingWindowFunction(
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++)
{
@@ -4797,7 +4745,6 @@ void OpChiInv::GenSlidingWindowFunction(
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
#endif
}
- nItems += nCurWindowSize;
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
@@ -4806,7 +4753,6 @@ void OpChiInv::GenSlidingWindowFunction(
static_cast< const formula::SingleVectorRefToken* >(pCur);
ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n";
#else
- nItems += 1;
#endif
}
else if (pCur->GetType() == formula::svDouble)
@@ -4814,13 +4760,11 @@ void OpChiInv::GenSlidingWindowFunction(
#ifdef ISNAN
ss << "{\n";
#endif
- nItems += 1;
}
else
{
#ifdef ISNAN
#endif
- nItems += 1;
}
#ifdef ISNAN
if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
@@ -5675,7 +5619,7 @@ void OpMedian::GenSlidingWindowFunction(
{
ss << "gid0; endFlag = "<< nCurWindowSize <<"-gid0;\n";
}
- else if (pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
+ if (pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
{
ss << "gid0; endFlag = gid0+"<< nCurWindowSize <<";\n";
}
@@ -5753,7 +5697,7 @@ void OpKurt:: GenSlidingWindowFunction(std::stringstream &ss,
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
ss << " {\n";
ss << " double arg"<<i<<" = ";
- ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef(true);
ss << ";\n";
#ifdef ISNAN
ss << " if(isNan(arg"<<i<<")||((gid0+i)>=";
@@ -5808,7 +5752,7 @@ void OpKurt:: GenSlidingWindowFunction(std::stringstream &ss,
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
ss << " {\n";
ss << " double arg"<<i<<" = ";
- ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef(true);
ss << ";\n";
#ifdef ISNAN
ss << " if(isNan(arg"<<i<<")||((gid0+i)>=";
@@ -5857,7 +5801,7 @@ void OpKurt:: GenSlidingWindowFunction(std::stringstream &ss,
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
ss << " {\n";
ss << " double arg"<<i<<" = ";
- ss << vSubArguments[i]->GenSlidingWindowDeclRef();
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef(true);
ss << ";\n";
#ifdef ISNAN
ss << " if(isNan(arg"<<i<<")||((gid0+i)>=";
commit 6ec9fefd5317509696d84f125e2cbd7e51001b55
Author: haochen <haochen at multicorewareinc.com>
Date: Tue May 13 10:06:44 2014 +0800
GPU Calc: Fixed style&error problem in op_statistical(line 1-4037)
Change-Id: I97f55bffd1e61bc9d3f7f85ab857f82df5475dc4
diff --git a/sc/source/core/opencl/op_statistical.cxx b/sc/source/core/opencl/op_statistical.cxx
index 3c6b880..e095f03 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -684,7 +684,8 @@ void OpTTest::GenSlidingWindowFunction(std::stringstream &ss,
}
else if(pCur3->GetType() == formula::svDouble)
{
- ss << " type = floor(" << pCur3->GetDouble() << ");\n";
+ ss << " type = floor(convert_double(" << pCur3->GetDouble() <<
+ "));\n";
}
else
{
@@ -782,9 +783,9 @@ void OpTTest::GenSlidingWindowFunction(std::stringstream &ss,
}
ss << " arg1 = ";
- ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef(true) << ";\n";
ss << " arg2 = ";
- ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef(true) << ";\n";
#ifdef ISNAN
ss << " if (isNan(arg1)||isNan(arg2))\n";
ss << " continue;\n";
@@ -874,7 +875,7 @@ void OpTTest::GenSlidingWindowFunction(std::stringstream &ss,
}
ss << " arg1 = ";
- ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef(true) << ";\n";
#ifdef ISNAN
ss << " if (isNan(arg1))\n";
ss << " continue;\n";
@@ -929,7 +930,7 @@ void OpTTest::GenSlidingWindowFunction(std::stringstream &ss,
#endif
}
ss << " arg2 = ";
- ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef(true) << ";\n";
#ifdef ISNAN
ss << " if (isNan(arg2))\n";
ss << " continue;\n";
@@ -3177,7 +3178,7 @@ void OpSlope::GenSlidingWindowFunction(std::stringstream &ss,
ss << " double argY = 0.0;\n";
if(vSubArguments.size() != 2)
{
- ss << " return DBL_MAX;\n";
+ ss << " return NAN;\n";
ss << "}\n";
return ;
}
@@ -3200,7 +3201,7 @@ void OpSlope::GenSlidingWindowFunction(std::stringstream &ss,
pDVR1->GetArrayLength();
if(nCurWindowSize != nCurWindowSize1)
{
- ss << " return DBL_MAX;\n";
+ ss << " return NAN;\n";
ss << "}\n";
return ;
}
@@ -3218,7 +3219,7 @@ void OpSlope::GenSlidingWindowFunction(std::stringstream &ss,
#endif
}
else if ((pDVR->IsStartFixed() && !pDVR->IsEndFixed())
- &&(pDVR->IsStartFixed() && !pDVR->IsEndFixed()))
+ &&(pDVR1->IsStartFixed() && !pDVR1->IsEndFixed()))
{
#ifdef ISNAN
ss << "0; i < " << arrayLength ;
@@ -3230,7 +3231,7 @@ void OpSlope::GenSlidingWindowFunction(std::stringstream &ss,
#endif
}
else if ((!pDVR->IsStartFixed() && !pDVR->IsEndFixed())
- &&(!pDVR->IsStartFixed() && !pDVR->IsEndFixed()))
+ &&(!pDVR1->IsStartFixed() && !pDVR1->IsEndFixed()))
{
#ifdef ISNAN
ss << "0; i + gid0 < " << arrayLength;
@@ -3242,7 +3243,7 @@ void OpSlope::GenSlidingWindowFunction(std::stringstream &ss,
#endif
}
else if ((pDVR->IsStartFixed() && pDVR->IsEndFixed())
- &&(pDVR->IsStartFixed() && pDVR->IsEndFixed()))
+ &&(pDVR1->IsStartFixed() && pDVR1->IsEndFixed()))
{
#ifdef ISNAN
ss << "0; i < " << arrayLength << "; i++)\n";
@@ -3263,7 +3264,7 @@ void OpSlope::GenSlidingWindowFunction(std::stringstream &ss,
#endif
ss << " break;\n";
ss << " }";
- ss << " return DBL_MAX;\n";
+ ss << " return NAN;\n";
ss << "}\n";
return ;
}
@@ -3282,7 +3283,7 @@ void OpSlope::GenSlidingWindowFunction(std::stringstream &ss,
ss << " }\n";
ss << " if (fCount < 1.0)\n";
- ss << " return DBL_MAX;\n";
+ ss << " return NAN;\n";
ss << " else\n";
ss << " {\n";
ss << " fMeanX = fSumX * pow(fCount,-1.0);\n";
@@ -3302,7 +3303,7 @@ void OpSlope::GenSlidingWindowFunction(std::stringstream &ss,
#endif
}
else if ((pDVR->IsStartFixed() && !pDVR->IsEndFixed())
- &&(pDVR->IsStartFixed() && !pDVR->IsEndFixed()))
+ &&(pDVR1->IsStartFixed() && !pDVR1->IsEndFixed()))
{
#ifdef ISNAN
ss << "0; i < " << arrayLength ;
@@ -3314,7 +3315,7 @@ void OpSlope::GenSlidingWindowFunction(std::stringstream &ss,
#endif
}
else if ((!pDVR->IsStartFixed() && !pDVR->IsEndFixed())
- &&(!pDVR->IsStartFixed() && !pDVR->IsEndFixed()))
+ &&(!pDVR1->IsStartFixed() && !pDVR1->IsEndFixed()))
{
#ifdef ISNAN
ss << "0; i + gid0 < " << arrayLength;
@@ -3348,7 +3349,7 @@ void OpSlope::GenSlidingWindowFunction(std::stringstream &ss,
ss << " fSumSqrDeltaX += (argX-fMeanX) * (argX-fMeanX);\n";
ss << " }\n";
ss << " if(fSumSqrDeltaX == 0.0)\n";
- ss << " return DBL_MAX;\n";
+ ss << " return NAN;\n";
ss << " else\n";
ss << " {\n";
ss << " return fSumDeltaXDeltaY*pow(fSumSqrDeltaX,-1.0);\n";
@@ -3358,7 +3359,7 @@ void OpSlope::GenSlidingWindowFunction(std::stringstream &ss,
}
else
{
- ss << " return DBL_MAX;\n";
+ ss << " return NAN;\n";
ss << "}\n";
}
}
@@ -3711,9 +3712,9 @@ void OpCorrel::GenSlidingWindowFunction(
if (!pCurDVRX->IsStartFixed() && pCurDVRX->IsEndFixed()) {
ss << "gid0; i < " << nCurWindowSizeX << "; i++) {\n\t\t";
ss << "arg0 = " << vSubArguments[0]
- ->GenSlidingWindowDeclRef() << ";\n\t\t";
+ ->GenSlidingWindowDeclRef(true) << ";\n\t\t";
ss << "arg1 = " << vSubArguments[1]
- ->GenSlidingWindowDeclRef() << ";\n\t\t";
+ ->GenSlidingWindowDeclRef(true) << ";\n\t\t";
#ifdef ISNAN
ss << "if(isNan(arg0) || isNan(arg1) || (i >= ";
ss << pCurDVRX->GetArrayLength() << ") || (i >=";
@@ -3730,9 +3731,9 @@ void OpCorrel::GenSlidingWindowFunction(
} else if (pCurDVRX->IsStartFixed() && !pCurDVRX->IsEndFixed()) {
ss << "0; i < gid0 + " << nCurWindowSizeX << "; i++) {\n\t\t";
ss << "arg0 = " << vSubArguments[0]
- ->GenSlidingWindowDeclRef() << ";\n\t\t";
+ ->GenSlidingWindowDeclRef(true) << ";\n\t\t";
ss << "arg1 = " << vSubArguments[1]
- ->GenSlidingWindowDeclRef() << ";\n\t\t";
+ ->GenSlidingWindowDeclRef(true) << ";\n\t\t";
#ifdef ISNAN
ss << "if(isNan(arg0) || isNan(arg1) || (i >= ";
ss << pCurDVRX->GetArrayLength() << ") || (i >=";
@@ -3750,9 +3751,9 @@ void OpCorrel::GenSlidingWindowFunction(
else if (pCurDVRX->IsStartFixed() && pCurDVRX->IsEndFixed()) {
ss << "0; i < " << nCurWindowSizeX << "; i++) {\n\t\t";
ss << "arg0 = " << vSubArguments[0]
- ->GenSlidingWindowDeclRef() << ";\n\t\t";
+ ->GenSlidingWindowDeclRef(true) << ";\n\t\t";
ss << "arg1 = " << vSubArguments[1]
- ->GenSlidingWindowDeclRef() << ";\n\t\t";
+ ->GenSlidingWindowDeclRef(true) << ";\n\t\t";
#ifdef ISNAN
ss << "if(isNan(arg0) || isNan(arg1) || (i >= ";
ss << pCurDVRX->GetArrayLength() << ") || (i >=";
@@ -3769,9 +3770,9 @@ void OpCorrel::GenSlidingWindowFunction(
} else {
ss << "0; i < " << nCurWindowSizeX << "; i++) {\n\t\t";
ss << "arg0 = " << vSubArguments[0]
- ->GenSlidingWindowDeclRef() << ";\n\t\t";
+ ->GenSlidingWindowDeclRef(true) << ";\n\t\t";
ss << "arg1 = " << vSubArguments[1]
- ->GenSlidingWindowDeclRef() << ";\n\t\t";
+ ->GenSlidingWindowDeclRef(true) << ";\n\t\t";
#ifdef ISNAN
ss << "if(isNan(arg0) || isNan(arg1) || (i + gid0 >= ";
ss << pCurDVRX->GetArrayLength() << ") || (i + gid0 >=";
@@ -3800,9 +3801,9 @@ void OpCorrel::GenSlidingWindowFunction(
if (!pCurDVRX->IsStartFixed() && pCurDVRX->IsEndFixed()) {
ss << "gid0; i < " << nCurWindowSizeX << "; i++) {\n\t\t\t";
ss << "arg0 = " << vSubArguments[0]
- ->GenSlidingWindowDeclRef() << ";\n\t\t\t";
+ ->GenSlidingWindowDeclRef(true) << ";\n\t\t\t";
ss << "arg1 = " << vSubArguments[1]
- ->GenSlidingWindowDeclRef() << ";\n\t\t\t";
+ ->GenSlidingWindowDeclRef(true) << ";\n\t\t\t";
#ifdef ISNAN
ss << "if(isNan(arg0) || isNan(arg1) || (i >= ";
ss << pCurDVRX->GetArrayLength() << ") || (i >=";
@@ -3818,9 +3819,9 @@ void OpCorrel::GenSlidingWindowFunction(
} else if (pCurDVRX->IsStartFixed() && !pCurDVRX->IsEndFixed()) {
ss << "0; i < gid0 + " << nCurWindowSizeX << "; i++) {\n\t\t\t";
ss << "arg0 = " << vSubArguments[0]
- ->GenSlidingWindowDeclRef() << ";\n\t\t\t";
+ ->GenSlidingWindowDeclRef(true) << ";\n\t\t\t";
ss << "arg1 = " << vSubArguments[1]
- ->GenSlidingWindowDeclRef() << ";\n\t\t\t";
+ ->GenSlidingWindowDeclRef(true) << ";\n\t\t\t";
#ifdef ISNAN
ss << "if(isNan(arg0) || isNan(arg1) || (i >= ";
ss << pCurDVRX->GetArrayLength() << ") || (i >=";
@@ -3836,9 +3837,9 @@ void OpCorrel::GenSlidingWindowFunction(
} else if (pCurDVRX->IsStartFixed() && pCurDVRX->IsEndFixed()) {
ss << "0; i < " << nCurWindowSizeX << "; i++) {\n\t\t\t";
ss << "arg0 = " << vSubArguments[0]
- ->GenSlidingWindowDeclRef() << ";\n\t\t\t";
+ ->GenSlidingWindowDeclRef(true) << ";\n\t\t\t";
ss << "arg1 = " << vSubArguments[1]
- ->GenSlidingWindowDeclRef() << ";\n\t\t\t";
+ ->GenSlidingWindowDeclRef(true) << ";\n\t\t\t";
#ifdef ISNAN
ss << "if(isNan(arg0) || isNan(arg1) || (i >= ";
ss << pCurDVRX->GetArrayLength() << ") || (i >=";
@@ -3854,9 +3855,9 @@ void OpCorrel::GenSlidingWindowFunction(
} else {
ss << "0; i < " << nCurWindowSizeX << "; i++) {\n\t\t\t";
ss << "arg0 = " << vSubArguments[0]
- ->GenSlidingWindowDeclRef() << ";\n\t\t\t";
+ ->GenSlidingWindowDeclRef(true) << ";\n\t\t\t";
ss << "arg1 = " << vSubArguments[1]
- ->GenSlidingWindowDeclRef() << ";\n\t\t\t";
+ ->GenSlidingWindowDeclRef(true) << ";\n\t\t\t";
#ifdef ISNAN
ss << "if(isNan(arg0) || isNan(arg1) || (i + gid0 >= ";
ss << pCurDVRX->GetArrayLength() << ") || (i + gid0 >=";
@@ -3872,7 +3873,7 @@ void OpCorrel::GenSlidingWindowFunction(
}
ss << "if(vXSum == 0.0 || vYSum == 0.0) {\n\t\t\t";
- ss << "return DBL_MIN;\n\t\t";
+ ss << "return NAN;\n\t\t";
ss << "}\n\t\t";
ss << "else {\n\t\t\t";
ss << "return vSum/pow(vXSum*vYSum, 0.5);\n\t\t";
@@ -3958,11 +3959,11 @@ void OpNegbinomdist::GenSlidingWindowFunction(
void OpPearson::GenSlidingWindowFunction(
std::stringstream &ss, const std::string &sSymName, SubArguments &vSubArguments)
{
- FormulaToken* pCur = vSubArguments[1]->GetFormulaToken();
+ FormulaToken* pCur = vSubArguments[0]->GetFormulaToken();
assert(pCur);
- const formula::DoubleVectorRefToken* pCurDVR =
+ const formula::DoubleVectorRefToken* pDVR =
static_cast<const formula::DoubleVectorRefToken *>(pCur);
- size_t CurWindowSize = pCurDVR->GetRefRowSize();
+ size_t nCurWindowSize = pDVR->GetRefRowSize();
ss << "\ndouble " << sSymName;
ss << "_"<< BinFuncName() <<"(";
@@ -3981,100 +3982,23 @@ void OpPearson::GenSlidingWindowFunction(
ss << " double fSumDeltaXDeltaY = 0.0;\n";
ss << " double fInx;\n";
ss << " double fIny;\n";
- size_t i = vSubArguments.size();
- ss <<"\n";
- for (i = 0; i < vSubArguments.size(); i++)
- {
- pCur = vSubArguments[i]->GetFormulaToken();
- assert(pCur);
- if (pCur->GetType() == formula::svDoubleVectorRef)
- {
- const formula::DoubleVectorRefToken* pDVR =
- static_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
- }
- }
- else if (pCur->GetType() == formula::svSingleVectorRef)
- {
-#ifdef ISNAN
- const formula::SingleVectorRefToken* pSVR =
- static_cast< const formula::SingleVectorRefToken* >(pCur);
- ss << "if (gid0 < " << pSVR->GetArrayLength() << "){\n";
-#endif
- }
- else if (pCur->GetType() == formula::svDouble)
- {
-#ifdef ISNAN
- ss << "{\n";
-#endif
- }
- ss << "\n}\n";
- }
-#ifdef ISNAN
- FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
- const formula::DoubleVectorRefToken*tmpCurDVR0= static_cast<const
- formula::DoubleVectorRefToken *>(tmpCur0);
-
- FormulaToken *tmpCur1 = vSubArguments[1]->GetFormulaToken();
- const formula::DoubleVectorRefToken*tmpCurDVR1= static_cast<const
- formula::DoubleVectorRefToken *>(tmpCur1);
-
- ss << " int buffer_fInx_len = ";
- ss << tmpCurDVR0->GetArrayLength();
- ss << ";\n";
-
- ss << " int buffer_fIny_len = ";
- ss << tmpCurDVR1->GetArrayLength();
+ ss << "for (int i = ";
+ if (!pDVR->IsStartFixed() && pDVR->IsEndFixed()) {
+ ss << "gid0; i < " << pDVR->GetArrayLength();
+ ss << " && i < " << nCurWindowSize << "; i++){\n";
+ } else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed()) {
+ ss << "0; i < " << pDVR->GetArrayLength();
+ ss << " && i < gid0+"<< nCurWindowSize << "; i++){\n";
+ } else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed()){
+ ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+ ss << " && i < "<< nCurWindowSize << "; i++){\n";
+ }
+ else {
+ ss << "0; i < "<< nCurWindowSize << "; i++){\n";
+ }
+ ss << " fInx = "<<vSubArguments[0]->GenSlidingWindowDeclRef(true);
ss << ";\n";
-#endif
- ss << " for(int i=0; i<"<<CurWindowSize<<"; i++)\n";
- ss << " {\n";
-#ifdef ISNAN
- ss <<" if((gid0+i)>=buffer_fInx_len || isNan(";
- ss << vSubArguments[0]->GenSlidingWindowDeclRef();
- ss <<"))\n";
- ss <<" fInx = 0;\n";
- ss <<" else\n";
-#endif
- ss << " fInx = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
- ss << ";\n";
-#ifdef ISNAN
- ss <<" if((gid0+i)>=buffer_fIny_len || isNan(";
- ss << vSubArguments[1]->GenSlidingWindowDeclRef();
- ss <<"))\n";
- ss <<" fIny = 0;\n";
- ss <<" else\n";
-#endif
- ss << " fIny = "<<vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << " fIny = "<<vSubArguments[1]->GenSlidingWindowDeclRef(true);
ss << " ;\n";
ss << " fSumX += fInx;\n";
ss << " fSumY += fIny;\n";
@@ -4084,11 +4008,23 @@ void OpPearson::GenSlidingWindowFunction(
ss << " double fMeanY = fSumY / fCount;\n";
ss << " fSumX = 0.0;\n";
ss << " fSumY = 0.0;\n";
- ss << " for(int i=0; i<"<<CurWindowSize<<"; i++)\n";
- ss << " {\n";
- ss << " fInx = "<<vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << "for (int i = ";
+ if (!pDVR->IsStartFixed() && pDVR->IsEndFixed()) {
+ ss << "gid0; i < " << pDVR->GetArrayLength();
+ ss << " && i < " << nCurWindowSize << "; i++){\n";
+ } else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed()) {
+ ss << "0; i < " << pDVR->GetArrayLength();
+ ss << " && i < gid0+"<< nCurWindowSize << "; i++){\n";
+ } else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed()){
+ ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+ ss << " && i < "<< nCurWindowSize << "; i++){\n";
+ }
+ else {
+ ss << "0; i < "<< nCurWindowSize << "; i++){\n";
+ }
+ ss << " fInx = "<<vSubArguments[0]->GenSlidingWindowDeclRef(true);
ss << " ;\n";
- ss << " fIny = "<<vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss << " fIny = "<<vSubArguments[1]->GenSlidingWindowDeclRef(true);
ss << " ;\n";
ss << " fSumDeltaXDeltaY += (fInx - fMeanX) * (fIny - fMeanY);\n";
ss << " fSumX += pow(fInx - fMeanX,2);\n";
commit e259362b5299cf5cd34968d1cd8d568943d14292
Author: haochen <haochen at multicorewareinc.com>
Date: Tue May 13 09:55:22 2014 +0800
GPU Calc: Fixed style&error problem in op_math once more
Change-Id: I768ad4503905b54ef5a7aa54445dbb94ce0493ed
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 257fe41..2be3146 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -2921,7 +2921,7 @@ void OpConvert::GenSlidingWindowFunction(
void OpProduct::GenSlidingWindowFunction(std::stringstream &ss,
const std::string &sSymName, SubArguments &vSubArguments)
{
- ss << "\ndouble " << sSymName;
+ ss << "\ndouble " << sSymName;
ss << "_"<< BinFuncName() <<"( ";
for (unsigned i = 0; i < vSubArguments.size(); i++)
{
@@ -2932,13 +2932,9 @@ void OpProduct::GenSlidingWindowFunction(std::stringstream &ss,
ss << ") {\n";
ss << " int gid0 = get_global_id(0);\n";
ss << " int i = 0;\n";
- ss << " double product=0.0;\n\n";
+ ss << " double product=1.0;\n\n";
for (unsigned i = 0; i < vSubArguments.size(); i++)
{
- std::stringstream ssArgNoI;
- ssArgNoI << i;
- std::string sArgNoI = ssArgNoI.str();
- ss << std::string(" double arg")+sArgNoI+";\n";
FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
assert(pCur);
if (pCur->GetType() == formula::svDoubleVectorRef)
@@ -2946,52 +2942,49 @@ void OpProduct::GenSlidingWindowFunction(std::stringstream &ss,
const formula::DoubleVectorRefToken* pDVR =
static_cast<const formula::DoubleVectorRefToken *>(pCur);
size_t nCurWindowSize = pDVR->GetRefRowSize();
- ss << std::string(" arg")+sArgNoI+" = ";
- ss << vSubArguments[i]->GenSlidingWindowDeclRef();
- ss <<";\n";
-#ifdef ISNAN
- ss << std::string(" if(isNan(arg")+sArgNoI+")||((gid0+i)>=";
- ss << pDVR->GetArrayLength();
- ss << "))\n";
- ss << " {\n";
- ss << std::string(" arg")+sArgNoI+" = 0;\n";
- ss << " }\n";
-#endif
- ss << std::string(" product = arg")+sArgNoI+";\n";
- ss << " for (i = ";
- ss << "1; i < "<< nCurWindowSize << "; i++)\n";
- ss << " {\n";
- ss << std::string(" arg")+sArgNoI+" = ";
- ss << vSubArguments[i]->GenSlidingWindowDeclRef();
- ss << ";\n";
-#ifdef ISNAN
- ss <<std::string(" if(isNan(arg")+sArgNoI+")||((gid0+i)>=";
- ss << pDVR->GetArrayLength();
- ss << "))\n";
- ss << " {\n";
- ss << std::string(" arg")+sArgNoI+" = 0;\n";
- ss << " }\n";
-#endif
- ss << std::string(" product*=arg")+sArgNoI+";\n";
- ss << " }\n";
+
+ ss << " for (int i = ";
+ if (!pDVR->IsStartFixed() && pDVR->IsEndFixed())
+ {
+ ss << "gid0; i < " << pDVR->GetArrayLength();
+ ss << " && i < " << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+ }
+ else if (pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+ {
+ ss << "0; i < " << pDVR->GetArrayLength();
+ ss << " && i < gid0+" << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+ }
+ else if (!pDVR->IsStartFixed() && !pDVR->IsEndFixed())
+ {
+ ss << "0; i + gid0 < " << pDVR->GetArrayLength();
+ ss << " && i < " << nCurWindowSize << "; i++)\n";
+ ss << " {\n";
+ }
+ else if (pDVR->IsStartFixed() && pDVR->IsEndFixed())
+ {
+
+ ss << "0; i < " << pDVR->GetArrayLength() << "; i++)\n";
+ ss << " {\n";
+ }
+ ss << "if(!isNan("<<vSubArguments[i]->GenSlidingWindowDeclRef()<<"))\n";
+ ss << "product = product*";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
+ ss << " }\n";
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
-#ifdef ISNAN
- ss << std::string(" arg")+sArgNoI+" = ";
- ss << vSubArguments[i]->GenSlidingWindowDeclRef();
- ss << ";\n";
- ss << std::string(" product*=arg")+sArgNoI+";\n";
-#endif
+ ss << "if(!isNan("<<vSubArguments[i]->GenSlidingWindowDeclRef()<<"))\n";
+ ss << "product = product*";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
+
}
- else if (pCur->GetType() == formula::svDouble)
+ else
{
-#ifdef ISNAN
- ss << std::string(" arg")+sArgNoI+" = ";
- ss << vSubArguments[i]->GenSlidingWindowDeclRef();
- ss << ";\n";
- ss << std::string(" product*=arg")+sArgNoI+";\n";
-#endif
+ ss << "if(!isNan("<<vSubArguments[i]->GenSlidingWindowDeclRef()<<"))\n";
+ ss << "product = product*";
+ ss << vSubArguments[i]->GenSlidingWindowDeclRef()<<";\n";
}
}
ss << " return product;\n";
@@ -3072,12 +3065,11 @@ void OpAverageIf::GenSlidingWindowFunction(std::stringstream &ss,
if(vSubArguments[paraThreeIndex]->GetFormulaToken()->GetType() ==
formula::svDoubleVectorRef)
{
- unsigned paraThreeWidth = 1;
FormulaToken *tmpCur2 =
vSubArguments[paraThreeIndex]->GetFormulaToken();
const formula::DoubleVectorRefToken*pCurDVR2= static_cast<const
formula::DoubleVectorRefToken *>(tmpCur2);
- paraThreeWidth = pCurDVR2->GetArrays().size();
+ unsigned paraThreeWidth = pCurDVR2->GetArrays().size();
if(paraThreeWidth > 1)
{
throw Unhandled();
commit d4f0b89119bb61f5c5db10d2f9c81123a1426749
Author: haochen <haochen at multicorewareinc.com>
Date: Tue May 13 09:53:38 2014 +0800
GPU Calc: Fixed style&error problem in op_math
Change-Id: I1f177684bdbac76a2f9632bc51482821eb510496
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index ccd0f3d..257fe41 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -26,30 +26,52 @@ namespace sc { namespace opencl {
void OpCos::GenSlidingWindowFunction(std::stringstream &ss,
const std::string &sSymName, SubArguments &vSubArguments)
{
- FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
- const formula::SingleVectorRefToken*tmpCurDVR= static_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\t";
- ss <<"int gid0=get_global_id(0);\n\t";
- ss << "double arg0 = " << vSubArguments[0]->GenSlidingWindowDeclRef();
- ss << ";\n\t";
+ 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=
+ static_cast
+ <const formula::SingleVectorRefToken *>(tmpCur);
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
#ifdef ISNAN
- ss<< "if(isNan(arg0)||(gid0>=";
- ss<<tmpCurDVR->GetArrayLength();
- ss<<"))\n\t\t";
- ss<<"arg0 = 0;\n\t";
+ ss << " if(isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ")||(gid0>=";
+ ss << tmpCurDVR->GetArrayLength();
+ ss << "))\n";
+ ss << " { arg0 = 0.0f; }\n";
#endif
- ss << "double tmp=cos(arg0);\n\t";
- ss << "return tmp;\n";
- ss << "}";
+ }
+ else if(tmpCur->GetType() == formula::svDouble)
+ {
+ ss << " arg0=" << tmpCur->GetDouble() << ";\n";
+ }
+ }
+ else
+ {
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ }
+ ss << " return cos(arg0);\n";
+ ss << "}";
+
}
void OpSec::GenSlidingWindowFunction(std::stringstream &ss,
const std::string &sSymName, SubArguments &vSubArguments)
@@ -968,7 +990,7 @@ void OpSinh::GenSlidingWindowFunction(std::stringstream &ss,
const std::string &sSymName, SubArguments &vSubArguments)
{
FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
- const formula::SingleVectorRefToken*tmpCurDVR= static_cast<const
+ static_cast<const
formula::SingleVectorRefToken *>(tmpCur);
ss << "\ndouble " << sSymName;
ss << "_"<< BinFuncName() <<"(";
@@ -983,12 +1005,8 @@ void OpSinh::GenSlidingWindowFunction(std::stringstream &ss,
ss <<" double arg0 = " <<
vSubArguments[0]->GenSlidingWindowDeclRef();
ss <<";\n";
-#ifdef ISNAN
- ss<< " if(isNan(arg0)||(gid0>=";
- ss<<tmpCurDVR->GetArrayLength();
- ss<<"))\n";
+ ss<< " if(isNan(arg0))\n";
ss<<" arg0 = 0;\n";
-#endif
ss << " double tmp=( exp(arg0)-exp(-arg0) )/2;\n";
ss << " return tmp;\n";
ss << "}";
@@ -1566,21 +1584,43 @@ void OpArcTan::GenSlidingWindowFunction(std::stringstream &ss,
if (i) ss << ",";
vSubArguments[i]->GenSlidingWindowDecl(ss);
}
- ss << ") {\n";
- ss << " int gid0 = get_global_id(0);\n";
- ss << " double tmp = " << GetBottom() << ";\n";
+ 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=
+ static_cast
+ <const formula::SingleVectorRefToken *>(tmpCur);
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
#ifdef ISNAN
- FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
- const formula::SingleVectorRefToken*tmpCurDVR0=
- static_cast<const formula::SingleVectorRefToken *>(tmpCur0);
- ss << " int buffer_len = " << tmpCurDVR0->GetArrayLength() << ";\n";
- ss << " if((gid0)>=buffer_len || isNan(";
- ss << vSubArguments[0]->GenSlidingWindowDeclRef() << "))\n";
- ss << " tmp = " << GetBottom() << ";\n";
- ss << " else\n ";
+ ss << " if(isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ")||(gid0>=";
+ ss << tmpCurDVR->GetArrayLength();
+ ss << "))\n";
+ ss << " { arg0 = 0.0f; }\n";
#endif
- ss << " tmp = " << vSubArguments[0]->GenSlidingWindowDeclRef() << ";\n";
- ss << " return atan(tmp);\n";
+ }
+ else if(tmpCur->GetType() == formula::svDouble)
+ {
+ ss << " arg0=" << tmpCur->GetDouble() << ";\n";
+ }
+ }
+ else
+ {
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ }
+ ss << " return atan(arg0);\n";
ss << "}";
}
void OpArcTanH::GenSlidingWindowFunction(std::stringstream &ss,
commit ca3f69a1f0198c5304dfaab45a0b4c0c95332ed0
Author: haochen <haochen at multicorewareinc.com>
Date: Wed May 14 17:34:06 2014 +0800
GPU Calc: Support nested formula of string compared in AND formula.
such as AND(MOD($B4, 3)=0, $A4="NQSO")
Change-Id: Ie891d4e56eaa39f769f018b6db53ee209dd15540
diff --git a/sc/source/core/opencl/op_logical.cxx b/sc/source/core/opencl/op_logical.cxx
index cb80ec7..79dc74a 100644
--- a/sc/source/core/opencl/op_logical.cxx
+++ b/sc/source/core/opencl/op_logical.cxx
@@ -42,7 +42,6 @@ void OpAnd::GenSlidingWindowFunction(std::stringstream &ss,
FormulaToken *tmpCur0 = vSubArguments[j]->GetFormulaToken();
if(tmpCur0->GetType() == formula::svSingleVectorRef)
{
-#ifdef ISNAN
const formula::SingleVectorRefToken*pCurDVR= static_cast<const
formula::SingleVectorRefToken *>(tmpCur0);
ss<< " int buffer_len"<<j<<" = "<<pCurDVR->GetArrayLength();
@@ -51,7 +50,6 @@ void OpAnd::GenSlidingWindowFunction(std::stringstream &ss,
ss <<vSubArguments[j]->GenSlidingWindowDeclRef();
ss <<"))\n";
ss <<" tmp = 1;\n else\n";
-#endif
ss <<" tmp = ";
ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n";
ss <<" tmp"<<j<<" = tmp"<<j<<" && tmp;\n";
@@ -100,6 +98,11 @@ void OpAnd::GenSlidingWindowFunction(std::stringstream &ss,
ss <<" tmp"<<j<<" = tmp"<<j<<" && tmp;\n";
ss <<" }\n";
}
+ else
+ {
+ ss <<" tmp"<<j<<" = ";
+ ss <<vSubArguments[j]->GenSlidingWindowDeclRef()<<";\n";
+ }
ss <<" t = t && tmp"<<j<<";\n";
}
ss << " return t;\n";
commit 2d73c5cdefd4fe811ae33938be32772c84fee16c
Author: haochen <haochen at multicorewareinc.com>
Date: Fri May 16 17:52:55 2014 +0800
GPU Calc:Fixed style&error problem
in op_financial&opbase.cxx&opencl_device.cxx
Change-Id: Ic4b8cee77a0a4faec44bcf3650f4f6fa691a9e71
diff --git a/sc/source/core/opencl/op_financial.cxx b/sc/source/core/opencl/op_financial.cxx
index ef669e7..6170bb7 100644
--- a/sc/source/core/opencl/op_financial.cxx
+++ b/sc/source/core/opencl/op_financial.cxx
@@ -1253,14 +1253,10 @@ void XNPV::GenSlidingWindowFunction(
ss << "double result = 0.0;\n\t";
ss << "int gid0 = get_global_id(0);\n\t";
ss << "int i=0;\n\t";
- if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed()) {
- ss<< "i=gid0;\n\t";
- }
ss << "double date;\n\t";
ss << "double value;\n\t";
ss << "double rate;\n\t";
ss << "double dateNull;\n\t";
-#ifdef ISNAN
FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
const formula::SingleVectorRefToken*tmpCurDVR0= static_cast<const
formula::SingleVectorRefToken *>(tmpCur0);
@@ -1281,25 +1277,24 @@ void XNPV::GenSlidingWindowFunction(
ss<< "int buffer_date_len = ";
ss<< tmpCurDVR2->GetArrayLength();
ss << ";\n\t";
-#endif
-#ifdef ISNAN
- ss<<"if((i+gid0)>=buffer_date_len || isNan(";
+ ss<<"if((gid0)>=buffer_date_len || isNan(";
ss << vSubArguments[2]->GenSlidingWindowDeclRef();
ss<<"))\n\t\t";
- ss<<"dateNull = 0;\n\telse \n\t\t";
-#endif
+ ss<<"return NAN;\n\telse \n";
ss<<"dateNull = ";
ss << vSubArguments[2]->GenSlidingWindowDeclRef();
ss<<";\n\t";
-#ifdef ISNAN
- ss<<"if((i+gid0)>=buffer_rate_len || isNan(";
+ ss<<"if((gid0)>=buffer_rate_len || isNan(";
ss << vSubArguments[0]->GenSlidingWindowDeclRef();
ss<<"))\n\t\t";
- ss<<"rate = 0;\n\telse \n\t\t";
-#endif
+ ss<<"return NAN;\n\telse \n";
ss<<"rate = ";
ss << vSubArguments[0]->GenSlidingWindowDeclRef();
ss<<";\n\t";
+ ss<<"if(1 == buffer_date_len )\n";
+ ss<<"return ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss<<";\n\t";
ss << "for (int i = ";
if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed())
{
@@ -1314,17 +1309,27 @@ void XNPV::GenSlidingWindowFunction(
ss << "0; i < "<< nCurWindowSize <<"; i++)\n\t\t";
}
ss << "{\n\t";
- ss << "result += ";
- ss << vSubArguments[1]->GenSlidingWindowDeclRef();
- ss << "/(pow((";
- ss<<vSubArguments[0]->GenSlidingWindowDeclRef();
- ss <<"+1),(";
- ss << vSubArguments[2]->GenSlidingWindowDeclRef();
- ss << "-dateNull)/365));\n\t";
- ss <<"}\n\t";
+ if (!pCurDVR->IsStartFixed() && !pCurDVR->IsEndFixed())
+ {
+ ss << "if((i+gid0)>=buffer_value_len || (i+gid0)>=buffer_date_len)\n\t\t";
+ ss << "return result;\n\telse \n\t\t";
+ }
+ else
+ {
+ ss << "if(i>=buffer_value_len || i>=buffer_date_len)\n\t\t";
+ ss << "return result;\n\telse \n\t\t";
+ }
- ss << "return result;\n";
- ss << "}";
+ ss << "value = ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef(true);
+ ss << ";\n";
+ ss << " date = ";
+ ss << vSubArguments[2]->GenSlidingWindowDeclRef(true);
+ ss << ";\n";
+ ss << "result += value/(pow((rate+1),(date-dateNull)/365));\n";
+ ss << "}\n";
+ ss << "return result;\n";
+ ss << "}";
}
void PriceMat::BinInlineFun(std::set<std::string>& decls,
@@ -2891,6 +2896,7 @@ void OpPrice::GenSlidingWindowFunction(std::stringstream &ss,
ss <<";\n";
#endif
}
+ ss << " if(tmp4*tmp5 == 0) return NAN;\n";
ss << " tmp = getPrice_(tmp0,tmp1,tmp2,tmp3,tmp4,tmp5,tmp6);\n";
ss << " return tmp;\n";
ss << "}";
@@ -2932,7 +2938,6 @@ void OpOddlprice::GenSlidingWindowFunction(std::stringstream &ss,
ss <<" double tmp5=0;\n";
ss <<" double tmp6=0;\n";
ss <<" double tmp7=0;\n";
- size_t nItems = 0;
ss <<" \n";
for (size_t i = 0; i < vSubArguments.size(); i++)
{
@@ -2973,7 +2978,6 @@ void OpOddlprice::GenSlidingWindowFunction(std::stringstream &ss,
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
#endif
}
- nItems += nCurWindowSize;
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
@@ -2982,7 +2986,6 @@ void OpOddlprice::GenSlidingWindowFunction(std::stringstream &ss,
static_cast< const formula::SingleVectorRefToken* >(pCur);
ss << " if (gid0 < " << pSVR->GetArrayLength() << "){\n";
#else
- nItems += 1;
#endif
}
else if (pCur->GetType() == formula::svDouble)
@@ -2990,13 +2993,11 @@ void OpOddlprice::GenSlidingWindowFunction(std::stringstream &ss,
#ifdef ISNAN
ss << "{\n";
#endif
- nItems += 1;
}
else
{
#ifdef ISNAN
#endif
- nItems += 1;
}
#ifdef ISNAN
if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
@@ -3064,7 +3065,6 @@ void OpOddlyield::GenSlidingWindowFunction(std::stringstream &ss,
ss <<" double tmp5=0;\n";
ss <<" double tmp6=0;\n";
ss <<" double tmp7=0;\n";
- size_t nItems = 0;
ss <<" \n";
for (size_t i = 0; i < vSubArguments.size(); i++)
{
@@ -3105,7 +3105,6 @@ void OpOddlyield::GenSlidingWindowFunction(std::stringstream &ss,
ss << "0; i < "<< nCurWindowSize << "; i++)\n";
#endif
}
- nItems += nCurWindowSize;
}
else if (pCur->GetType() == formula::svSingleVectorRef)
{
@@ -3114,7 +3113,6 @@ void OpOddlyield::GenSlidingWindowFunction(std::stringstream &ss,
static_cast< const formula::SingleVectorRefToken* >(pCur);
ss << " if (gid0 < " << pSVR->GetArrayLength() << "){\n";
#else
- nItems += 1;
#endif
}
else if (pCur->GetType() == formula::svDouble)
@@ -3122,13 +3120,11 @@ void OpOddlyield::GenSlidingWindowFunction(std::stringstream &ss,
#ifdef ISNAN
ss << "{\n";
#endif
- nItems += 1;
}
else
{
#ifdef ISNAN
#endif
- nItems += 1;
}
#ifdef ISNAN
if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
@@ -3271,7 +3267,7 @@ void OpNper::GenSlidingWindowFunction(std::stringstream &ss,
ss <<" double tmp2=0;\n";
ss <<" double tmp3=0;\n";
ss <<" double tmp4=0;\n";
- size_t nItems = 0;
+
for (size_t i = 0; i < vSubArguments.size(); i++)
{
FormulaToken *pCur = vSubArguments[i]->GetFormulaToken();
@@ -3283,7 +3279,6 @@ void OpNper::GenSlidingWindowFunction(std::stringstream &ss,
static_cast< const formula::SingleVectorRefToken* >(pCur);
ss << " if (gid0 < " << pSVR->GetArrayLength() << "){\n";
#else
- nItems += 1;
#endif
}
else if (pCur->GetType() == formula::svDouble)
@@ -3291,13 +3286,11 @@ void OpNper::GenSlidingWindowFunction(std::stringstream &ss,
#ifdef ISNAN
ss << "{\n";
#endif
- nItems += 1;
}
else
{
#ifdef ISNAN
#endif
- nItems += 1;
}
#ifdef ISNAN
if(ocPush==vSubArguments[i]->GetFormulaToken()->GetOpCode())
@@ -5010,13 +5003,10 @@ vSubArguments)
const formula::SingleVectorRefToken*tmpCurDVR2= static_cast<const
formula::SingleVectorRefToken *>(tmpCur2);
- const formula::SingleVectorRefToken*tmpCurDVR3;
- const formula::SingleVectorRefToken*tmpCurDVR4;
-
if(vSubArguments.size()>3)
{
FormulaToken *tmpCur3 = vSubArguments[3]->GetFormulaToken();
- tmpCurDVR3= static_cast<const formula::SingleVectorRefToken *>(
+ const formula::SingleVectorRefToken* tmpCurDVR3= static_cast<const formula::SingleVectorRefToken *>(
tmpCur3);
ss<< " int buffer_zw_len = ";
ss<< tmpCurDVR3->GetArrayLength();
@@ -5026,7 +5016,7 @@ tmpCur3);
if(vSubArguments.size()>4)
{
FormulaToken *tmpCur4 = vSubArguments[4]->GetFormulaToken();
- tmpCurDVR4= static_cast<const formula::SingleVectorRefToken *>(
+ const formula::SingleVectorRefToken* tmpCurDVR4= static_cast<const formula::SingleVectorRefToken *>(
tmpCur4);
ss<< " int buffer_flag_len = ";
ss<< tmpCurDVR4->GetArrayLength();
diff --git a/sc/source/core/opencl/opbase.cxx b/sc/source/core/opencl/opbase.cxx
index 63c07b9..6bc5214 100644
--- a/sc/source/core/opencl/opbase.cxx
+++ b/sc/source/core/opencl/opbase.cxx
@@ -43,8 +43,6 @@ VectorRef::~VectorRef()
{
if (mpClmem) {
cl_int ret = clReleaseMemObject(mpClmem);
- if (ret != CL_SUCCESS)
- throw OpenCLError(ret, __FILE__, __LINE__);
}
}
diff --git a/sc/source/core/opencl/opencl_device.cxx b/sc/source/core/opencl/opencl_device.cxx
index 1a5edc5..9070cd8 100644
--- a/sc/source/core/opencl/opencl_device.cxx
+++ b/sc/source/core/opencl/opencl_device.cxx
@@ -226,11 +226,6 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData)
/* Evaluating an OpenCL device */
LOG_PRINTF("[DS] Device: \"" << device->oclDeviceName << "\" (OpenCL) evaluation...");
cl_int clStatus;
- cl_context clContext;
- cl_command_queue clQueue;
- cl_program clProgram;
- cl_kernel clKernel;
-
/* Check for 64-bit float extensions */
size_t aDevExtInfoSize = 0;
clStatus = clGetDeviceInfo(device->oclDeviceID, CL_DEVICE_EXTENSIONS, 0, NULL, &aDevExtInfoSize);
@@ -239,7 +234,6 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData)
char* aExtInfo = new char[aDevExtInfoSize];
clStatus = clGetDeviceInfo(device->oclDeviceID, CL_DEVICE_EXTENSIONS, sizeof(char) * aDevExtInfoSize, aExtInfo, NULL);
DS_CHECK_STATUS(clStatus, "evaluateScoreForDevice::clGetDeviceInfo");
-
bool bKhrFp64Flag = false;
bool bAmdFp64Flag = false;
const char* buildOption = NULL;
@@ -276,13 +270,13 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData)
/* 64-bit float support present */
/* Create context and command queue */
- clContext = clCreateContext(NULL, 1, &device->oclDeviceID, NULL, NULL, &clStatus);
+ cl_context clContext = clCreateContext(NULL, 1, &device->oclDeviceID, NULL, NULL, &clStatus);
DS_CHECK_STATUS(clStatus, "evaluateScoreForDevice::clCreateContext");
- clQueue = clCreateCommandQueue(clContext, device->oclDeviceID, 0, &clStatus);
+ cl_command_queue clQueue = clCreateCommandQueue(clContext, device->oclDeviceID, 0, &clStatus);
DS_CHECK_STATUS(clStatus, "evaluateScoreForDevice::clCreateCommandQueue");
/* Build program */
- clProgram = clCreateProgramWithSource(clContext, 1, &source, sourceSize, &clStatus);
+ cl_program clProgram = clCreateProgramWithSource(clContext, 1, &source, sourceSize, &clStatus);
DS_CHECK_STATUS(clStatus, "evaluateScoreForDevice::clCreateProgramWithSource");
clStatus = clBuildProgram(clProgram, 1, &device->oclDeviceID, buildOption, NULL, NULL);
DS_CHECK_STATUS(clStatus, "evaluateScoreForDevice::clBuildProgram");
@@ -293,7 +287,7 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData)
char* buildLog;
clStatus = clGetProgramBuildInfo(clProgram, device->oclDeviceID, CL_PROGRAM_BUILD_LOG, 0, NULL, &length);
buildLog = (char*)malloc(length);
- clStatus = clGetProgramBuildInfo(clProgram, device->oclDeviceID, CL_PROGRAM_BUILD_LOG, length, buildLog, &length);
+ clGetProgramBuildInfo(clProgram, device->oclDeviceID, CL_PROGRAM_BUILD_LOG, length, buildLog, &length);
LOG_PRINTF("[OCL] Build Errors" << std::endl << buildLog);
free(buildLog);
@@ -309,7 +303,7 @@ ds_status evaluateScoreForDevice(ds_device* device, void* evalData)
/* Run kernel */
LibreOfficeDeviceEvaluationIO* testData = (LibreOfficeDeviceEvaluationIO*)evalData;
- clKernel = clCreateKernel(clProgram, "DynamicKernel", &clStatus);
+ cl_kernel clKernel = clCreateKernel(clProgram, "DynamicKernel", &clStatus);
DS_CHECK_STATUS(clStatus, "evaluateScoreForDevice::clCreateKernel");
cl_mem clResult = clCreateBuffer(clContext, CL_MEM_WRITE_ONLY | CL_MEM_USE_HOST_PTR, sizeof(cl_double) * testData->outputSize, &testData->output[0], &clStatus);
DS_CHECK_STATUS(clStatus, "evaluateScoreForDevice::clCreateBuffer::clResult");
@@ -560,7 +554,7 @@ ds_device getDeviceSelection(const char* sProfilePath, bool bForceSelection)
bIsDeviceSelected = true;
/* Release profile */
- status = releaseDSProfile(profile, releaseScore);
+ releaseDSProfile(profile, releaseScore);
}
return selectedDevice;
}
commit fbbf5c089d9e102f819df752dce0e1b3223ad269
Author: haochen <haochen at multicorewareinc.com>
Date: Tue May 13 09:35:08 2014 +0800
GPU Calc: Fixed style&error problem in formulagroupcl and op_addin
Change-Id: Id7c6e341eb88f6c8ffdaa7f83b787bb19649afec
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index 7066c4f..4f40e25 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -31,7 +31,7 @@
/// CONFIGURATIONS
// Comment out this to turn off FMIN and FMAX intrinsics
#define USE_FMIN_FMAX 1
-#define REDUCE_THRESHOLD 4 // set to 4 for correctness testing. priority 1
+#define REDUCE_THRESHOLD 201 // set to 4 for correctness testing. priority 1
#define UNROLLING_FACTOR 16 // set to 4 for correctness testing (if no reduce)
#include "formulagroupcl_public.hxx"
#ifdef WIN32
@@ -1218,30 +1218,25 @@ public:
ss << "int nCount = 0;\n\t";
ss << "double tmpBottom;\n\t";
unsigned i = vSubArguments.size();
- size_t nItems = 0;
while (i--)
{
if (NumericRange *NR =
dynamic_cast<NumericRange *> (vSubArguments[i].get()))
{
- bool needBody;
- nItems += NR->GenReductionLoopHeader(ss, needBody);
- if (needBody == false) continue;
+ bool needBody;NR->GenReductionLoopHeader(ss, needBody);if (needBody == false) continue;
}
else if (ParallelNumericRange *PNR =
dynamic_cast<ParallelNumericRange *> (vSubArguments[i].get()))
{
//did not handle yet
- bool needBody;
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list