[Beignet] [PATCH v2] fix a powr function issue in cpu compiler math

Yang, Rong R rong.r.yang at intel.com
Sun Aug 9 22:48:35 PDT 2015


Pushed, thanks.

> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> Meng Mengmeng
> Sent: Wednesday, July 29, 2015 03:51
> To: beignet at lists.freedesktop.org
> Cc: Meng, Mengmeng
> Subject: [Beignet] [PATCH v2] fix a powr function issue in cpu compiler math
> 
> In OpenCL spec, gentype powr(gentype x, gentype y). In the meantime,
> added edge tests for powr.
> ---
>  utests/utest_math_gen.py | 24 ++++++++++++++++++++----
>  1 file changed, 20 insertions(+), 4 deletions(-)
> 
> diff --git a/utests/utest_math_gen.py b/utests/utest_math_gen.py index
> 83edcc3..424af41 100755
> --- a/utests/utest_math_gen.py
> +++ b/utests/utest_math_gen.py
> @@ -467,14 +467,30 @@ static float pown(float x, int y){
>    pownUtests =
> func('pown','pown',[pown_input_type1,pown_input_type2],pown_output_
> type,[pown_input_values1,pown_input_values2],'16 * FLT_ULP',
> pown_cpu_func)
> 
>    ##### gentype powr(gentype x, gentype y)
> -  powr_input_values1 = [80, -80, 3.14, -3.14, 0.5, 1, -1, 0.0,6,1500.24,-1500.24]
> -  powr_input_values2 = [5,6,7,8,10,11,12,13,14,0,12]
> +  powr_input_values1 = [80, -80, 3.14, 1, 1.257, +0.0, -0.0, +0.0,
> + -0.0, +0.0, -0.0, +1, +1, -80, +0.0, -0.0, +0.0, -0.0,
> + 'INFINITY','INFINITY', +1, +1, +0.0, 2.5,' NAN', 'NAN', 'NAN']
> +  powr_input_values2 = [5.5, 6,7, +0.0, -0.0, -1, -15.67, '-INFINITY',
> + '-INFINITY', 1,  -2.7, 10.5, 3.1415, 3.5, -0.0, -0.0, +0.0, +0.0,
> + +0.0, -0.0, 'INFINITY', '-INFINITY', 'NAN', 'NAN', -1.5, +0.0, 1.5]
>    powr_input_type1 = ['float','float2','float4','float8','float16']
>    powr_input_type2 = ['float','float2','float4','float8','float16']
>    powr_output_type = ['float','float2','float4','float8','float16']
>    powr_cpu_func='''
> -static float powr(float x, int y){
> -    if (x<0)
> +static float powr(float x, float y){
> +    if (((x > 0) && (x != +INFINITY)) && (y == 0.0f))
> +        return 1;
> +    else if ((x == 0.0f) && ((y < 0 ) || (y == -INFINITY)))
> +        return +INFINITY;
> +    else if ((x == 0.0f) && (y > 0))
> +        return +0;
> +    else if ((x == 0.0f) && (y == 0.0f))
> +        return NAN;
> +    else if ((x == +1) && ((y == +INFINITY) || (y == -INFINITY)))
> +        return NAN;
> +    else if ((x == +1) && ((y != +INFINITY) && (y != -INFINITY)))
> +        return 1;
> +    else if ((x == +INFINITY) && (y == 0.0f))
> +        return NAN;
> +    else if (isnan(x) || (x < 0))
> +        return NAN;
> +    else if ((x >=  0) && (isnan(y)))
>          return NAN;
>      else
>          return powf(x,y);
> --
> 1.9.1
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list