summaryrefslogtreecommitdiff
path: root/utests/utest_helper.cpp
diff options
context:
space:
mode:
authorYi Sun <yi.sun@intel.com>2013-12-24 11:15:18 +0800
committerZhigang Gong <zhigang.gong@intel.com>2013-12-25 13:57:14 +0800
commitc69a86ba2760568c6c3a1b36a5dbe71d57a48fa2 (patch)
treeac3db736093ed2b5f39c3b207df1e2f1db460e7f /utests/utest_helper.cpp
parent6e2d5ebf0a09590a3365302b088de20841ebd97e (diff)
downloadbeignet-c69a86ba2760568c6c3a1b36a5dbe71d57a48fa2.tar.gz
Add test cases generator.
v1: File utest_generator.py contain the base class and function for generating File utest_math_gen.py can generate most math function for all the gentype utest_math_gen.py can be run during cmake. v2: 1. Put all the generated unit test cases to folder utest/generated. 2. Delete all generated folder while involve make clean. 3. At the top of the generated test cases, add some comments 4. Instead of defined FLT_ULP(0.000001) as the ulp unit, caculate the float ulp before using it. 5. Add several math functions' test case. v3: 1. Refine the calculation for float, and calculate each float got from cpu function. v4: Refine the calculation for float. Following fucntions test cases fail with input 0, 1 or 3.14: builtin_atan2_float builtin_atanh_float builtin_rootn_float builtin_cos_float builtin_cospi_float builtin_erf_float builtin_erfc_float builtin_mad_float builtin_nextafter_float builtin_pown_float builtin_powr_float builtin_rint_float builtin_sinpi_float builtin_tan_float builtin_tanpi_float v5: remove case builtin_mad_float todo: atan2pi fmax fmin sincos Signed-off-by: Yi Sun <yi.sun@intel.com> Signed-off-by: Yangwei Shui <yangweix.shui@intel.com> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com> Reviewed-by: "Song, Ruiling" <ruiling.song@intel.com>
Diffstat (limited to 'utests/utest_helper.cpp')
-rw-r--r--utests/utest_helper.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/utests/utest_helper.cpp b/utests/utest_helper.cpp
index b264c1b4..a7385997 100644
--- a/utests/utest_helper.cpp
+++ b/utests/utest_helper.cpp
@@ -648,3 +648,33 @@ int cl_check_image(const int *img, int w, int h, const char *bmp)
return (float(discrepancy) / float(n) > max_error_ratio) ? 0 : 1;
}
+typedef struct
+{
+ unsigned int mantissa:23;
+ unsigned int exponent:8;
+ unsigned int sign:1;
+} FLOAT;
+
+typedef union
+{
+ float f;
+ unsigned int i;
+ FLOAT spliter;
+} SF;
+
+const float cl_FLT_ULP(float float_number)
+{
+ SF floatBin, ulpBin;
+ floatBin.f = float_number;
+
+ ulpBin.spliter.sign = floatBin.spliter.sign;
+ ulpBin.spliter.exponent = floatBin.spliter.exponent;
+ ulpBin.spliter.mantissa = 0x1;
+
+ return ulpBin.f;
+}
+
+const int cl_INT_ULP(int int_number)
+{
+ return 0;
+}