summaryrefslogtreecommitdiff
path: root/sc/source/core/opencl
diff options
context:
space:
mode:
authoryangzhang <yangzhang@multicorewareinc.com>2013-12-20 13:55:26 +0800
committerI-Jui (Ray) Sung <ray@multicorewareinc.com>2013-12-23 16:51:31 -0600
commitf48749354f018ef41b135bad0d433d94778accd5 (patch)
tree79a9ab2dc970f71add76027b5202fd38c4635153 /sc/source/core/opencl
parentbc7c98cf20c1b39edf6d832e3fb09e550df2e485 (diff)
GPU Calc: Optimized ATAN2
AMLOEXT-349 Change-Id: Ifd9532d7b73afee1a0d6eb8f2d4522e0356006f5 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/source/core/opencl')
-rw-r--r--sc/source/core/opencl/op_math.cxx8
-rw-r--r--sc/source/core/opencl/op_math.hxx1
-rw-r--r--sc/source/core/opencl/opinlinefun_math.hxx29
3 files changed, 37 insertions, 1 deletions
diff --git a/sc/source/core/opencl/op_math.cxx b/sc/source/core/opencl/op_math.cxx
index 3958781a6512..85fdfa1177c5 100644
--- a/sc/source/core/opencl/op_math.cxx
+++ b/sc/source/core/opencl/op_math.cxx
@@ -1396,6 +1396,12 @@ void OpArcSinHyp::GenSlidingWindowFunction(std::stringstream &ss,
ss << " return log( tmp + pow((pown(tmp, 2) + 1.0), 0.5));\n";
ss << "}";
}
+void OpArcTan2::BinInlineFun(std::set<std::string>& decls,
+ std::set<std::string>& funs)
+{
+ decls.insert(atan2Decl);
+ funs.insert(atan2Content);
+}
void OpArcTan2::GenSlidingWindowFunction(std::stringstream &ss,
const std::string sSymName, SubArguments &vSubArguments)
{
@@ -1432,7 +1438,7 @@ void OpArcTan2::GenSlidingWindowFunction(std::stringstream &ss,
ss << " else \n ";
#endif
ss << " y_num = "<< vSubArguments[1]->GenSlidingWindowDeclRef() << ";\n";
- ss << " return atan2(y_num, x_num);\n";
+ ss << " return arctan2(y_num, x_num);\n";
ss << "}";
}
void OpArcTan::GenSlidingWindowFunction(std::stringstream &ss,
diff --git a/sc/source/core/opencl/op_math.hxx b/sc/source/core/opencl/op_math.hxx
index b0d79807bca8..a174bef0da61 100644
--- a/sc/source/core/opencl/op_math.hxx
+++ b/sc/source/core/opencl/op_math.hxx
@@ -175,6 +175,7 @@ public:
const std::string sSymName, SubArguments &vSubArguments);
virtual std::string GetBottom(void) { return "0.0"; }
virtual std::string BinFuncName(void) const { return "ScATan2"; }
+ virtual void BinInlineFun(std::set<std::string>& ,std::set<std::string>&);
};
class OpArcTan:public Normal{
public:
diff --git a/sc/source/core/opencl/opinlinefun_math.hxx b/sc/source/core/opencl/opinlinefun_math.hxx
index b641c522e898..a8130919245a 100644
--- a/sc/source/core/opencl/opinlinefun_math.hxx
+++ b/sc/source/core/opencl/opinlinefun_math.hxx
@@ -56,6 +56,35 @@ std::string local_cosh =
" double nVal = (exp(n) + exp(-n)) / 2;\n"
" return nVal;\n"
"}\n";
+std::string atan2Decl = "double arctan2(double y, double x);\n";
+std::string atan2Content =
+"double arctan2(double y, double x)\n"
+"{\n"
+" if(y==0.0)\n"
+" return 0.0;\n"
+" double a,num,den,tmpPi;\n"
+" int flag;\n"
+" tmpPi = 0;\n"
+" if (fabs(x) >= fabs(y))\n"
+" {\n"
+" num = y;\n"
+" den = x;\n"
+" flag = 1;\n"
+" if (x < 0.0)\n"
+" tmpPi = M_PI;\n"
+" }\n"
+" if(fabs(x) < fabs(y))\n"
+" {\n"
+" num = x;\n"
+" den = y;\n"
+" flag = -1;\n"
+" tmpPi = M_PI_2;\n"
+" }\n"
+" a = atan(num/den);\n"
+" a = flag==1?a:-a;\n"
+" a = a + (y >= 0.0 ? tmpPi : -tmpPi);\n"
+" return a;\n"
+"}\n";
#endif //SC_OPENCL_OPINLINFUN_MATH