[Beignet] [PATCH] utest: Add test case for build-in function get_work_dim
Yi Sun
yi.sun at intel.com
Wed May 29 05:23:25 PDT 2013
v1: We're starting to implement the test cases for each build-in fucntions, of course, occording to OpenCL 1.0 specification.
Now this case is only for compiling since function get_work_dim is just in the TO-DO list. We can enhance test case when the function is implemented.
v2: Refine the case, verifying the result of function get_work_dim.
---
kernels/buildin_work_dim.cl | 3 +++
utests/CMakeLists.txt | 1 +
utests/buildin_work_dim.cpp | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 41 insertions(+), 0 deletions(-)
create mode 100644 kernels/buildin_work_dim.cl
create mode 100644 utests/buildin_work_dim.cpp
diff --git a/kernels/buildin_work_dim.cl b/kernels/buildin_work_dim.cl
new file mode 100644
index 0000000..27c0e18
--- /dev/null
+++ b/kernels/buildin_work_dim.cl
@@ -0,0 +1,3 @@
+kernel void buildin_work_dim( __global int *ret ) {
+ *ret = get_work_dim();
+}
diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt
index 63c873d..5775357 100644
--- a/utests/CMakeLists.txt
+++ b/utests/CMakeLists.txt
@@ -76,6 +76,7 @@ set (utests_sources
compiler_volatile.cpp
compiler_copy_image1.cpp
compiler_get_image_info.cpp
+ buildin_work_dim.cpp
runtime_createcontext.cpp
utest_assert.cpp
utest.cpp
diff --git a/utests/buildin_work_dim.cpp b/utests/buildin_work_dim.cpp
new file mode 100644
index 0000000..c57be76
--- /dev/null
+++ b/utests/buildin_work_dim.cpp
@@ -0,0 +1,37 @@
+#include "utest_helper.hpp"
+
+static void buildin_work_dim(void)
+{
+ // Setup kernel and buffers
+
+ int result, err;
+ OCL_CREATE_KERNEL("buildin_work_dim");
+
+ OCL_CREATE_BUFFER(buf[0], CL_MEM_READ_WRITE, sizeof(int), NULL);
+ OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]);
+
+ globals[0] = 256;
+ globals[1] = 256;
+ globals[2] = 256;
+ locals[0] = 16;
+ locals[1] = 16;
+ locals[2] = 16;
+
+ for( int i=1; i <= 2; i++ )
+ {
+
+ // Run the kernel
+ OCL_NDRANGE(i);
+
+ err = clEnqueueReadBuffer( queue, buf[0], CL_TRUE, 0, sizeof(int), &result, 0, NULL, NULL);
+ if (err != CL_SUCCESS)
+ {
+ printf("Error: Failed to read output array! %d\n", err);
+ exit(1);
+ }
+
+ OCL_ASSERT( result == i);
+ }
+}
+
+MAKE_UTEST_FROM_FUNCTION(buildin_work_dim);
--
1.7.6.4
More information about the Beignet
mailing list