summaryrefslogtreecommitdiff
path: root/sc/source/core/opencl/op_math.cxx
diff options
context:
space:
mode:
authoryangzhang <yangzhang@multicorewareinc.com>2013-11-10 10:02:00 +0800
committerI-Jui (Ray) Sung <ray@multicorewareinc.com>2013-11-14 20:30:44 -0600
commitf928820af4234725c98dd82e997ead2b1966a0dc (patch)
tree0666af119df8d82fddda7ad674d68a3d10dfdc77 /sc/source/core/opencl/op_math.cxx
parentdfbd51822f16e45036a198217863f670a7d8f609 (diff)
GPU Calc: implemented BITLSHFIT
AMLOEXT-167 FIX Change-Id: Ia91542a64c44d541114fee3c3655120d0350a286 Signed-off-by: haochen <haochen@multicorewareinc.com> Signed-off-by: I-Jui (Ray) Sung <ray@multicorewareinc.com>
Diffstat (limited to 'sc/source/core/opencl/op_math.cxx')
-rw-r--r--sc/source/core/opencl/op_math.cxx45
1 files changed, 44 insertions, 1 deletions
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 5ba599d71827..c6e1f7e88d6a 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1422,7 +1422,50 @@ void OpBitOr::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return (long)num1 | (long)num2;\n";
ss << "}";
}
-
+void OpBitLshift::GenSlidingWindowFunction(std::stringstream &ss,
+ const std::string sSymName, SubArguments &vSubArguments)
+{
+ ss << "\ndouble " << sSymName;
+ ss << "_"<< BinFuncName() <<"(";
+ for (unsigned i = 0; i < vSubArguments.size(); i++)
+ {
+ if (i) ss << ",";
+ vSubArguments[i]->GenSlidingWindowDecl(ss);
+ }
+ ss << ") {\n";
+ ss << " int gid0 = get_global_id(0);\n";
+ ss << " double num = " << GetBottom() << ";\n";
+ ss << " double shift_amount = " << GetBottom() << ";\n";
+#ifdef ISNAN
+ FormulaToken *iNum = vSubArguments[0]->GetFormulaToken();
+ const formula::SingleVectorRefToken* tmpCurDVRNum=
+ dynamic_cast<const formula::SingleVectorRefToken*>(iNum);
+ FormulaToken *iShiftAmount = vSubArguments[1]->GetFormulaToken();
+ const formula::SingleVectorRefToken* tmpCurDVRShiftAmount=
+ dynamic_cast<const formula::SingleVectorRefToken*>(iShiftAmount);
+ ss << " int buffer_num_len = "<< tmpCurDVRNum->GetArrayLength()<<";\n";
+ ss << " int buffer_shift_amount_len = ";
+ ss << tmpCurDVRShiftAmount->GetArrayLength() << ";\n";
+ ss << " if((gid0)>=buffer_num_len || isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << "))\n";
+ ss << " num = " << GetBottom() << ";\n";
+ ss << " else\n ";
+#endif
+ ss << " num = floor(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef() << ");\n";
+#ifdef ISNAN
+ ss << " if((gid0)>=buffer_shift_amount_len || isNan(";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << "))\n";
+ ss << " shift_amount = " << GetBottom() << ";\n";
+ ss << " else\n ";
+#endif
+ ss << " shift_amount = floor(";
+ ss << vSubArguments[1]->GenSlidingWindowDeclRef() << ");\n";
+ ss << " return floor(" << "shift_amount >= 0 ? ";
+ ss << "num * pow(2.0, shift_amount) : ";
+ ss << "num / pow(2.0, fabs(shift_amount)));\n";
+ ss << "}";
+}
}}