summaryrefslogtreecommitdiff
path: root/utests
diff options
context:
space:
mode:
authorMeng Mengmeng <mengmeng.meng@intel.com>2015-07-15 01:22:34 +0800
committerYang Rong <rong.r.yang@intel.com>2015-07-15 16:56:45 +0800
commit83f2ce719adfcae6433026b884e916d9c0b0ce65 (patch)
tree40e97b32f889d147d08b7238d98a2f5fbdc332fb /utests
parent6e85bd3d03acc298ef5ee2c4fac6c3d4e9b66e27 (diff)
correct ULP value in utests
Set a global function in utests to get the right ULP value.
Diffstat (limited to 'utests')
-rw-r--r--utests/builtin_pow.cpp6
-rw-r--r--utests/builtin_tgamma.cpp6
-rw-r--r--utests/utest_generator.py12
-rw-r--r--utests/utest_helper.cpp12
-rw-r--r--utests/utest_helper.hpp4
5 files changed, 24 insertions, 16 deletions
diff --git a/utests/builtin_pow.cpp b/utests/builtin_pow.cpp
index a8523d30..f5864483 100644
--- a/utests/builtin_pow.cpp
+++ b/utests/builtin_pow.cpp
@@ -28,6 +28,7 @@ static void builtin_pow(void)
{
// Setup kernel and buffers
int k, i, index_cur;
+ float ULPSIZE_NO_FAST_MATH = 16.0;
float gpu_data[max_function * count_input] = {0}, cpu_data[max_function * count_input] = {0};
for(i=0; i<count_input_ori;i++)
@@ -40,10 +41,7 @@ static void builtin_pow(void)
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)
- ULPSIZE_FACTOR = 10000.;
+ float ULPSIZE_FACTOR = select_ulpsize(ULPSIZE_FAST_MATH,ULPSIZE_NO_FAST_MATH);
OCL_CREATE_KERNEL("builtin_pow");
diff --git a/utests/builtin_tgamma.cpp b/utests/builtin_tgamma.cpp
index b7db69b0..db9ab3c2 100644
--- a/utests/builtin_tgamma.cpp
+++ b/utests/builtin_tgamma.cpp
@@ -6,6 +6,7 @@ void builtin_tgamma(void)
{
const int n = 1024;
float src[n];
+ float ULPSIZE_NO_FAST_MATH = 16.0;
// Setup kernel and buffers
OCL_CREATE_KERNEL("builtin_tgamma");
@@ -15,10 +16,7 @@ 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 = 16.0;
- if (env_strict == NULL || strcmp(env_strict, "0") == 0)
- ULPSIZE_FACTOR = 10000.;
+ float ULPSIZE_FACTOR = select_ulpsize(ULPSIZE_FAST_MATH,ULPSIZE_NO_FAST_MATH);
cl_device_fp_config fp_config;
clGetDeviceInfo(device, CL_DEVICE_SINGLE_FP_CONFIG, sizeof(cl_device_fp_config), &fp_config, 0);
diff --git a/utests/utest_generator.py b/utests/utest_generator.py
index 7d2d3a06..c2205750 100644
--- a/utests/utest_generator.py
+++ b/utests/utest_generator.py
@@ -108,12 +108,8 @@ def udebug(ulpSize,returnType,function):
static const char* INFORNAN;
static %s ULPSIZE, ULPSIZE_FACTOR;
- const char* env_strict = getenv("OCL_STRICT_CONFORMANCE");
-
- if (env_strict == NULL || strcmp(env_strict, "0") == 0)
- ULPSIZE_FACTOR = 1000;
- else
- ULPSIZE_FACTOR = %s;
+ float ULPSIZE_NO_FAST_MATH = %s;
+ ULPSIZE_FACTOR = select_ulpsize(ULPSIZE_FAST_MATH,ULPSIZE_NO_FAST_MATH);
if (isinf(cpu_data[index])){
INFORNAN="INF";
@@ -147,11 +143,11 @@ def udebug(ulpSize,returnType,function):
#else
if (isinf(cpu_data[index])){
sprintf(log, "%s expect:%s\\n", log, INFORNAN);
- OCL_ASSERTM(isinf(gpu_data[index]) || !env_strict,log);
+ OCL_ASSERTM(isinf(gpu_data[index]),log);
}
else if (isnan(cpu_data[index])){
sprintf(log, "%s expect:%s\\n", log, INFORNAN);
- OCL_ASSERTM(isnan(gpu_data[index]) || !env_strict,log);
+ OCL_ASSERTM(isnan(gpu_data[index]),log);
}
else{
sprintf(log, "%s expect:%s\\n", log, ULPSIZE);
diff --git a/utests/utest_helper.cpp b/utests/utest_helper.cpp
index d3c378e9..8f772fd4 100644
--- a/utests/utest_helper.cpp
+++ b/utests/utest_helper.cpp
@@ -53,6 +53,7 @@ cl_mem buf[MAX_BUFFER_N] = {};
void *buf_data[MAX_BUFFER_N] = {};
size_t globals[3] = {};
size_t locals[3] = {};
+float ULPSIZE_FAST_MATH = 10000.;
#ifdef HAS_EGL
Display *xDisplay;
@@ -702,3 +703,14 @@ double time_subtract(struct timeval *y, struct timeval *x, struct timeval *resul
double msec = 1000.0*(y->tv_sec - x->tv_sec) + (y->tv_usec - x->tv_usec)/1000.0;
return msec;
}
+
+float select_ulpsize(float ULPSIZE_FAST_MATH, float ULPSIZE_NO_FAST_MATH)
+{
+ const char* env_strict = getenv("OCL_STRICT_CONFORMANCE");
+
+ float ULPSIZE_FACTOR = ULPSIZE_NO_FAST_MATH;
+ if (env_strict != NULL && strcmp(env_strict, "0") == 0 )
+ ULPSIZE_FACTOR = ULPSIZE_FAST_MATH;
+
+ return ULPSIZE_FACTOR;
+}
diff --git a/utests/utest_helper.hpp b/utests/utest_helper.hpp
index 6d097662..3b17606d 100644
--- a/utests/utest_helper.hpp
+++ b/utests/utest_helper.hpp
@@ -165,6 +165,7 @@ extern cl_mem buf[MAX_BUFFER_N];
extern void* buf_data[MAX_BUFFER_N];
extern size_t globals[3];
extern size_t locals[3];
+extern float ULPSIZE_FAST_MATH;
enum {
SOURCE = 0,
@@ -233,5 +234,8 @@ extern int cl_INT_ULP(int int_number);
/* subtract the time */
double time_subtract(struct timeval *y, struct timeval *x, struct timeval *result);
+/* check ulpsize */
+float select_ulpsize(float ULPSIZE_FAST_MATH, float ULPSIZE_NO_FAST_MATH);
+
#endif /* __UTEST_HELPER_HPP__ */