[Beignet] [PATCH] backend: add double support to copysign

rander rander.wang at intel.com
Mon Mar 27 09:43:58 UTC 2017


Signed-off-by: rander <rander.wang at intel.com>
---
 backend/src/libocl/tmpl/ocl_math.tmpl.cl    | 9 +++++++++
 backend/src/libocl/tmpl/ocl_math.tmpl.h     | 1 +
 backend/src/libocl/tmpl/ocl_math_20.tmpl.cl | 9 +++++++++
 backend/src/libocl/tmpl/ocl_math_20.tmpl.h  | 1 +
 4 files changed, 20 insertions(+)

diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.cl b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
index 65cd7fc..2ee797c 100644
--- a/backend/src/libocl/tmpl/ocl_math.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
@@ -3949,6 +3949,15 @@ OVERLOADABLE double ceil(double x)
      return ret;
 }
 
+OVERLOADABLE double copysign(double x, double y)
+{
+	ulong uy = as_ulong(y);
+	ulong sign = uy & DF_SIGN_MASK;
+	ulong ux = as_ulong(x);
+	ux = (ux & DF_ABS_MASK) | sign;
+	return as_double(ux);
+}
+
 OVERLOADABLE double fabs(double x)
 {
     long  qw = as_ulong(x);
diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.h b/backend/src/libocl/tmpl/ocl_math.tmpl.h
index e4d2e55..de79a5b 100644
--- a/backend/src/libocl/tmpl/ocl_math.tmpl.h
+++ b/backend/src/libocl/tmpl/ocl_math.tmpl.h
@@ -234,6 +234,7 @@ OVERLOADABLE float half_tan(float x);
 
 //------- double -----------
 OVERLOADABLE double ceil(double x);
+OVERLOADABLE double copysign(double x, double y);
 OVERLOADABLE double fabs(double x);
 OVERLOADABLE double floor(double x);
 OVERLOADABLE double fmax(double a, double b);
diff --git a/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl b/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl
index 69716ad..4f1461b 100644
--- a/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl
@@ -3825,6 +3825,15 @@ OVERLOADABLE double ceil(double x)
      return ret;
 }
 
+OVERLOADABLE double copysign(double x, double y)
+{
+	ulong uy = as_ulong(y);
+	ulong sign = uy & DF_SIGN_MASK;
+	ulong ux = as_ulong(x);
+	ux = (ux & DF_ABS_MASK) | sign;
+	return as_double(ux);
+}
+
 OVERLOADABLE double fabs(double x)
 {
     long  qw = as_ulong(x);
diff --git a/backend/src/libocl/tmpl/ocl_math_20.tmpl.h b/backend/src/libocl/tmpl/ocl_math_20.tmpl.h
index a3d9578..3ca2b35 100644
--- a/backend/src/libocl/tmpl/ocl_math_20.tmpl.h
+++ b/backend/src/libocl/tmpl/ocl_math_20.tmpl.h
@@ -211,6 +211,7 @@ OVERLOADABLE float half_tan(float x);
 
 //------- double -----------
 OVERLOADABLE double ceil(double x);
+OVERLOADABLE double copysign(double x, double y);
 OVERLOADABLE double fabs(double x);
 OVERLOADABLE double fmax(double a, double b);
 OVERLOADABLE double fmin(double a, double b);
-- 
2.7.4



More information about the Beignet mailing list