Utest: test pow, not powr, on negative x

Submitted by Rebecca N. Palmer on Sept. 25, 2016, 11:20 p.m.

Details

Message ID eb6bf7a9-98f8-cde3-e86f-7edaa90461c2@zoho.com
State New
Headers show
Series "Utest: test pow, not powr, on negative x" ( rev: 1 ) in Beignet

Not browsing as part of any series.

Commit Message

Rebecca N. Palmer Sept. 25, 2016, 11:20 p.m.
powr(x,y) is explicitly undefined for negative x; on my hardware,
it happens to be correct in default mode, but acts like pow(abs(x),y)
in fast (OCL_STRICT_CONFORMANCE=0) mode, failing the test.

Signed-off-by: Rebecca Palmer <rebecca_palmer@zoho.com>

Patch hide | download patch | download mbox

diff --git a/utests/utest_math_gen.py b/utests/utest_math_gen.py
index a4bfd51..9ef75d5 100755
--- a/utests/utest_math_gen.py
+++ b/utests/utest_math_gen.py
@@ -447,14 +447,20 @@  static float minmag(float x, float y){
   nextafterUtests = func('nextafter','nextafterf',[nextafter_input_type1,nextafter_input_type2],nextafter_output_type,[nextafter_input_values1,nextafter_input_values2],'0 * FLT_ULP')
   
   ##### gentype pow(gentype x, gentype y)
-  pow_base_values = base_input_values1
+  pow_base_values = [80, -80, 3.14, -3.14, 0.5, 1, -3,-4,2,0.0,-0.0,1500.24,-1500.24]
   pow_input_values1 = []
   pow_input_values2 = []
   pow_input_values1,pow_input_values2=gene2ValuesLoop(pow_input_values1,pow_input_values2,pow_base_values)
   pow_input_type1 = ['float','float2','float4','float8','float16']
   pow_input_type2 = ['float','float2','float4','float8','float16']
   pow_output_type = ['float','float2','float4','float8','float16']
-  powUtests = func('pow','powf',[pow_input_type1,pow_input_type2],pow_output_type,[pow_input_values1,pow_input_values2],'16 * FLT_ULP')
+  pow_cpu_func='''
+static float pow_utest(float x, float y){
+    if ((x == 0.0f) && (y == -INFINITY))
+        return INFINITY;
+    return pow(x,y);
+} '''
+  powUtests = func('pow','pow_utest',[pow_input_type1,pow_input_type2],pow_output_type,[pow_input_values1,pow_input_values2],'16 * FLT_ULP',pow_cpu_func)
   
   ##### floatn pown(floatn x, intn y)
   pown_input_values1 = [FLT_MAX_POSI,FLT_MIN_NEGA,FLT_MIN_POSI,FLT_MAX_NEGA,80, -80, 3.14, -3.14, 0.5, 1, 0.0,1500.24,-1500.24]
@@ -469,7 +475,7 @@  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, 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_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']

Comments

LGTM, pushed, thanks.

> -----Original Message-----

> From: Beignet [mailto:beignet-bounces@lists.freedesktop.org] On Behalf Of

> Rebecca N. Palmer

> Sent: Monday, September 26, 2016 7:21

> To: beignet@lists.freedesktop.org

> Subject: [Beignet] [PATCH] Utest: test pow, not powr, on negative x

> 

> powr(x,y) is explicitly undefined for negative x; on my hardware, it happens

> to be correct in default mode, but acts like pow(abs(x),y) in fast

> (OCL_STRICT_CONFORMANCE=0) mode, failing the test.

> 

> Signed-off-by: Rebecca Palmer <rebecca_palmer@zoho.com>

> 

> diff --git a/utests/utest_math_gen.py b/utests/utest_math_gen.py index

> a4bfd51..9ef75d5 100755

> --- a/utests/utest_math_gen.py

> +++ b/utests/utest_math_gen.py

> @@ -447,14 +447,20 @@ static float minmag(float x, float y){

>    nextafterUtests =

> func('nextafter','nextafterf',[nextafter_input_type1,nextafter_input_type2]

> ,nextafter_output_type,[nextafter_input_values1,nextafter_input_values2]

> ,'0 * FLT_ULP')

> 

>    ##### gentype pow(gentype x, gentype y)

> -  pow_base_values = base_input_values1

> +  pow_base_values = [80, -80, 3.14, -3.14, 0.5, 1,

> + -3,-4,2,0.0,-0.0,1500.24,-1500.24]

>    pow_input_values1 = []

>    pow_input_values2 = []

> 

> pow_input_values1,pow_input_values2=gene2ValuesLoop(pow_input_valu

> es1,pow_input_values2,pow_base_values)

>    pow_input_type1 = ['float','float2','float4','float8','float16']

>    pow_input_type2 = ['float','float2','float4','float8','float16']

>    pow_output_type = ['float','float2','float4','float8','float16']

> -  powUtests =

> func('pow','powf',[pow_input_type1,pow_input_type2],pow_output_type,

> [pow_input_values1,pow_input_values2],'16 * FLT_ULP')

> +  pow_cpu_func='''

> +static float pow_utest(float x, float y){

> +    if ((x == 0.0f) && (y == -INFINITY))

> +        return INFINITY;

> +    return pow(x,y);

> +} '''

> +  powUtests =

> +func('pow','pow_utest',[pow_input_type1,pow_input_type2],pow_output

> _typ

> +e,[pow_input_values1,pow_input_values2],'16 * FLT_ULP',pow_cpu_func)

> 

>    ##### floatn pown(floatn x, intn y)

>    pown_input_values1 =

> [FLT_MAX_POSI,FLT_MIN_NEGA,FLT_MIN_POSI,FLT_MAX_NEGA,80, -80,

> 3.14, -3.14, 0.5, 1, 0.0,1500.24,-1500.24] @@ -469,7 +475,7 @@ 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, 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_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']

> 

> _______________________________________________

> Beignet mailing list

> Beignet@lists.freedesktop.org

> https://lists.freedesktop.org/mailman/listinfo/beignet