[Beignet] [PATCH version3 1/2] add built-in function "remquo"
Zhigang Gong
zhigang.gong at linux.intel.com
Tue Jul 23 23:41:22 PDT 2013
Tested ok, pushed, thanks.
On Thu, Jul 18, 2013 at 02:46:32PM +0800, Homer Hsing wrote:
>
> Signed-off-by: Homer Hsing <homer.xing at intel.com>
> ---
> backend/src/ocl_stdlib.h | 35 +++++++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/backend/src/ocl_stdlib.h b/backend/src/ocl_stdlib.h
> index cfe62d6..b7da9b2 100644
> --- a/backend/src/ocl_stdlib.h
> +++ b/backend/src/ocl_stdlib.h
> @@ -5342,6 +5342,41 @@ 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;
> + 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 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
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list