[PATCH i-g-t] lib/intel_compute: Compare floats with igt_assert_eq_double()

Kamil Konieczny kamil.konieczny at linux.intel.com
Tue Mar 4 16:20:40 UTC 2025


Hi Francois,
On 2025-03-04 at 12:39:09 +0100, Francois Dugast wrote:
> Using igt_assert_eq() to compare floats was incorrect and led to
> false positives, replace it with the appropriate assert.
> 
> Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> Signed-off-by: Francois Dugast <francois.dugast at intel.com>
> ---
>  lib/intel_compute.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/lib/intel_compute.c b/lib/intel_compute.c
> index 4818c0ff7..dd9c83c9c 100644
> --- a/lib/intel_compute.c
> +++ b/lib/intel_compute.c
> @@ -754,7 +754,7 @@ static void compute_exec(int fd, const unsigned char *kernel,
>  			igt_debug("[%4d] input:%f output:%f expected_output:%f\n",
>  				  i, input, output, expected_output);
>  		if (!user || (user && !user->skip_results_check))
> -			igt_assert_eq(output, expected_output);
> +			igt_assert_eq_double(output, expected_output);

Technically they are floats but this should be ok, so

Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>

>  	}
>  
>  	bo_execenv_unbind(&execenv, bo_dict, BO_DICT_ENTRIES);
> @@ -1035,7 +1035,7 @@ static void xehp_compute_exec(int fd, const unsigned char *kernel,
>  			igt_debug("[%4d] input:%f output:%f expected_output:%f\n",
>  				  i, input, output, expected_output);
>  		if (!user || (user && !user->skip_results_check))
> -			igt_assert_eq(output, expected_output);
> +			igt_assert_eq_double(output, expected_output);
>  	}
>  
>  	bo_execenv_unbind(&execenv, bo_dict, XEHP_BO_DICT_ENTRIES);
> @@ -1246,7 +1246,7 @@ static void xehpc_compute_exec(int fd, const unsigned char *kernel,
>  			igt_debug("[%4d] input:%f output:%f expected_output:%f\n",
>  				  i, input, output, expected_output);
>  		if (!user || (user && !user->skip_results_check))
> -			igt_assert_eq(output, expected_output);
> +			igt_assert_eq_double(output, expected_output);
>  	}
>  
>  	bo_execenv_unbind(&execenv, bo_dict, XEHPC_BO_DICT_ENTRIES);
> @@ -1613,7 +1613,7 @@ static void xelpg_compute_exec(int fd, const unsigned char *kernel,
>  			igt_debug("[%4d] input:%f output:%f expected_output:%f\n",
>  				  i, input, output, expected_output);
>  		if (!user || (user && !user->skip_results_check))
> -			igt_assert_eq(output, expected_output);
> +			igt_assert_eq_double(output, expected_output);
>  	}
>  
>  	bo_execenv_unbind(&execenv, bo_dict, XELPG_BO_DICT_ENTRIES);
> @@ -1706,7 +1706,7 @@ static void xe2lpg_compute_exec(int fd, const unsigned char *kernel,
>  			igt_debug("[%4d] input:%f output:%f expected_output:%f\n",
>  				  i, input, output, expected_output);
>  		if (!user || (user && !user->skip_results_check))
> -			igt_assert_eq(output, expected_output);
> +			igt_assert_eq_double(output, expected_output);
>  	}
>  
>  	bo_execenv_unbind(&execenv, bo_dict, XE2_BO_DICT_ENTRIES);
> @@ -2048,7 +2048,7 @@ static void xe2lpg_compute_preempt_exec(int fd, const unsigned char *long_kernel
>  		if (output != expected_output)
>  			igt_debug("[%4d] input:%f output:%f expected_output:%f\n",
>  				  i, input, output, expected_output);
> -		igt_assert_eq(output, expected_output);
> +		igt_assert_eq_double(output, expected_output);
>  	}
>  
>  	for (int i = 0; i < SIZE_DATA; i++) {
> -- 
> 2.43.0
> 


More information about the igt-dev mailing list