[Beignet] [PATCH] Utest: Add check for OpenCL 2.0 extension
Xiuli Pan
xiuli.pan at intel.com
Tue Jul 19 02:55:32 UTC 2016
From: Pan Xiuli <xiuli.pan at intel.com>
Beignet has some opencl2.0 builtin functions, add check for OpenCL 2.0
or Beignet for these test cases.
Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
utests/builtin_global_linear_id.cpp | 2 ++
utests/builtin_local_linear_id.cpp | 2 ++
utests/utest_helper.cpp | 29 +++++++++++++++++++++++++++++
utests/utest_helper.hpp | 3 +++
4 files changed, 36 insertions(+)
diff --git a/utests/builtin_global_linear_id.cpp b/utests/builtin_global_linear_id.cpp
index 06807c2..cda7e84 100644
--- a/utests/builtin_global_linear_id.cpp
+++ b/utests/builtin_global_linear_id.cpp
@@ -29,6 +29,8 @@ dimension:3
#include "utest_helper.hpp"
static void builtin_global_linear_id(void)
{
+ if (!cl_check_ocl20())
+ return;
// Setup kernel and buffers
int dim, err, i, buf_len=1;
diff --git a/utests/builtin_local_linear_id.cpp b/utests/builtin_local_linear_id.cpp
index 8d706d0..88cb357 100644
--- a/utests/builtin_local_linear_id.cpp
+++ b/utests/builtin_local_linear_id.cpp
@@ -30,6 +30,8 @@ dimension:3
#include "utest_helper.hpp"
static void builtin_local_linear_id(void)
{
+ if (!cl_check_ocl20())
+ return;
// Setup kernel and buffers
int dim, i, buf_len=1;
diff --git a/utests/utest_helper.cpp b/utests/utest_helper.cpp
index 0ecbea3..da4cfbf 100644
--- a/utests/utest_helper.cpp
+++ b/utests/utest_helper.cpp
@@ -896,3 +896,32 @@ int cl_check_subgroups(void)
return 1;
}
+int cl_check_ocl20(void)
+{
+ size_t param_value_size;
+ size_t ret_sz;
+ OCL_CALL(clGetDeviceInfo, device, CL_DEVICE_OPENCL_C_VERSION, 0, 0, ¶m_value_size);
+ if(param_value_size == 0) {
+ printf("Not OpenCL 2.0 device, ");
+ if(cl_check_beignet()) {
+ printf("Beignet extension test!");
+ return 1;
+ }
+ return 0;
+ }
+ char* device_version_str = (char* )malloc(param_value_size * sizeof(char) );
+ OCL_CALL(clGetDeviceInfo, device, CL_DEVICE_OPENCL_C_VERSION, param_value_size, (void*)device_version_str, &ret_sz);
+ OCL_ASSERT(ret_sz == param_value_size);
+
+ if(!strstr(device_version_str, "2.0")) {
+ free(device_version_str);
+ printf("Not OpenCL 2.0 device, ");
+ if(cl_check_beignet()) {
+ printf("Beignet extension test!");
+ return 1;
+ }
+ return 0;
+ }
+ free(device_version_str);
+ return 1;
+}
diff --git a/utests/utest_helper.hpp b/utests/utest_helper.hpp
index 7d05056..421e356 100644
--- a/utests/utest_helper.hpp
+++ b/utests/utest_helper.hpp
@@ -296,4 +296,7 @@ typedef cl_int(clGetKernelSubGroupInfoKHR_cb)(cl_kernel, cl_device_id,
const void *, size_t, void *,
size_t *);
extern clGetKernelSubGroupInfoKHR_cb* utestclGetKernelSubGroupInfoKHR;
+
+/* Check is cl version 2.0. */
+extern int cl_check_ocl20(void);
#endif /* __UTEST_HELPER_HPP__ */
--
2.5.0
More information about the Beignet
mailing list