[Beignet] [PATCH 10/10] Backend: add double support to max, min, min, step Also add other function in headfile to compile successfully
rander
rander.wang at intel.com
Tue Mar 7 06:37:12 UTC 2017
Signed-off-by: rander <rander.wang at intel.com>
---
backend/src/libocl/tmpl/ocl_common.tmpl.cl | 24 ++++++++++++++++++++++++
backend/src/libocl/tmpl/ocl_common.tmpl.h | 11 +++++++++++
2 files changed, 35 insertions(+)
diff --git a/backend/src/libocl/tmpl/ocl_common.tmpl.cl b/backend/src/libocl/tmpl/ocl_common.tmpl.cl
index 0b6a8fb..af516de 100644
--- a/backend/src/libocl/tmpl/ocl_common.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_common.tmpl.cl
@@ -26,6 +26,9 @@ PURE CONST OVERLOADABLE float __gen_ocl_fmax(float a, float b);
PURE CONST OVERLOADABLE float __gen_ocl_fmin(float a, float b);
PURE CONST OVERLOADABLE float __gen_ocl_lrp(float a, float b, float c);
+PURE CONST OVERLOADABLE double __gen_ocl_fmax(double a, double b);
+PURE CONST OVERLOADABLE double __gen_ocl_fmin(double a, double b);
+
OVERLOADABLE float step(float edge, float x) {
return x < edge ? 0.0 : 1.0;
}
@@ -118,3 +121,24 @@ OVERLOADABLE half sign(half x) {
s = (x == (half)0.0) ? s : r;
return isnan(x) ? 0.0 : s;
}
+
+OVERLOADABLE double step(double edge, double x)
+{
+ return x < edge ? 0.0 : 1.0;
+}
+
+OVERLOADABLE double max(double a, double b)
+{
+ return __gen_ocl_fmax(a, b);
+}
+
+OVERLOADABLE double min(double a, double b)
+{
+ return __gen_ocl_fmin(a, b);
+}
+
+OVERLOADABLE double mix(double x, double y, double a)
+{
+ return x + (y-x)*a;
+}
+
diff --git a/backend/src/libocl/tmpl/ocl_common.tmpl.h b/backend/src/libocl/tmpl/ocl_common.tmpl.h
index 8e9cec0..5ea0b40 100644
--- a/backend/src/libocl/tmpl/ocl_common.tmpl.h
+++ b/backend/src/libocl/tmpl/ocl_common.tmpl.h
@@ -47,3 +47,14 @@ OVERLOADABLE half radians(half degrees);
OVERLOADABLE half smoothstep(half e0, half e1, half x);
OVERLOADABLE half sign(half x);
+
+OVERLOADABLE double step(double edge, double x);
+OVERLOADABLE double max(double a, double b);
+OVERLOADABLE double min(double a, double b);
+OVERLOADABLE double mix(double x, double y, double a);
+OVERLOADABLE double clamp(double v, double l, double u);
+OVERLOADABLE double degrees(double radians);
+OVERLOADABLE double radians(double degrees);
+OVERLOADABLE double smoothstep(double e0, double e1, double x);
+OVERLOADABLE double sign(double x);
+
--
2.7.4
More information about the Beignet
mailing list