diff options
Diffstat (limited to 'utests')
-rw-r--r-- | utests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | utests/compiler_double.cpp | 5 | ||||
-rw-r--r-- | utests/compiler_double_precision.cpp | 3 | ||||
-rw-r--r-- | utests/utest_helper.cpp | 19 | ||||
-rw-r--r-- | utests/utest_helper.hpp | 3 |
5 files changed, 31 insertions, 1 deletions
diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt index 2f1e10f2..3f30933a 100644 --- a/utests/CMakeLists.txt +++ b/utests/CMakeLists.txt @@ -193,6 +193,8 @@ set (utests_sources compiler_sub_group_any.cpp compiler_sub_group_all.cpp compiler_time_stamp.cpp + compiler_double_precision.cpp + compiler_double.cpp load_program_from_gen_bin.cpp load_program_from_spir.cpp get_arg_info.cpp diff --git a/utests/compiler_double.cpp b/utests/compiler_double.cpp index 7c54ddfe..fc89a0fb 100644 --- a/utests/compiler_double.cpp +++ b/utests/compiler_double.cpp @@ -12,6 +12,9 @@ void compiler_double(void) const size_t n = 16; double cpu_dst[n], cpu_src[n]; + if (!cl_check_double()) + return; + // Setup kernel and buffers OCL_CREATE_KERNEL("compiler_double"); OCL_CREATE_BUFFER(buf[0], 0, n * sizeof(double), NULL); @@ -38,7 +41,7 @@ void compiler_double(void) // Compare OCL_MAP_BUFFER(1); for (int32_t i = 0; i < (int32_t) n; ++i) - OCL_ASSERT(fabs(((double*)buf_data[1])[i] - cpu_dst[i]) < 1e-4); + OCL_ASSERT(fabs(((double*)buf_data[1])[i] - cpu_dst[i]) < 1e-32); OCL_UNMAP_BUFFER(1); } } diff --git a/utests/compiler_double_precision.cpp b/utests/compiler_double_precision.cpp index 217fd187..f77a0597 100644 --- a/utests/compiler_double_precision.cpp +++ b/utests/compiler_double_precision.cpp @@ -9,6 +9,9 @@ static void double_precision_check(void) double d1 = 0.12355678922345678; float cpu_result = d1 - d0; + if (!cl_check_double()) + return; + // Setup kernel and buffers OCL_CREATE_KERNEL("double_precision_check"); //OCL_CREATE_KERNEL("compiler_array"); diff --git a/utests/utest_helper.cpp b/utests/utest_helper.cpp index 2d914269..0aab208b 100644 --- a/utests/utest_helper.cpp +++ b/utests/utest_helper.cpp @@ -821,3 +821,22 @@ float select_ulpsize(float ULPSIZE_FAST_MATH, float ULPSIZE_NO_FAST_MATH) return ULPSIZE_FACTOR; } + +int cl_check_double(void) +{ + std::string extStr; + size_t param_value_size; + OCL_CALL(clGetDeviceInfo, device, CL_DEVICE_EXTENSIONS, 0, 0, ¶m_value_size); + std::vector<char> param_value(param_value_size); + OCL_CALL(clGetDeviceInfo, device, CL_DEVICE_EXTENSIONS, param_value_size, + param_value.empty() ? NULL : ¶m_value.front(), ¶m_value_size); + if (!param_value.empty()) + extStr = std::string(¶m_value.front(), param_value_size-1); + + if (std::strstr(extStr.c_str(), "cl_khr_fp64") == NULL) { + printf("No cl_khr_fp64, Skip!"); + return 0; + } + + return 1; +} diff --git a/utests/utest_helper.hpp b/utests/utest_helper.hpp index 2008bdd6..c6f6384a 100644 --- a/utests/utest_helper.hpp +++ b/utests/utest_helper.hpp @@ -241,5 +241,8 @@ double time_subtract(struct timeval *y, struct timeval *x, struct timeval *resul /* check ulpsize */ float select_ulpsize(float ULPSIZE_FAST_MATH, float ULPSIZE_NO_FAST_MATH); +/* Check is FP64 enabled. */ +extern int cl_check_double(void); + #endif /* __UTEST_HELPER_HPP__ */ |