summaryrefslogtreecommitdiff
path: root/utests/builtin_tgamma.cpp
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-06 15:16:07 +0800
commit63c85d71062058e718dc7c1e291286be8ea3cc61 (patch)
tree7cf51b9ccf20477ffb8ee4f09537dd4a286bcbfe /utests/builtin_tgamma.cpp
parentc98d604f34d08618a19ed3ce6057dbcb516bea38 (diff)
downloadbeignet-63c85d71062058e718dc7c1e291286be8ea3cc61.tar.gz
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 <zhigang.gong@intel.com> Signed-off-by: Rebecca Palmer <rebecca_palmer@zoho.com> Reviewed-by: "Song, Ruiling" <ruiling.song@intel.com>
Diffstat (limited to 'utests/builtin_tgamma.cpp')
-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);
}