summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Palmer <rebecca_palmer@zoho.com>2014-11-05 12:27:16 +0800
committerZhigang Gong <zhigang.gong@intel.com>2014-11-07 16:54:53 +0800
commit2285000156227dd2f5ee289b0a15ef02990838d1 (patch)
treec5a0860608b77dfcd6b06e5861774955161c0cbb
parent37619cd0c0a9c7d2878d21e9765e79b164525305 (diff)
utests: fix bugs in builtin_tgamma().Release_v0.9.x
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 <zhigang.gong@intel.com> Signed-off-by: Rebecca Palmer <rebecca_palmer@zoho.com> Reviewed-by: Ruiling Song <ruiling.song@intel.com>
-rw-r--r--utests/builtin_tgamma.cpp9
1 files changed, 7 insertions, 2 deletions
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 <cmath>
#include "utest_helper.hpp"
+#include <string.h>
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);
}