[Beignet] [PATCH 1/2] add builtin function "remquo"

Homer Hsing homer.xing at intel.com
Tue Jul 16 21:48:43 PDT 2013


Signed-off-by: Homer Hsing <homer.xing at intel.com>
---
 backend/src/ocl_stdlib.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/backend/src/ocl_stdlib.h b/backend/src/ocl_stdlib.h
index cfe62d6..893b967 100644
--- a/backend/src/ocl_stdlib.h
+++ b/backend/src/ocl_stdlib.h
@@ -5342,6 +5342,14 @@ INLINE_OVERLOADABLE float16 fract(float16 x, float16 *p) {
                    fract(x.se, 14 + (float *)p),
                    fract(x.sf, 15 + (float *)p));
 }
+INLINE_OVERLOADABLE float remquo(float x, float y, int *quo) {
+  uint hx = as_uint(x), ix = hx & 0x7FFFFFFF, hy = as_uint(y), iy = hy & 0x7FFFFFFF;
+  if (ix > 0x7F800000 || iy > 0x7F800000 || ix == 0x7F800000 || iy == 0)
+    return nan(0u);
+  float k = x / y;
+  *quo = __gen_ocl_rnde(k);
+  return x - (*quo) * y;
+}
 INLINE_OVERLOADABLE float native_divide(float x, float y) { return x/y; }
 INLINE_OVERLOADABLE float ldexp(float x, int n) {
   return __gen_ocl_pow(2, n) * x;
-- 
1.8.1.2



More information about the Beignet mailing list