Good. Thanks for the comments.

-----Original Message-----
From: Zhigang Gong [mailto:[email protected]] 
Sent: Friday, November 8, 2013 2:23 PM
To: Xing, Homer
Cc: [email protected]
Subject: Re: [Beignet] [PATCH] fix builtin function "fmax"

Two additional comments:

1. This patch should only for the float data type. 

2. For the float data type, according to IVB spec.
Nan compare with any other data will get a false, so we can reduce one nan 
checking, and the following should be good enough.

{
if (inan(b))
  return a;
return a > b ? a : b
}

On Fri, Nov 08, 2013 at 10:51:34AM +0800, Homer Hsing wrote:
> if an parameter is nan, then returns another parameter.
> 
> Signed-off-by: Homer Hsing <[email protected]>
> ---
>  backend/src/ocl_stdlib.tmpl.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/backend/src/ocl_stdlib.tmpl.h 
> b/backend/src/ocl_stdlib.tmpl.h index bff2b1c..ec9ed60 100644
> --- a/backend/src/ocl_stdlib.tmpl.h
> +++ b/backend/src/ocl_stdlib.tmpl.h
> @@ -1621,6 +1621,10 @@ INLINE_OVERLOADABLE float step(float edge, 
> float x) {
>  
>  #define DECL_MIN_MAX_CLAMP(TYPE) \
>  INLINE_OVERLOADABLE TYPE max(TYPE a, TYPE b) { \
> +  if (isnan(a)) \
> +    return b; \
> +  if (isnan(b)) \
> +    return a; \
>    return a > b ? a : b; \
>  } \
>  INLINE_OVERLOADABLE TYPE min(TYPE a, TYPE b) { \
> --
> 1.8.3.2
> 
> _______________________________________________
> Beignet mailing list
> [email protected]
> http://lists.freedesktop.org/mailman/listinfo/beignet
_______________________________________________
Beignet mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/beignet

Reply via email to