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

rander rander.wang at intel.com
Thu Mar 23 09:36:48 UTC 2017


	do it by x - floor(x)

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

diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.cl b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
index bb9bc4d..8c5fe8c 100644
--- a/backend/src/libocl/tmpl/ocl_math.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math.tmpl.cl
@@ -3963,4 +3963,24 @@ OVERLOADABLE double floor(double x)
     }
 }
 
+OVERLOADABLE double fract(double x, global double *p)
+{
+    double ret = floor(x);
+    *p =  ret;
+    return x -ret;
+}
+
+OVERLOADABLE double fract(double x, local double *p)
+{
+    double ret = floor(x);
+    *p =  ret;
+    return x -ret;
+}
+
+OVERLOADABLE double fract(double x, private double *p)
+{
+    double ret = floor(x);
+    *p =  ret;
+    return x -ret;
+}
 
diff --git a/backend/src/libocl/tmpl/ocl_math.tmpl.h b/backend/src/libocl/tmpl/ocl_math.tmpl.h
index f699ab2..dc79c08 100644
--- a/backend/src/libocl/tmpl/ocl_math.tmpl.h
+++ b/backend/src/libocl/tmpl/ocl_math.tmpl.h
@@ -236,3 +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 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 a032f59..701d006 100644
--- a/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl
+++ b/backend/src/libocl/tmpl/ocl_math_20.tmpl.cl
@@ -3864,4 +3864,25 @@ OVERLOADABLE double floor(double x)
     }
 }
 
+OVERLOADABLE double fract(double x, global double *p)
+{
+    double ret = floor(x);
+    *p =  ret;
+    return x -ret;
+}
+
+OVERLOADABLE double fract(double x, local double *p)
+{
+    double ret = floor(x);
+    *p =  ret;
+    return x -ret;
+}
+
+OVERLOADABLE double fract(double x, private double *p)
+{
+    double ret = floor(x);
+    *p =  ret;
+    return x -ret;
+}
+
 
diff --git a/backend/src/libocl/tmpl/ocl_math_20.tmpl.h b/backend/src/libocl/tmpl/ocl_math_20.tmpl.h
index bf7ac13..52a6b23 100644
--- a/backend/src/libocl/tmpl/ocl_math_20.tmpl.h
+++ b/backend/src/libocl/tmpl/ocl_math_20.tmpl.h
@@ -213,3 +213,7 @@ OVERLOADABLE float half_tan(float x);
 OVERLOADABLE double ceil(double x);
 OVERLOADABLE double fabs(double x);
 OVERLOADABLE double floor(double x);
+OVERLOADABLE double fract(double x, global double *p);
+OVERLOADABLE double fract(double x, local double *p);
+OVERLOADABLE double fract(double x, private double *p);
+
-- 
2.7.4



More information about the Beignet mailing list