[Beignet] [PATCH] fix isnan (builtin function)

Zhigang Gong zhigang.gong at linux.intel.com
Wed Oct 9 22:40:00 PDT 2013


Pushed, thanks.

On Wed, Oct 09, 2013 at 04:14:48PM +0800, Homer Hsing wrote:
> this patch passes following piglit test case
>   piglit/framework/../bin/cl-program-tester generated_tests/cl/builtin/relational/builtin-float-isnan-1.0.generated.cl
> 
> Signed-off-by: Homer Hsing <homer.xing at intel.com>
> ---
>  backend/src/ocl_stdlib.tmpl.h | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/backend/src/ocl_stdlib.tmpl.h b/backend/src/ocl_stdlib.tmpl.h
> index 8dfea09..831a658 100644
> --- a/backend/src/ocl_stdlib.tmpl.h
> +++ b/backend/src/ocl_stdlib.tmpl.h
> @@ -246,7 +246,11 @@ DEF(uint, float);
>  
>  INLINE_OVERLOADABLE int isfinite(float x) { return __builtin_isfinite(x); }
>  INLINE_OVERLOADABLE int isinf(float x) { return __builtin_isinf(x); }
> -INLINE_OVERLOADABLE int isnan(float x) { return __builtin_isnan(x); }
> +INLINE_OVERLOADABLE int isnan(float x) {
> +  union { uint u; float f; } u;
> +  u.f = x;
> +  return (u.u & 0x7FFFFFFF) > 0x7F800000;
> +}
>  INLINE_OVERLOADABLE int isnormal(float x) { return __builtin_isnormal(x); }
>  INLINE_OVERLOADABLE int isordered(float x, float y) { return isequal(x, x) && isequal(y, y); }
>  INLINE_OVERLOADABLE int isunordered(float x, float y) { return isnan(x) || isnan(y); }
> -- 
> 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