[Beignet] [PATCH 12/13] Utests: Add double check and refine compiler_double case.
junyan.he at inbox.com
junyan.he at inbox.com
Fri Sep 18 02:58:23 PDT 2015
From: Junyan He <junyan.he at linux.intel.com>
Signed-off-by: Junyan He <junyan.he at linux.intel.com>
---
utests/CMakeLists.txt | 1 +
utests/compiler_double.cpp | 5 ++++-
utests/utest_helper.cpp | 19 +++++++++++++++++++
utests/utest_helper.hpp | 3 +++
4 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt
index e7a9e26..a17ab55 100644
--- a/utests/CMakeLists.txt
+++ b/utests/CMakeLists.txt
@@ -194,6 +194,7 @@ set (utests_sources
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 7c54ddf..fc89a0f 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/utest_helper.cpp b/utests/utest_helper.cpp
index 8f772fd..37a5697 100644
--- a/utests/utest_helper.cpp
+++ b/utests/utest_helper.cpp
@@ -714,3 +714,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 3b17606..7453854 100644
--- a/utests/utest_helper.hpp
+++ b/utests/utest_helper.hpp
@@ -237,5 +237,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__ */
--
1.9.1
More information about the Beignet
mailing list