[Beignet] [PATCH] backend: add double version of sin
rander
rander.wang at intel.com
Thu Mar 30 07:12:21 UTC 2017
cp from 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 | 28 +++++++++++++++++++++++++
backend/src/libocl/tmpl/ocl_math_common.tmpl.h | 1 +
2 files changed, 29 insertions(+)
diff --git a/backend/src/libocl/tmpl/ocl_math_common.tmpl.cl b/backend/src/libocl/tmpl/ocl_math_common.tmpl.cl
index ee1cf0b..290ec6b 100644
--- a/backend/src/libocl/tmpl/ocl_math_common.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math_common.tmpl.cl
@@ -1704,6 +1704,34 @@ OVERLOADABLE double round(double x)
return dp;
}
+OVERLOADABLE double sin(double x)
+{
+ double y[2],z=0.0;
+ int n, ix;
+
+ /* High word of x. */
+ ix = __HI(x);
+
+ /* |x| ~< pi/4 */
+ ix &= 0x7fffffff;
+ if(ix <= 0x3fe921fb) return __kernel_sin(x,z,0);
+
+ /* sin(Inf or NaN) is NaN */
+ else if (ix>=0x7ff00000) return x-x;
+
+ /* argument reduction needed */
+ else {
+ n = __ieee754_rem_pio2(x,y);
+ switch(n&3) {
+ case 0: return __kernel_sin(y[0],y[1],1);
+ case 1: return __kernel_cos(y[0],y[1]);
+ case 2: return -__kernel_sin(y[0],y[1],1);
+ default:
+ return -__kernel_cos(y[0],y[1]);
+ }
+ }
+}
+
OVERLOADABLE double sqrt(double x)
{
double z;
diff --git a/backend/src/libocl/tmpl/ocl_math_common.tmpl.h b/backend/src/libocl/tmpl/ocl_math_common.tmpl.h
index d1c7fd0..ba246cc 100644
--- a/backend/src/libocl/tmpl/ocl_math_common.tmpl.h
+++ b/backend/src/libocl/tmpl/ocl_math_common.tmpl.h
@@ -54,6 +54,7 @@ OVERLOADABLE double nan(ulong code);
OVERLOADABLE double nextafter(double x, double y);
OVERLOADABLE double rint(double x);
OVERLOADABLE double round(double x);
+OVERLOADABLE double sin(double x);
OVERLOADABLE double sqrt(double x);
OVERLOADABLE double trunc(double x);
--
2.7.4
More information about the Beignet
mailing list