[Beignet] [PATCH] Utests: Fix the failure for half math tests.

Yang, Rong R rong.r.yang at intel.com
Mon Nov 23 23:23:32 PST 2015



> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> junyan.he at inbox.com
> Sent: Wednesday, November 11, 2015 17:59
> To: beignet at lists.freedesktop.org
> Subject: [Beignet] [PATCH] Utests: Fix the failure for half math tests.
> 
> From: Junyan He <junyan.he at linux.intel.com>
> 
> We do not have native half type support on X86 platforms.
> The half math functions on CPU side are just used in utests, so we do not
> want to import the soft imitation code or add dependency on some math libs
> for half. We just use float to to calculate the reference value. This causes the
> diff between CPU results and GPU results. We use random func to generate
> src value but when this src value is very close to pi or pi/2, the truncation diff
> imported by float -> half will be magnified a lot in the result of some math
> functions, e.g. sin, cos and tan.
> We now just use a float table as src to fix this.
> 
> Signed-off-by: Junyan He <junyan.he at linux.intel.com>
> ---
>  utests/compiler_half.cpp | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/utests/compiler_half.cpp b/utests/compiler_half.cpp index
> 163573f..b5480a0 100644
> --- a/utests/compiler_half.cpp
> +++ b/utests/compiler_half.cpp
> @@ -172,7 +172,7 @@ void compiler_half_basic(void)
>    for (int32_t i = 0; i < (int32_t) n; ++i) {
>      tmp_f = __half_to_float(((uint16_t *)buf_data[1])[i]);
>      memcpy(&f, &tmp_f, sizeof(float));
> -    printf("%f %f\n", f, fdst[i]);
> +    //printf("%f %f\n", f, fdst[i]);
>      OCL_ASSERT(fabs(f - fdst[i]) <= 0.01 * fabs(fdst[i]) || (fdst[i] == 0.0 && f
> == 0.0));
>    }
>    OCL_UNMAP_BUFFER(1);
> @@ -180,11 +180,18 @@ void compiler_half_basic(void)
> 
>  MAKE_UTEST_FROM_FUNCTION(compiler_half_basic);
> 
> +static const int half_n = 16;
> +static float half_test_src[half_n] = {
> +  -0.23455f, 1.23413f, 2.3412, 8.234f,
> +  -122.31f, -14.233f, 0.0023f, 99.322f,
> +  0.0f, 0.332f, 123.12f, -0.003f,
> +  16.0f, 19.22f, 128.006f, 25.032f
> +};
> 
>  #define HALF_MATH_TEST_1ARG(NAME, CPPNAME, RANGE_L, RANGE_H)
Are RANGE_L and RANGE_H no longer use in this Marco? 




More information about the Beignet mailing list