summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authoryiming ju <yiming@multicorewareinc.com>2013-12-12 15:16:34 +0800
committerI-Jui (Ray) Sung <ray@multicorewareinc.com>2013-12-19 17:53:52 -0600
commit2ebc7c6ab819771514d7405adb286bad1fa5b489 (patch)
treee098fe878250425c4efaa7828ce03cc1b90d73e5 /sc
parenta7859b3c6a2710e9b1d90f040c0d31b7606b013a (diff)
GPU Calc: implemented ROUNDDOWN
AMLOEXT-352 FIX Change-Id: I68cce5d17a3ab6aacf1f20bae1baa09604015238 Signed-off-by: haochen <haochen@multicorewareinc.com> Signed-off-by: Wei Wei <weiwei@multicorewareinc.com> Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/opencl/formulagroupcl.cxx4
-rw-r--r--sc/source/core/opencl/op_math.cxx33
-rw-r--r--sc/source/core/opencl/op_math.hxx7
3 files changed, 44 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index ebce006a6198..cd4e1f407799 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -2428,6 +2428,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i],new OpRoundUp));
break;
+ case ocRoundDown:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i],new OpRoundDown));
+ 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 4368f7eb9ffd..18b0480e8f70 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1493,6 +1493,39 @@ void OpRoundUp::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return tmp;\n";
ss << "}";
}
+void OpRoundDown::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{\n";
+ ss << " int gid0=get_global_id(0);\n";
+ ss << " int singleIndex = gid0;\n";
+ ss << " int intTmp;\n";
+ ss << " double tmp;\n";
+ GenTmpVariables(ss,vSubArguments);
+ CheckAllSubArgumentIsNan(ss,vSubArguments);
+ ss << " if(tmp1 >20 || tmp1 < -20)";
+ ss << " {\n";
+ ss << " tmp = NAN;\n";
+ ss << " }else\n";
+ ss << " {\n";
+ ss << " for(int i=0;i<tmp1;i++)\n";
+ ss << " tmp0 = tmp0 * 10;\n";
+ ss << " intTmp = (int)tmp0;\n";
+ ss << " tmp = intTmp;\n";
+ ss << " for(int i=0;i<tmp1;i++)\n";
+ ss << " tmp = tmp / 10;\n";
+ ss << " }\n";
+ ss << " return tmp;\n";
+ ss << "}";
+}
void OpOdd::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 b59e798c71f6..ce06d8f82a17 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -221,6 +221,13 @@ public:
const std::string sSymName, SubArguments &vSubArguments);
virtual std::string BinFuncName(void) const { return "RoundUp"; }
};
+class OpRoundDown: public CheckVariables
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments);
+ virtual std::string BinFuncName(void) const { return "RoundDown"; }
+};
class OpCot: public Normal
{
public: