summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPan Xiuli <xiuli.pan@intel.com>2016-07-19 10:55:32 +0800
committerYang Rong <rong.r.yang@intel.com>2016-07-20 17:35:52 +0800
commit8e5faaeba359bcfe0b9e7b2ee30c04c6a6c654f3 (patch)
tree8eeb7322d157a38fa9fc6c2b9a000629e83b8449
parentbe7edccf4378987b8f52aaea64e26180e1fb5472 (diff)
downloadbeignet-8e5faaeba359bcfe0b9e7b2ee30c04c6a6c654f3.tar.gz
Utest: Add check for OpenCL 2.0 extension
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@intel.com> Reviewed-by: Yang Rong <rong.r.yang@intel.com>
-rw-r--r--utests/builtin_global_linear_id.cpp2
-rw-r--r--utests/builtin_local_linear_id.cpp2
-rw-r--r--utests/utest_helper.cpp29
-rw-r--r--utests/utest_helper.hpp3
4 files changed, 36 insertions, 0 deletions
diff --git a/utests/builtin_global_linear_id.cpp b/utests/builtin_global_linear_id.cpp
index 06807c20..cda7e840 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 8d706d05..88cb3572 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 0ecbea31..da4cfbff 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, &param_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 7d050569..421e356a 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__ */