[Beignet] [PATCH] keep address space qualifier of pointers
Zhigang Gong
zhigang.gong at gmail.com
Wed Aug 7 00:00:18 PDT 2013
Pushed, thanks.
On Wed, Aug 07, 2013 at 05:41:47AM +0000, Yang, Rong R wrote:
> Test ok, LGTM.
>
> -----Original Message-----
> From: beignet-bounces+rong.r.yang=intel.com at lists.freedesktop.org [mailto:beignet-bounces+rong.r.yang=intel.com at lists.freedesktop.org] On Behalf Of Homer Hsing
> Sent: Wednesday, August 07, 2013 1:19 PM
> To: beignet at lists.freedesktop.org
> Subject: [Beignet] [PATCH] keep address space qualifier of pointers
>
> for built-in function with address-space-qualified pointers, keep address space when accessing the pointers.
>
> Signed-off-by: Homer Hsing <homer.xing at intel.com>
> ---
> backend/src/ocl_stdlib.tmpl.h | 121 ++++++++++++++++++++----------------------
> 1 file changed, 58 insertions(+), 63 deletions(-)
>
> diff --git a/backend/src/ocl_stdlib.tmpl.h b/backend/src/ocl_stdlib.tmpl.h index c9e54e2..972655c 100644
> --- a/backend/src/ocl_stdlib.tmpl.h
> +++ b/backend/src/ocl_stdlib.tmpl.h
> @@ -543,13 +543,13 @@ INLINE_OVERLOADABLE float __gen_ocl_internal_expm1(float x) { return __gen_ocl_p INLINE_OVERLOADABLE float __gen_ocl_internal_cbrt(float x) {
> return __gen_ocl_pow(x, 0.3333333333f); } -INLINE_OVERLOADABLE float __gen_ocl_internal_sincos(float x, float *cosval) {
> - *cosval = native_cos(x);
> +#define BODY \
> + *cosval = native_cos(x); \
> return native_sin(x);
> -}
> -INLINE_OVERLOADABLE float sincos(float x, global float *cosval) { return __gen_ocl_internal_sincos(x, (float*)cosval); } -INLINE_OVERLOADABLE float sincos(float x, local float *cosval) { return __gen_ocl_internal_sincos(x, (float*)cosval); } -INLINE_OVERLOADABLE float sincos(float x, private float *cosval) { return __gen_ocl_internal_sincos(x, (float*)cosval); }
> +INLINE_OVERLOADABLE float sincos(float x, global float *cosval) { BODY;
> +} INLINE_OVERLOADABLE float sincos(float x, local float *cosval) {
> +BODY; } INLINE_OVERLOADABLE float sincos(float x, private float
> +*cosval) { BODY; } #undef BODY
>
> INLINE_OVERLOADABLE float __gen_ocl_internal_sinh(float x) {
> return (1 - native_exp(-2 * x)) / (2 * native_exp(-x)); @@ -726,23 +726,22 @@ DECL_MIN_MAX_CLAMP(unsigned short) DECL_MIN_MAX_CLAMP(unsigned char) #undef DECL_MIN_MAX_CLAMP
>
> -INLINE_OVERLOADABLE float __gen_ocl_frexp(float x, int *exp) {
> - uint u = as_uint(x);
> - if ((u & 0x7FFFFFFFu) == 0) {
> - *exp = 0;
> - return x;
> - }
> - int e = (u >> 23) & 255;
> - if (e == 255)
> - return x;
> - *exp = e - 126;
> - u = (u & (0x807FFFFFu)) | 0x3F000000;
> +#define BODY \
> + uint u = as_uint(x); \
> + if ((u & 0x7FFFFFFFu) == 0) { \
> + *exp = 0; \
> + return x; \
> + } \
> + int e = (u >> 23) & 255; \
> + if (e == 255) \
> + return x; \
> + *exp = e - 126; \
> + u = (u & (0x807FFFFFu)) | 0x3F000000; \
> return as_float(u);
> -}
> -
> -INLINE_OVERLOADABLE float frexp(float x, global int *exp) { return __gen_ocl_frexp(x, (int *)exp); } -INLINE_OVERLOADABLE float frexp(float x, local int *exp) { return __gen_ocl_frexp(x, (int *)exp); } -INLINE_OVERLOADABLE float frexp(float x, private int *exp) { return __gen_ocl_frexp(x, (int *)exp); }
> +INLINE_OVERLOADABLE float frexp(float x, global int *exp) { BODY; }
> +INLINE_OVERLOADABLE float frexp(float x, local int *exp) { BODY; }
> +INLINE_OVERLOADABLE float frexp(float x, private int *exp) { BODY; }
> +#undef BODY
>
> INLINE_OVERLOADABLE float nextafter(float x, float y) {
> uint hx = as_uint(x), ix = hx & 0x7FFFFFFF; @@ -760,24 +759,22 @@ INLINE_OVERLOADABLE float nextafter(float x, float y) {
> return as_float(hx);
> }
>
> -INLINE_OVERLOADABLE float __gen_ocl_modf(float x, float *i) {
> - uint hx = as_uint(x), ix = hx & 0x7FFFFFFF;
> - if (ix > 0x7F800000) {
> - *i = nan(0u);
> - return nan(0u);
> - }
> - if (ix == 0x7F800000) {
> - *i = x;
> - return as_float(hx & 0x80000000u);
> - }
> - *i = __gen_ocl_rndz(x);
> +#define BODY \
> + uint hx = as_uint(x), ix = hx & 0x7FFFFFFF; \
> + if (ix > 0x7F800000) { \
> + *i = nan(0u); \
> + return nan(0u); \
> + } \
> + if (ix == 0x7F800000) { \
> + *i = x; \
> + return as_float(hx & 0x80000000u); \
> + } \
> + *i = __gen_ocl_rndz(x); \
> return x - *i;
> -}
> -
> -INLINE_OVERLOADABLE float modf(float x, global float *i) { return __gen_ocl_modf(x, (float *)i); } -INLINE_OVERLOADABLE float modf(float x, local float *i) { return __gen_ocl_modf(x, (float *)i); } -INLINE_OVERLOADABLE float modf(float x, private float *i) { return __gen_ocl_modf(x, (float *)i); }
> -
> +INLINE_OVERLOADABLE float modf(float x, global float *i) { BODY; }
> +INLINE_OVERLOADABLE float modf(float x, local float *i) { BODY; }
> +INLINE_OVERLOADABLE float modf(float x, private float *i) { BODY; }
> +#undef BODY
> INLINE_OVERLOADABLE float degrees(float radians) { return (180 / M_PI_F) * radians; } INLINE_OVERLOADABLE float radians(float degrees) { return (M_PI_F / 180) * degrees; }
>
> @@ -810,32 +807,30 @@ INLINE_OVERLOADABLE float mix(float x, float y, float a) { return x + (y-x)*a;} INLINE_OVERLOADABLE float __gen_ocl_internal_fdim(float x, float y) {
> return __gen_ocl_internal_fmax(x, y) - y; } -INLINE_OVERLOADABLE float __gen_ocl_fract(float x, float *p) {
> - *p = __gen_ocl_internal_floor(x);
> +#define BODY \
> + *p = __gen_ocl_internal_floor(x); \
> return __gen_ocl_internal_fmin(x - *p, 0x1.FFFFFep-1F); -} -INLINE_OVERLOADABLE float fract(float x, global float *p) { return __gen_ocl_fract(x, (float *)p); } -INLINE_OVERLOADABLE float fract(float x, local float *p) { return __gen_ocl_fract(x, (float *)p); } -INLINE_OVERLOADABLE float fract(float x, private float *p) { return __gen_ocl_fract(x, (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);
> +INLINE_OVERLOADABLE float fract(float x, global float *p) { BODY; }
> +INLINE_OVERLOADABLE float fract(float x, local float *p) { BODY; }
> +INLINE_OVERLOADABLE float fract(float x, private float *p) { BODY; }
> +#undef BODY
> +
> +#define BODY \
> + 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 float remquo(float x, float y, global int *quo) {
> +BODY; } INLINE_OVERLOADABLE float remquo(float x, float y, local int
> +*quo) { BODY; } INLINE_OVERLOADABLE float remquo(float x, float y,
> +private int *quo) { BODY; } #undef BODY
> 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
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list