[Beignet] [PATCH] backend: add doube support to fabs
rander
rander.wang at intel.com
Thu Mar 23 08:37:54 UTC 2017
Signed-off-by: rander <rander.wang at intel.com>
---
backend/src/libocl/tmpl/ocl_math.tmpl.cl | 8 ++++++++
backend/src/libocl/tmpl/ocl_math.tmpl.h | 1 +
backend/src/libocl/tmpl/ocl_math_20.tmpl.cl | 7 +++++++
backend/src/libocl/tmpl/ocl_math_20.tmpl.h | 2 ++
4 files changed, 18 insertions(+)
diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.cl b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
index 9cded64..83af1c6 100644
--- a/backend/src/libocl/tmpl/ocl_math.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
@@ -21,6 +21,7 @@
#include "ocl_common.h"
#include "ocl_integer.h"
#include "ocl_convert.h"
+#include "ocl_printf.h"
extern constant int __ocl_math_fastpath_flag;
@@ -3923,3 +3924,10 @@ OVERLOADABLE double ceil(double x)
return ret;
}
+OVERLOADABLE double fabs(double x)
+{
+ long qw = as_ulong(x);
+ qw &= 0x7FFFFFFFFFFFFFFF;
+ return as_double(qw);
+}
+
diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.h b/backend/src/libocl/tmpl/ocl_math.tmpl.h
index fb126ed..dab45ae 100644
--- a/backend/src/libocl/tmpl/ocl_math.tmpl.h
+++ b/backend/src/libocl/tmpl/ocl_math.tmpl.h
@@ -234,4 +234,5 @@ OVERLOADABLE float half_tan(float x);
//------- double -----------
OVERLOADABLE double ceil(double x);
+OVERLOADABLE double fabs(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 25ef835..83c889a 100644
--- a/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl
@@ -3825,3 +3825,10 @@ OVERLOADABLE double ceil(double x)
return ret;
}
+OVERLOADABLE double fabs(double x)
+{
+ long qw = as_ulong(x);
+ qw &= 0x7FFFFFFFFFFFFFFF;
+ return as_double(qw);
+}
+
diff --git a/backend/src/libocl/tmpl/ocl_math_20.tmpl.h b/backend/src/libocl/tmpl/ocl_math_20.tmpl.h
index 3b10595..76778dd 100644
--- a/backend/src/libocl/tmpl/ocl_math_20.tmpl.h
+++ b/backend/src/libocl/tmpl/ocl_math_20.tmpl.h
@@ -211,4 +211,6 @@ OVERLOADABLE float half_tan(float x);
//------- double -----------
OVERLOADABLE double ceil(double x);
+OVERLOADABLE double fabs(double x);
+
--
2.7.4
More information about the Beignet
mailing list