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

rander rander.wang at intel.com
Tue Mar 28 02:06:16 UTC 2017


	spec:Returns a quiet NaN. The nancode may be placed
	     in the significand of the resulting NaN. accoding
	     to IEEE754, as_long(nan) > 7FF0000000000000

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

diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.cl b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
index c9e5219..ff75b1a 100644
--- a/backend/src/libocl/tmpl/ocl_math.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
@@ -4375,6 +4375,11 @@ OVERLOADABLE double mad(double a, double b, double c)
 	return __gen_ocl_mad(a, b, c);
 }
 
+OVERLOADABLE double nan(ulong code)
+{
+	return as_double(DF_POSITIVE_INF + (code&DF_MAN_MASK));
+}
+
 OVERLOADABLE double fmax(double a, double b)
 {
 	ulong ua = as_ulong(a);
diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.h b/backend/src/libocl/tmpl/ocl_math.tmpl.h
index de40d5d..6dca21f 100644
--- a/backend/src/libocl/tmpl/ocl_math.tmpl.h
+++ b/backend/src/libocl/tmpl/ocl_math.tmpl.h
@@ -253,6 +253,7 @@ OVERLOADABLE double log1p(double x);
 OVERLOADABLE double logb(double x);
 OVERLOADABLE int ilogb(double x);
 OVERLOADABLE double mad(double a, double b, double c);
+OVERLOADABLE double nan(ulong code);
 OVERLOADABLE double rint(double x);
 OVERLOADABLE double round(double x);
 OVERLOADABLE double trunc(double x);
diff --git a/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl b/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl
index 0861f5a..755bb9d 100644
--- a/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl
@@ -4251,6 +4251,11 @@ OVERLOADABLE double mad(double a, double b, double c)
 	return __gen_ocl_mad(a, b, c);
 }
 
+OVERLOADABLE double nan(ulong code)
+{
+	return as_double(DF_POSITIVE_INF + (code&DF_MAN_MASK));
+}
+
 OVERLOADABLE double fmax(double a, double b)
 {
 	ulong ua = as_ulong(a);
diff --git a/backend/src/libocl/tmpl/ocl_math_20.tmpl.h b/backend/src/libocl/tmpl/ocl_math_20.tmpl.h
index 597f491..a753d52 100644
--- a/backend/src/libocl/tmpl/ocl_math_20.tmpl.h
+++ b/backend/src/libocl/tmpl/ocl_math_20.tmpl.h
@@ -230,6 +230,7 @@ OVERLOADABLE double log1p(double x);
 OVERLOADABLE double logb(double x);
 OVERLOADABLE int ilogb(double x);
 OVERLOADABLE double mad(double a, double b, double c);
+OVERLOADABLE double nan(ulong code);
 OVERLOADABLE double rint(double x);
 OVERLOADABLE double round(double x);
 OVERLOADABLE double trunc(double x);
-- 
2.7.4



More information about the Beignet mailing list