From 63c85d71062058e718dc7c1e291286be8ea3cc61 Mon Sep 17 00:00:00 2001 From: Rebecca Palmer Date: Wed, 5 Nov 2014 12:27:16 +0800 Subject: utests: fix bugs in builtin_tgamma(). This patch is based on Rebecca's patch at: https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=Fix-pow-erf-tgamma.patch;att=3;bug=768090. And fixed another bug which we should not use an absolute error checking. We should use ULP and considering the strict conformance or non strict conformance state. Signed-off-by: Zhigang Gong Signed-off-by: Rebecca Palmer Reviewed-by: "Song, Ruiling" --- utests/builtin_tgamma.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'utests/builtin_tgamma.cpp') diff --git a/utests/builtin_tgamma.cpp b/utests/builtin_tgamma.cpp index 4c824d03..16dac97d 100644 --- a/utests/builtin_tgamma.cpp +++ b/utests/builtin_tgamma.cpp @@ -1,5 +1,6 @@ #include #include "utest_helper.hpp" +#include void builtin_tgamma(void) { @@ -14,6 +15,10 @@ void builtin_tgamma(void) OCL_SET_ARG(1, sizeof(cl_mem), &buf[1]); globals[0] = n; locals[0] = 16; + const char* env_strict = getenv("OCL_STRICT_CONFORMANCE"); + float ULPSIZE_FACTOR = 1.0; + if (env_strict == NULL || strcmp(env_strict, "0") == 0) + ULPSIZE_FACTOR = 10000.; for (int j = 0; j < 1024; j ++) { OCL_MAP_BUFFER(0); @@ -27,10 +32,10 @@ void builtin_tgamma(void) OCL_MAP_BUFFER(1); float *dst = (float*)buf_data[1]; for (int i = 0; i < n; ++i) { - float cpu = gammaf(src[i]); + float cpu = tgammaf(src[i]); if (isinf(cpu)) { OCL_ASSERT(isinf(dst[i])); - } else if (fabsf(cpu - dst[i]) >= 1e-3) { + } else if (fabsf(cpu - dst[i]) >= cl_FLT_ULP(cpu) * ULPSIZE_FACTOR) { printf("%f %f %f\n", src[i], cpu, dst[i]); OCL_ASSERT(0); } -- cgit v1.2.1