summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authoryiming ju <yiming@multicorewareinc.com>2013-11-08 13:19:10 +0800
committerI-Jui (Ray) Sung <ray@multicorewareinc.com>2013-11-14 14:09:45 -0600
commit374f670aea4c2581c1e813c39571819fecdff4f4 (patch)
treeef139275cfb7cadb8d2539e322859ff341d10ffc /sc
parenta6ec887150d07ededcc2c333d60237581b28442f (diff)
GPU Calc: implemented CHISQINV
AMLOEXT-148 FIX Change-Id: I2f41abf89b8714e854efde85b88c2c2998d6da1a Refacotring: convert fmax&fmin to max&min Signed-off-by: haochen <haochen@multicorewareinc.com> Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/opencl/formulagroupcl.cxx12
-rw-r--r--sc/source/core/opencl/op_statistical.cxx55
-rw-r--r--sc/source/core/opencl/op_statistical.hxx10
-rw-r--r--sc/source/core/opencl/opinlinefun_statistical.cxx20
4 files changed, 83 insertions, 14 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index a4e99e0d172d..e75ef48feb24 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -696,9 +696,9 @@ public:
virtual std::string GetBottom(void) { return "MAXFLOAT"; }
virtual std::string Gen2(const std::string &lhs, const std::string &rhs) const
{
- return "fmin("+lhs + "," + rhs +")";
+ return "min("+lhs + "," + rhs +")";
}
- virtual std::string BinFuncName(void) const { return "fmin"; }
+ virtual std::string BinFuncName(void) const { return "min"; }
};
class OpMax: public Reduction {
@@ -706,9 +706,9 @@ public:
virtual std::string GetBottom(void) { return "-MAXFLOAT"; }
virtual std::string Gen2(const std::string &lhs, const std::string &rhs) const
{
- return "fmax("+lhs + "," + rhs +")";
+ return "max("+lhs + "," + rhs +")";
}
- virtual std::string BinFuncName(void) const { return "fmax"; }
+ virtual std::string BinFuncName(void) const { return "max"; }
};
class OpSumProduct: public SumOfProduct {
public:
@@ -1232,6 +1232,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i],new OpChiSqDist));
break;
+ case ocChiSqInv:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i],new OpChiSqInv));
+ 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 a9cfbd2b1530..88ccdab7892d 100644
--- a/sc/source/core/opencl/op_statistical.cxx
+++ b/sc/source/core/opencl/op_statistical.cxx
@@ -3000,6 +3000,61 @@ vSubArguments)
}
+ void OpChiSqInv::BinInlineFun(std::set<std::string>& decls,
+ std::set<std::string>& funs)
+{
+ decls.insert(fMaxGammaArgumentDecl);decls.insert(GetChiSqDistCDFDecl);
+ decls.insert(GetLowRegIGammaDecl);decls.insert(lcl_IterateInverseChiSQInvDecl);
+ decls.insert(GetGammaContFractionDecl);decls.insert(GetGammaSeriesDecl);
+ decls.insert(fHalfMachEpsDecl);decls.insert(F_PIDecl);
+ decls.insert(fBigInvDecl);decls.insert(lcl_HasChangeOfSignDecl);
+ decls.insert(fMachEpsDecl);
+
+ funs.insert(GetGammaContFraction);funs.insert(GetChiSqDistCDF);
+ funs.insert(GetLowRegIGamma);funs.insert(lcl_HasChangeOfSign);
+ funs.insert(GetGammaSeries);funs.insert(lcl_IterateInverseChiSQInv);
+}
+
+void OpChiSqInv::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 << " int singleIndex = gid0;\n";
+ ss << " double result = 0;\n";
+ if(vSubArguments.size()!=2)
+ {
+ ss << " result = -DBL_MAX;\n";
+ ss << " return result;\n";
+ }else
+ {
+ GenTmpVariables(ss,vSubArguments);
+ CheckAllSubArgumentIsNan(ss,vSubArguments);
+ ss << " tmp1 = floor(tmp1);\n";
+ ss << " bool bConvError;\n";
+ ss << " if(tmp1 < 1.0 || tmp0 < 0 || tmp0>=1.0)\n";
+ ss << " result = -DBL_MAX;\n";
+ ss << " else\n";
+ ss << " {\n";
+ ss << " result =lcl_IterateInverseChiSQInv( tmp0, tmp1,";
+ ss << "tmp1*0.5, tmp1, &bConvError );\n";
+ ss << " }\n";
+ ss << " if(bConvError)\n";
+ ss << " result = -DBL_MAX;\n";
+ ss << " return result;\n";
+ ss << "}";
+ }
+
+}
}}
diff --git a/sc/source/core/opencl/op_statistical.hxx b/sc/source/core/opencl/op_statistical.hxx
index ea006f79cda0..e609dc04b039 100644
--- a/sc/source/core/opencl/op_statistical.hxx
+++ b/sc/source/core/opencl/op_statistical.hxx
@@ -261,6 +261,16 @@ public:
virtual std::string BinFuncName(void) const { return "ChiSqDist"; }
virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& );
};
+
+class OpChiSqInv: public CheckVariables
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual std::string BinFuncName(void) const { return "ChiSqInv"; }
+ virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>& );
+};
+
}}
#endif
diff --git a/sc/source/core/opencl/opinlinefun_statistical.cxx b/sc/source/core/opencl/opinlinefun_statistical.cxx
index f9d357995f62..b97dd11c7d98 100644
--- a/sc/source/core/opencl/opinlinefun_statistical.cxx
+++ b/sc/source/core/opencl/opinlinefun_statistical.cxx
@@ -628,17 +628,17 @@ std::string lcl_IterateInverseChiSQInv =
" double fYEps = 1.0E-307;\n"
" double fXEps = fMachEps;\n"
-" if(!(fAx < fBx))\n"
-" {\n"
-" //print error\n"
-" }\n"
-" double fAy = fp - GetChiSqDistCDF(fAx, fdf);\n"
-" double fBy = fp - GetChiSqDistCDF(fBx, fdf);\n"
-" double fTemp;\n"
-" unsigned short nCount;\n"
-" for (nCount = 0; nCount < 1000 && !lcl_HasChangeOfSign(fAy,fBy);"
+" if(!(fAx < fBx))\n"
+" {\n"
+" //print error\n"
+" }\n"
+" double fAy = fp - GetChiSqDistCDF(fAx, fdf);\n"
+" double fBy = fp - GetChiSqDistCDF(fBx, fdf);\n"
+" double fTemp;\n"
+" unsigned short nCount;\n"
+" for (nCount = 0; nCount < 1000 && !lcl_HasChangeOfSign(fAy,fBy);"
" nCount++)\n"
-" {\n"
+" {\n"
" if (fabs(fAy) <= fabs(fBy))\n"
" {\n"
" fTemp = fAx;\n"