[Beignet] [PATCH] backend: add double support to fmax
rander
rander.wang at intel.com
Mon Mar 27 09:40:05 UTC 2017
Signed-off-by: rander <rander.wang at intel.com>
---
backend/src/libocl/tmpl/ocl_math.tmpl.cl | 15 +++++++++++++++
backend/src/libocl/tmpl/ocl_math.tmpl.h | 2 ++
backend/src/libocl/tmpl/ocl_math_20.tmpl.cl | 11 +++++++++++
backend/src/libocl/tmpl/ocl_math_20.tmpl.h | 2 ++
4 files changed, 30 insertions(+)
diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.cl b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
index d526d6c..6978c92 100644
--- a/backend/src/libocl/tmpl/ocl_math.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
@@ -4333,3 +4333,18 @@ OVERLOADABLE double mad(double a, double b, double c)
return __gen_ocl_mad(a, b, c);
}
+OVERLOADABLE double fmax(double a, double b)
+{
+ ulong ua = as_ulong(a);
+ ulong ub =as_ulong(b);
+
+ if((ua & DF_ABS_MASK) > DF_MAX_NORMAL) return b;
+ if((ub & DF_ABS_MASK) > DF_MAX_NORMAL) return a;
+ if(ua == DF_POSITIVE_INF) return a;
+ if(ub == DF_POSITIVE_INF) return b;
+
+ double c = a - b;
+ return (c >= 0) ? a:b;
+}
+
+
diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.h b/backend/src/libocl/tmpl/ocl_math.tmpl.h
index 852bf47..1bf9b9a 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 fabs(double x);
OVERLOADABLE double floor(double x);
+OVERLOADABLE double fmax(double a, double b);
OVERLOADABLE double fract(double x, global double *p);
OVERLOADABLE double fract(double x, local double *p);
OVERLOADABLE double fract(double x, private double *p);
@@ -248,3 +249,4 @@ OVERLOADABLE int ilogb(double x);
OVERLOADABLE double mad(double a, double b, double c);
+
diff --git a/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl b/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl
index f459619..d1e8305 100644
--- a/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl
@@ -4210,6 +4210,17 @@ OVERLOADABLE double mad(double a, double b, double c)
return __gen_ocl_mad(a, b, c);
}
+OVERLOADABLE double fmax(double a, double b)
+{
+ ulong ua = as_ulong(a);
+ ulong ub =as_ulong(b);
+ if((ua & DF_ABS_MASK) > DF_MAX_NORMAL) return b;
+ if((ub & DF_ABS_MASK) > DF_MAX_NORMAL) return a;
+ if(ua == DF_POSITIVE_INF) return a;
+ if(ub == DF_POSITIVE_INF) return b;
+ double c = a - b;
+ return (c >= 0) ? a:b;
+}
diff --git a/backend/src/libocl/tmpl/ocl_math_20.tmpl.h b/backend/src/libocl/tmpl/ocl_math_20.tmpl.h
index ee313af..10f0bcc 100644
--- a/backend/src/libocl/tmpl/ocl_math_20.tmpl.h
+++ b/backend/src/libocl/tmpl/ocl_math_20.tmpl.h
@@ -212,6 +212,7 @@ OVERLOADABLE float half_tan(float x);
//------- double -----------
OVERLOADABLE double ceil(double x);
OVERLOADABLE double fabs(double x);
+OVERLOADABLE double fmax(double a, double b);
OVERLOADABLE double floor(double x);
OVERLOADABLE double fract(double x, global double *p);
OVERLOADABLE double fract(double x, local double *p);
@@ -224,3 +225,4 @@ OVERLOADABLE double logb(double x);
OVERLOADABLE int ilogb(double x);
OVERLOADABLE double mad(double a, double b, double c);
+
--
2.7.4
More information about the Beignet
mailing list