diff options
author | Rebecca N. Palmer <rebecca_palmer@zoho.com> | 2015-04-29 13:58:13 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2015-04-29 13:58:13 +0800 |
commit | 8948353e839fab850e1fcdd4212061e726e33aab (patch) | |
tree | bc7874e7314b58c219e122c594300e3a47a21224 /utests/builtin_pow.cpp | |
parent | dc22a04dcb5142444f7816f1b6352e5dbef5f8c1 (diff) | |
download | beignet-8948353e839fab850e1fcdd4212061e726e33aab.tar.gz |
utest_pow: don't fail on declared lack of denormals.
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@zoho.com>
Reviewed-by: "Song, Ruiling" <ruiling.song@intel.com>
Diffstat (limited to 'utests/builtin_pow.cpp')
-rw-r--r-- | utests/builtin_pow.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/utests/builtin_pow.cpp b/utests/builtin_pow.cpp index a18f31e8..a8523d30 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,9 @@ 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 +93,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 } |