Add the utest case for printf
authorJunyan He <junyan.he@linux.intel.com>
Tue, 10 Jun 2014 04:53:22 +0000 (12:53 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Wed, 11 Jun 2014 03:04:11 +0000 (11:04 +0800)
Signed-off-by: Junyan He <junyan.he@linux.intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
kernels/test_printf.cl [new file with mode: 0644]
utests/CMakeLists.txt
utests/test_printf.cpp [new file with mode: 0644]

diff --git a/kernels/test_printf.cl b/kernels/test_printf.cl
new file mode 100644 (file)
index 0000000..3f4c98d
--- /dev/null
@@ -0,0 +1,13 @@
+__kernel void
+test_printf(void)
+{
+  int x = (int)get_global_id(0);
+  int y = (int)get_global_id(1);
+  int z = (int)get_global_id(2);
+
+  if (x % 15 == 0)
+    if (y % 3 == 0)
+      if (z % 7 == 0)
+        printf("######## global_id(x, y, z) = (%d, %d, %d), global_size(d0, d1, d3) = (%d, %d, %d)\n",
+                x, y, z, get_global_size(0), get_global_size(1), get_global_size(2));
+}
index 1c523cb..76bc56e 100644 (file)
@@ -172,6 +172,7 @@ set (utests_sources
   profiling_exec.cpp
   enqueue_copy_buf.cpp
   enqueue_copy_buf_unaligned.cpp
+  test_printf.cpp
   utest_assert.cpp
   utest.cpp
   utest_file_map.cpp
diff --git a/utests/test_printf.cpp b/utests/test_printf.cpp
new file mode 100644 (file)
index 0000000..ac17d9d
--- /dev/null
@@ -0,0 +1,18 @@
+#include "utest_helper.hpp"
+
+void test_printf(void)
+{
+  // Setup kernel and buffers
+  OCL_CREATE_KERNEL("test_printf");
+  globals[0] = 16;
+  locals[0] = 16;
+  globals[1] = 4;
+  locals[1] = 4;
+  globals[2] = 8;
+  locals[2] = 8;
+
+  // Run the kernel on GPU
+  OCL_NDRANGE(3);
+}
+
+MAKE_UTEST_FROM_FUNCTION(test_printf);