summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfengzeng <fengzeng@multicorewareinc.com>2013-12-05 09:36:46 +0800
committerI-Jui (Ray) Sung <ray@multicorewareinc.com>2013-12-18 20:34:58 -0600
commite0c571adbc959c87a777675af571cb21c667e0f1 (patch)
tree3112885f491674dfe6cdc4e3dd531fc1b32aec73
parent821e19f227dba1fd2fbe63475e30559f06db4652 (diff)
GPU Calc: Optimized TAN
AMLOEXT-274 Change-Id: I971bb4a44ff68af5c9fc952419e7035d1127fd5f 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>
-rw-r--r--sc/source/core/opencl/op_math.cxx47
1 files changed, 34 insertions, 13 deletions
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 3ae28bc20f7e..bf2e92c0c8aa 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -956,30 +956,51 @@ void OpArcCosHyp::GenSlidingWindowFunction(std::stringstream &ss,
void OpTan::GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments)
{
- FormulaToken *tmpCur = vSubArguments[0]->GetFormulaToken();
- const formula::SingleVectorRefToken*tmpCurDVR= dynamic_cast<const
- formula::SingleVectorRefToken *>(tmpCur);
ss << "\ndouble " << sSymName;
ss << "_"<< BinFuncName() <<"(";
for (unsigned i = 0; i < vSubArguments.size(); i++)
{
- if (i)
- ss << ",";
+ if (i) ss << ",";
vSubArguments[i]->GenSlidingWindowDecl(ss);
}
ss << ")\n";
ss << "{\n";
ss << " int gid0=get_global_id(0);\n";
- ss << " double arg0 = "<< vSubArguments[0]->GenSlidingWindowDeclRef();
- ss << ";\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=
+ dynamic_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";
- ss << " arg0 = 0;\n";
+ ss << " if(isNan(";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ")||(gid0>=";
+ ss << tmpCurDVR->GetArrayLength();
+ ss << "))\n";
+ ss << " { arg0 = 0.0f; }\n";
#endif
- ss << " double tmp=tan(arg0);\n";
- ss << " return tmp;\n";
+ }
+ else if(tmpCur->GetType() == formula::svDouble)
+ {
+ ss << " arg0=" << tmpCur->GetDouble() << ";\n";
+ }
+ }
+ else
+ {
+ ss << " arg0 = ";
+ ss << vSubArguments[0]->GenSlidingWindowDeclRef();
+ ss << ";\n";
+ }
+ ss << " arg0 = arg0 * M_1_PI;\n";
+ ss << " return sinpi(arg0) * pow(cospi(arg0), -1);\n";
ss << "}";
}
void OpTanH::GenSlidingWindowFunction(std::stringstream &ss,