[Beignet] [PATCH] backend: add double version of asinh
rander
rander.wang at intel.com
Thu Mar 30 06:15:42 UTC 2017
cp form fdlibm and pass the cft after refined
Signed-off-by: rander <rander.wang at intel.com>
---
backend/src/libocl/tmpl/ocl_math_common.tmpl.cl | 26 +++++++++++++++++++++++++
backend/src/libocl/tmpl/ocl_math_common.tmpl.h | 1 +
2 files changed, 27 insertions(+)
diff --git a/backend/src/libocl/tmpl/ocl_math_common.tmpl.cl b/backend/src/libocl/tmpl/ocl_math_common.tmpl.cl
index 051eae1..e655955 100644
--- a/backend/src/libocl/tmpl/ocl_math_common.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math_common.tmpl.cl
@@ -210,6 +210,32 @@ OVERLOADABLE double asinpi(double x)
return asin(x)/M_PI;
}
+OVERLOADABLE double asinh(double x)
+{
+ double one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
+ ln2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */
+ huge= 1.00000000000000000000e+300;
+ double t,w;
+
+ int hx,ix;
+ hx = __HI(x);
+ ix = hx&0x7fffffff;
+ if(ix>=0x7ff00000) return x+x; /* x is inf or NaN */
+ if(ix< 0x3e300000) { /* |x|<2**-28 */
+ if(huge+x>one) return x; /* return x inexact except 0 */
+ }
+ if(ix>0x41b00000) { /* |x| > 2**28 */
+ w = log(fabs(x))+ln2;
+ } else if (ix>0x40000000) { /* 2**28 > |x| > 2.0 */
+ t = fabs(x);
+ w = log(2.0*t+one/(sqrt(x*x+one)+t));
+ } else { /* 2.0 > |x| > 2**-28 */
+ t = x*x;
+ w =log1p(fabs(x)+t/(one+sqrt(one+t)));
+ }
+ if(hx>0) return w; else return -w;
+}
+
OVERLOADABLE double ceil(double x)
{
double ret;
diff --git a/backend/src/libocl/tmpl/ocl_math_common.tmpl.h b/backend/src/libocl/tmpl/ocl_math_common.tmpl.h
index fa4a260..56c9787 100644
--- a/backend/src/libocl/tmpl/ocl_math_common.tmpl.h
+++ b/backend/src/libocl/tmpl/ocl_math_common.tmpl.h
@@ -25,6 +25,7 @@ OVERLOADABLE double acospi(double x);
OVERLOADABLE double acosh(double x);
OVERLOADABLE double asin(double x);
OVERLOADABLE double asinpi(double x);
+OVERLOADABLE double asinh(double x);
OVERLOADABLE double ceil(double x);
OVERLOADABLE double copysign(double x, double y);
OVERLOADABLE double fabs(double x);
--
2.7.4
More information about the Beignet
mailing list