[Beignet] [PATCH] utest_pow: don't fail on declared lack of denormals
Song, Ruiling
ruiling.song at intel.com
Wed Apr 22 21:26:30 PDT 2015
LGTM
> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> Rebecca N. Palmer
> Sent: Saturday, April 18, 2015 5:19 AM
> To: beignet at lists.freedesktop.org
> Subject: [Beignet] [PATCH] utest_pow: don't fail on declared lack of
> denormals
>
> (Resend: the first copy appears to have gone missing)
>
> 0.01**20.5 is denormal; at least Ivy Bridge does not support denormals and
> hence returns 0. As this is allowed by the OpenCL standard, it shouldn't fail
> the test.
>
> Signed-off-by: Rebecca Palmer <rebecca_palmer at zoho.com>
>
> diff --git a/utests/builtin_pow.cpp b/utests/builtin_pow.cpp index
> a18f31e..6e0f8dd 100644
> --- a/utests/builtin_pow.cpp
> +++ b/utests/builtin_pow.cpp
> @@ -37,6 +37,9 @@ static void builtin_pow(void)
> input_data2[i*count_input_ori+k] = ori_data[k];
> }
>
> + cl_device_fp_config fp_config;
> + clGetDeviceInfo(device, CL_DEVICE_SINGLE_FP_CONFIG,
> + sizeof(cl_device_fp_config), &fp_config, 0); bool denormals_supported
> + = fp_config & CL_FP_DENORM;
> const char* env_strict = getenv("OCL_STRICT_CONFORMANCE");
> float ULPSIZE_FACTOR = 16.0;
> if (env_strict == NULL || strcmp(env_strict, "0") == 0) @@ -75,7 +78,8
> @@ static void builtin_pow(void)
> #if udebug
> if ( (isinf(cpu_data[index_cur]) && !isinf(gpu_data[index_cur])) ||
> (isnan(cpu_data[index_cur]) && !isnan(gpu_data[index_cur]))
> ||
> - (fabs(gpu_data[index_cur] - cpu_data[index_cur]) >
> cl_FLT_ULP(cpu_data[index_cur]) * ULPSIZE_FACTOR) )
> + (fabs(gpu_data[index_cur] - cpu_data[index_cur]) >
> cl_FLT_ULP(cpu_data[index_cur]) * ULPSIZE_FACTOR
> + && (denormals_supported || gpu_data[index_cur]!=0 ||
> + std::fpclassify(cpu_data[index_cur])!=FP_SUBNORMAL) ) )
> {
> printf_c("%d/%d: x:%f, y:%f -> gpu:%f cpu:%f\n", k, i,
> input_data1[k], input_data2[k], gpu_data[index_cur], cpu_data[index_cur]);
> }
> @@ -88,7 +92,8 @@ static void builtin_pow(void)
> OCL_ASSERT(isnan(gpu_data[index_cur]));
> else
> {
> - OCL_ASSERT(fabs(gpu_data[index_cur] - cpu_data[index_cur]) <
> cl_FLT_ULP(cpu_data[index_cur]) * ULPSIZE_FACTOR);
> + OCL_ASSERT((fabs(gpu_data[index_cur] - cpu_data[index_cur]) <
> cl_FLT_ULP(cpu_data[index_cur]) * ULPSIZE_FACTOR) ||
> + (!denormals_supported && gpu_data[index_cur]==0 &&
> + std::fpclassify(cpu_data[index_cur])==FP_SUBNORMAL) );
> }
> #endif
> }
>
>
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list