summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorhaochen <haochen@multicorewareinc.com>2014-05-29 09:14:53 +0800
committerMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-06-10 15:58:26 +0200
commit0fa58160b90aa9817e5a6fb18c7427895f4b2f4f (patch)
tree1b87a1371f637dbb1ea4ed30105727f4638c4896 /sc
parentc3383aafa18ef9d03b04b2a4719e71fdfabc14eb (diff)
GPU Calc:Support IF formula in GPUInterpret
Change-Id: I9b2cebb99812d28e25c961129f73585d60690846
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/opencl/formulagroupcl.cxx19
-rw-r--r--sc/source/core/opencl/op_logical.cxx37
-rw-r--r--sc/source/core/opencl/op_logical.hxx7
3 files changed, 63 insertions, 0 deletions
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index c0b62f29f154..91a54f4b81c1 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -1682,6 +1682,18 @@ public:
}
virtual std::string BinFuncName(void) const SAL_OVERRIDE { return "leq"; }
};
+class OpLess: public Binary {
+public:
+ virtual std::string GetBottom(void) SAL_OVERRIDE { return "0"; }
+ virtual std::string Gen2(const std::string &lhs, const std::string &rhs) const SAL_OVERRIDE
+ {
+ std::stringstream ss;
+ ss << "("<< lhs << "<" << rhs <<")";
+ return ss.str();
+ }
+ virtual std::string BinFuncName(void) const SAL_OVERRIDE { return "less"; }
+};
+
class OpGreater: public Binary {
public:
@@ -2267,6 +2279,9 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
case ocLessEqual:
mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpLessEqual));
break;
+ case ocLess:
+ mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpLess));
+ break;
case ocEqual:
mvSubArguments.push_back(SoPHelper(ts, ft->Children[i], new OpEqual));
break;
@@ -2872,6 +2887,10 @@ DynamicKernelSoPArguments::DynamicKernelSoPArguments(
mvSubArguments.push_back(SoPHelper(ts,
ft->Children[i], new OpAveDev));
break;
+ case ocIf:
+ mvSubArguments.push_back(SoPHelper(ts,
+ ft->Children[i], new OpIf));
+ break;
case ocExternal:
if ( !(pChild->GetExternal().compareTo(OUString(
"com.sun.star.sheet.addin.Analysis.getEffect"))))
diff --git a/sc/source/core/opencl/op_logical.cxx b/sc/source/core/opencl/op_logical.cxx
index 79dc74a71094..9dce77b73306 100644
--- a/sc/source/core/opencl/op_logical.cxx
+++ b/sc/source/core/opencl/op_logical.cxx
@@ -314,6 +314,43 @@ void OpXor::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return t;\n";
ss << "}\n";
}
+void OpIf::GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string &sSymName, SubArguments &vSubArguments)
+{
+ ss << "\ndouble " << sSymName;
+ ss << "_"<< BinFuncName() <<"(";
+ if(vSubArguments.size()!=3) throw Unhandled("unknown operand for ocPush");
+ 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";
+
+ FormulaToken *tmpCur0 = vSubArguments[0]->GetFormulaToken();
+ if(tmpCur0->GetType() == formula::svDoubleVectorRef)
+ {
+ throw UnhandledToken(tmpCur0, "unknown operand for ocPush");
+ }
+ else
+ {
+ ss << " if(isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ")|| ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << " == 0)\n";
+ ss << " return ";
+ ss << vSubArguments[2]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ ss << " else";
+ ss <<" return ";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef();
+ ss <<";\n";
+ }
+ ss << "}\n";
+}
}}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/opencl/op_logical.hxx b/sc/source/core/opencl/op_logical.hxx
index 357ddd81771b..4365a57e7625 100644
--- a/sc/source/core/opencl/op_logical.hxx
+++ b/sc/source/core/opencl/op_logical.hxx
@@ -44,6 +44,13 @@ public:
const std::string &sSymName, SubArguments &vSubArguments) SAL_OVERRIDE;
virtual std::string BinFuncName(void) const SAL_OVERRIDE { return "Xor"; }
};
+class OpIf:public Normal
+{
+public:
+ virtual void GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string &sSymName, SubArguments &vSubArguments) SAL_OVERRIDE;
+ virtual std::string BinFuncName(void) const SAL_OVERRIDE { return "IF"; }
+};
}}