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

rander rander.wang at intel.com
Mon Mar 27 09:41:49 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     |  1 +
 backend/src/libocl/tmpl/ocl_math_20.tmpl.cl | 14 ++++++++++++++
 backend/src/libocl/tmpl/ocl_math_20.tmpl.h  |  1 +
 4 files changed, 31 insertions(+)

diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.cl b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
index 6978c92..65cd7fc 100644
--- a/backend/src/libocl/tmpl/ocl_math.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
@@ -4347,4 +4347,19 @@ OVERLOADABLE double fmax(double a, double b)
 	return (c >= 0) ? a:b;
 }
 
+OVERLOADABLE double fmin(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_NEGTIVE_INF) return a;
+	if(ub == DF_NEGTIVE_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 1bf9b9a..e4d2e55 100644
--- a/backend/src/libocl/tmpl/ocl_math.tmpl.h
+++ b/backend/src/libocl/tmpl/ocl_math.tmpl.h
@@ -237,6 +237,7 @@ OVERLOADABLE double ceil(double x);
 OVERLOADABLE double fabs(double x);
 OVERLOADABLE double floor(double x);
 OVERLOADABLE double fmax(double a, double b);
+OVERLOADABLE double fmin(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);
diff --git a/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl b/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl
index d1e8305..69716ad 100644
--- a/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl
@@ -4224,3 +4224,17 @@ OVERLOADABLE double fmax(double a, double b)
 	return (c >= 0) ? a:b;
 }
 
+OVERLOADABLE double fmin(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_NEGTIVE_INF) return a;
+	if(ub == DF_NEGTIVE_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 10f0bcc..a3d9578 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 fabs(double x);
 OVERLOADABLE double fmax(double a, double b);
+OVERLOADABLE double fmin(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);
-- 
2.7.4



More information about the Beignet mailing list