[Beignet] [PATCH] fix 64-bit "clz" if parameter is "long4" or "ulong4"

Xing, Homer homer.xing at intel.com
Tue Sep 3 19:52:29 PDT 2013


I don't know the exact reason ... I hope someone can dig the reason in the future ...

-----Original Message-----
From: Zhigang Gong [mailto:zhigang.gong at linux.intel.com] 
Sent: Wednesday, September 4, 2013 10:51 AM
To: Xing, Homer
Cc: beignet at lists.freedesktop.org
Subject: Re: [Beignet] [PATCH] fix 64-bit "clz" if parameter is "long4" or "ulong4"

Homer,

Could you tell a little bit more about why the previous version couldn't work?
Thanks.

On Wed, Sep 04, 2013 at 10:33:39AM +0800, Homer Hsing wrote:
> 
> Signed-off-by: Homer Hsing <homer.xing at intel.com>
> ---
>  backend/src/ocl_stdlib.tmpl.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/backend/src/ocl_stdlib.tmpl.h 
> b/backend/src/ocl_stdlib.tmpl.h index 2b470e5..72f7d76 100644
> --- a/backend/src/ocl_stdlib.tmpl.h
> +++ b/backend/src/ocl_stdlib.tmpl.h
> @@ -318,12 +318,12 @@ INLINE_OVERLOADABLE uint clz(uint x) {  }
>  
>  INLINE_OVERLOADABLE long clz(long x) {
> -  if (x < 0)
> -    return 0;
> -  if (x == 0)
> -    return 64;
>    union { int i[2]; long x; } u;
>    u.x = x;
> +  if (u.i[1] & 0x80000000u)
> +    return 0;
> +  if (u.i[1] == 0 && u.i[0] == 0)
> +    return 64;
>    uint v = clz(u.i[1]);
>    if(v == 32)
>      v += clz(u.i[0]);
> --
> 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