[Beignet] [PATCH] fix built-in function "fast_normalize"

Zhigang Gong zhigang.gong at linux.intel.com
Tue Oct 29 03:25:54 CET 2013


Homer,

Do you want to submit a new version of patch to fix this issue? Thanks.

On Mon, Oct 28, 2013 at 02:49:30AM +0000, Xing, Homer wrote:
> I think the same as you. You should assume that if x is NaN, then the result should be a vector full of NaNs.
> 
> Homer Hsing
> 
> -----Original Message-----
> From: Lu, Guanqun 
> Sent: Monday, October 28, 2013 10:41 AM
> To: Xing, Homer; beignet at lists.freedesktop.org
> Subject: RE: [Beignet] [PATCH] fix built-in function "fast_normalize"
> 
> hi homer,
> 
> how about if x is NaN, according to the opencl-1.2 spec.
> 
>   "normalize ( v ) returns a vector full of NaNs if any element is a NaN."
> 
> so i would assume that if x is NaN, the result should be NaN. HOw do you think?
> 
> 
> --guanqun
> 
> 
> 
> > -----Original Message-----
> > From: beignet-bounces+guanqun.lu=intel.com at lists.freedesktop.org
> > [mailto:beignet-bounces+guanqun.lu=intel.com at lists.freedesktop.org] On 
> > Behalf Of Homer Hsing
> > Sent: Monday, October 28, 2013 9:03 AM
> > To: beignet at lists.freedesktop.org
> > Subject: [Beignet] [PATCH] fix built-in function "fast_normalize"
> > 
> > if the parameter is zero, then return zero if the parameter is 
> > positive, then return 1.
> > for other cases, return -1.
> > 
> > Signed-off-by: Homer Hsing <homer.xing at intel.com>
> > ---
> >  backend/src/ocl_stdlib.tmpl.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/backend/src/ocl_stdlib.tmpl.h 
> > b/backend/src/ocl_stdlib.tmpl.h index a3bf0a0..38d1ab0 100644
> > --- a/backend/src/ocl_stdlib.tmpl.h
> > +++ b/backend/src/ocl_stdlib.tmpl.h
> > @@ -1779,7 +1779,7 @@ INLINE_OVERLOADABLE float fast_distance(float x, 
> > float y) { return length(x-y);  INLINE_OVERLOADABLE float 
> > fast_distance(float2 x, float2 y) { return length(x-y); }  
> > INLINE_OVERLOADABLE float fast_distance(float3 x, float3 y) { return 
> > length(x-y); }  INLINE_OVERLOADABLE float fast_distance(float4 x, 
> > float4 y) { return length(x-y); } -INLINE_OVERLOADABLE float 
> > fast_normalize(float x) { return 1.f; }
> > +INLINE_OVERLOADABLE float fast_normalize(float x) { return x > 0 ? 
> > +1.f : (x <
> > 0 ? -1.f : 0.f); }
> >  INLINE_OVERLOADABLE float2 fast_normalize(float2 x) { return x * 
> > rsqrt(dot(x, x)); }  INLINE_OVERLOADABLE float3 fast_normalize(float3 
> > x) { return x * rsqrt(dot(x, x)); }  INLINE_OVERLOADABLE float4 
> > fast_normalize(float4 x) { return x * rsqrt(dot(x, x)); }
> > --
> > 1.8.3.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