[Beignet] [PATCH v10 1/2] add builtin function "remquo"
Homer Hsing
homer.xing at intel.com
Tue Jul 23 23:04:20 PDT 2013
The pointer is with address space modifier.
The function body has been revised.
Signed-off-by: Homer Hsing <homer.xing at intel.com>
---
backend/src/ocl_stdlib.h | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/backend/src/ocl_stdlib.h b/backend/src/ocl_stdlib.h
index 16856fb..56ac021 100644
--- a/backend/src/ocl_stdlib.h
+++ b/backend/src/ocl_stdlib.h
@@ -5353,6 +5353,45 @@ INLINE_OVERLOADABLE float16 fract(float16 x, float16 *p) {
fract(x.se, 14 + (float *)p),
fract(x.sf, 15 + (float *)p));
}
+
+INLINE_OVERLOADABLE float __gen_ocl_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;
+ int q = __gen_ocl_rnde(k);
+ *quo = q >= 0 ? (q & 127) : (q | 0xFFFFFF80u);
+ float r = x - q * y;
+ uint hr = as_uint(r), ir = hr & 0x7FFFFFFF;
+ if (ir == 0)
+ hr = ir | (hx & 0x80000000u);
+ return as_float(hr);
+}
+
+INLINE_OVERLOADABLE float remquo(float x, float y, global int *quo) { return __gen_ocl_remquo(x, y, (int *)quo); }
+INLINE_OVERLOADABLE float remquo(float x, float y, local int *quo) { return __gen_ocl_remquo(x, y, (int *)quo); }
+INLINE_OVERLOADABLE float remquo(float x, float y, private int *quo) { return __gen_ocl_remquo(x, y, (int *)quo); }
+
+INLINE_OVERLOADABLE float2 remquo(float2 x, float2 y, int2 *i) {
+ return (float2)(remquo(x.s0, y.s0, (int *)i), remquo(x.s1, y.s1, 1 + (int *)i));
+}
+
+INLINE_OVERLOADABLE float3 remquo(float3 x, float3 y, int3 *i) {
+ return (float3)(remquo(x.s0, y.s0, (int *)i), remquo(x.s1, y.s1, 1 + (int *)i), remquo(x.s2, y.s2, 2 + (int *)i));
+}
+
+INLINE_OVERLOADABLE float4 remquo(float4 x, float4 y, int4 *i) {
+ return (float4)(remquo(x.s0, y.s0, (int *)i), remquo(x.s1, y.s1, 1 + (int *)i), remquo(x.s2, y.s2, 2 + (int *)i), remquo(x.s3, y.s3, 3 + (int *)i));
+}
+
+INLINE_OVERLOADABLE float8 remquo(float8 x, float8 y, int8 *i) {
+ return (float8)(remquo(x.s0, y.s0, (int *)i), remquo(x.s1, y.s1, 1 + (int *)i), remquo(x.s2, y.s2, 2 + (int *)i), remquo(x.s3, y.s3, 3 + (int *)i), remquo(x.s4, y.s4, 4 + (int *)i), remquo(x.s5, y.s5, 5 + (int *)i), remquo(x.s6, y.s6, 6 + (int *)i), remquo(x.s7, y.s7, 7 + (int *)i));
+}
+
+INLINE_OVERLOADABLE float16 remquo(float16 x, float16 y, int16 *i) {
+ return (float16)(remquo(x.s0, y.s0, (int *)i), remquo(x.s1, y.s1, 1 + (int *)i), remquo(x.s2, y.s2, 2 + (int *)i), remquo(x.s3, y.s3, 3 + (int *)i), remquo(x.s4, y.s4, 4 + (int *)i), remquo(x.s5, y.s5, 5 + (int *)i), remquo(x.s6, y.s6, 6 + (int *)i), remquo(x.s7, y.s7, 7 + (int *)i), remquo(x.s8, y.s8, 8 + (int *)i), remquo(x.s9, y.s9, 9 + (int *)i), remquo(x.sa, y.sa, 10 + (int *)i), remquo(x.sb, y.sb, 11 + (int *)i), remquo(x.sc, y.sc, 12 + (int *)i), remquo(x.sd, y.sd, 13 + (int *)i), remquo(x.se, y.se, 14 + (int *)i), remquo(x.sf, y.sf, 15 + (int *)i));
+}
+
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