[Beignet] [PATCH] backend: add double support to fdim
rander
rander.wang at intel.com
Tue Mar 28 01:22:24 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 2ee797c..c781e5a 100644
--- a/backend/src/libocl/tmpl/ocl_math.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
@@ -3965,6 +3965,15 @@ OVERLOADABLE double fabs(double x)
return as_double(qw);
}
+OVERLOADABLE double fdim(double x, double y)
+{
+ if(isnan(x))
+ return x;
+ if(isnan(y))
+ return y;
+ return x > y ? (x - y) : +0.f;
+}
+
OVERLOADABLE double floor(double x)
{
ulong lval = as_ulong(x);
diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.h b/backend/src/libocl/tmpl/ocl_math.tmpl.h
index de79a5b..2eb4a2a 100644
--- a/backend/src/libocl/tmpl/ocl_math.tmpl.h
+++ b/backend/src/libocl/tmpl/ocl_math.tmpl.h
@@ -236,6 +236,7 @@ OVERLOADABLE float half_tan(float x);
OVERLOADABLE double ceil(double x);
OVERLOADABLE double copysign(double x, double y);
OVERLOADABLE double fabs(double x);
+OVERLOADABLE double fdim(double x, double y);
OVERLOADABLE double floor(double x);
OVERLOADABLE double fmax(double a, double b);
OVERLOADABLE double fmin(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 4f1461b..d410a14 100644
--- a/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl
@@ -3841,6 +3841,15 @@ OVERLOADABLE double fabs(double x)
return as_double(qw);
}
+OVERLOADABLE double fdim(double x, double y)
+{
+ if(isnan(x))
+ return x;
+ if(isnan(y))
+ return y;
+ return x > y ? (x - y) : +0.f;
+}
+
OVERLOADABLE double floor(double x)
{
ulong lval = 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 3ca2b35..8072fa0 100644
--- a/backend/src/libocl/tmpl/ocl_math_20.tmpl.h
+++ b/backend/src/libocl/tmpl/ocl_math_20.tmpl.h
@@ -213,6 +213,7 @@ OVERLOADABLE float half_tan(float x);
OVERLOADABLE double ceil(double x);
OVERLOADABLE double copysign(double x, double y);
OVERLOADABLE double fabs(double x);
+OVERLOADABLE double fdim(double x, double y);
OVERLOADABLE double fmax(double a, double b);
OVERLOADABLE double fmin(double a, double b);
OVERLOADABLE double floor(double x);
--
2.7.4
More information about the Beignet
mailing list