[Beignet] [PATCH 5/5] add functions cl_check_beignet.

xionghu.luo at intel.com xionghu.luo at intel.com
Thu Apr 21 10:50:41 UTC 2016


From: Luo Xionghu <xionghu.luo at intel.com>

__gen_ocl_get_timestamp functions is beignet builtin.

Signed-off-by: Luo Xionghu <xionghu.luo at intel.com>
---
 utests/compiler_time_stamp.cpp |  3 +++
 utests/utest_helper.cpp        | 22 ++++++++++++++++++++++
 utests/utest_helper.hpp        |  2 ++
 3 files changed, 27 insertions(+)

diff --git a/utests/compiler_time_stamp.cpp b/utests/compiler_time_stamp.cpp
index 4da5752..e376522 100644
--- a/utests/compiler_time_stamp.cpp
+++ b/utests/compiler_time_stamp.cpp
@@ -16,6 +16,9 @@ static void cpu(int global_id, int *src, int *dst) {
 
 void compiler_time_stamp(void)
 {
+  if (!cl_check_beignet())
+    return;
+
   const size_t n = 16;
   int cpu_dst[16], cpu_src[16];
 
diff --git a/utests/utest_helper.cpp b/utests/utest_helper.cpp
index 77a1926..9696dac 100644
--- a/utests/utest_helper.cpp
+++ b/utests/utest_helper.cpp
@@ -831,3 +831,25 @@ int cl_check_double(void)
 
   return 1;
 }
+
+int cl_check_beignet(void)
+{
+  size_t param_value_size;
+  size_t ret_sz;
+  OCL_CALL(clGetDeviceInfo, device, CL_DEVICE_VERSION, 0, 0, &param_value_size);
+  if(param_value_size == 0) {
+    printf("Not beignet device , Skip!");
+    return 0;
+  }
+  char* device_version_str = (char* )malloc(param_value_size * sizeof(char) );
+  OCL_CALL(clGetDeviceInfo, device, CL_DEVICE_VERSION, param_value_size, (void*)device_version_str, &ret_sz);
+  OCL_ASSERT(ret_sz == param_value_size);
+
+  if(!strstr(device_version_str, "beignet")) {
+    free(device_version_str);
+    printf("Not beignet device , Skip!");
+    return 0;
+  }
+  free(device_version_str);
+  return 1;
+}
diff --git a/utests/utest_helper.hpp b/utests/utest_helper.hpp
index 8ce7707..95c32d1 100644
--- a/utests/utest_helper.hpp
+++ b/utests/utest_helper.hpp
@@ -281,5 +281,7 @@ float select_ulpsize(float ULPSIZE_FAST_MATH, float ULPSIZE_NO_FAST_MATH);
 /* Check is FP64 enabled. */
 extern int cl_check_double(void);
 
+/* Check is beignet device. */
+extern int cl_check_beignet(void);
 #endif /* __UTEST_HELPER_HPP__ */
 
-- 
2.1.4



More information about the Beignet mailing list