[Beignet] [PATCH] Add several printf utest cases.

junyan.he at inbox.com junyan.he at inbox.com
Wed Jan 27 20:20:06 PST 2016


From: Junyan He <junyan.he at linux.intel.com>

Signed-off-by: Junyan He <junyan.he at linux.intel.com>
---
 kernels/test_printf.cl | 46 ++++++++++++++++++++++++++++++++++++++++++
 utests/test_printf.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 100 insertions(+)

diff --git a/kernels/test_printf.cl b/kernels/test_printf.cl
index 0a59e88..a2d3af9 100644
--- a/kernels/test_printf.cl
+++ b/kernels/test_printf.cl
@@ -44,3 +44,49 @@ test_printf(void)
     printf("--- End to the printf test ---\n");
   }
 }
+
+__kernel void
+test_printf_1(void)
+{
+   printf("");// just test null printf
+}
+
+__kernel void
+test_printf_2(void)
+{
+   printf("float %f\n", 2.0);// just test a uniform const
+   printf("long %lx\n", 0xABCD1234CCCCDDDD);
+}
+
+__kernel void
+test_printf_3(char arg)
+{
+   printf("@@ arg from func arg is %c\n", arg);
+}
+
+__kernel void
+test_printf_4(void)
+{
+    int a = get_global_size(0);
+    int b = get_local_size(0);
+    int c = a + 1;
+    int d = b + 2;
+    int e = b * 2;
+    int f = c + 1;
+    int g = d + 2;
+    int h = e * 2;
+    int i = a + 1;
+    int j = c / 2;
+    int k = a * 2;
+    int l = c + 1;
+    int m = f + 2;
+    int n = g * 2;
+    int o = e * 2;
+    int p = a + 1;
+    int q = c / 2;
+    int r = a * 2;
+    int s = c + 1;
+    int t = f + 2;
+    printf("@@ Long result is %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
+	   a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t);
+}
diff --git a/utests/test_printf.cpp b/utests/test_printf.cpp
index 3601574..84c3fae 100644
--- a/utests/test_printf.cpp
+++ b/utests/test_printf.cpp
@@ -16,3 +16,57 @@ void test_printf(void)
 }
 
 MAKE_UTEST_FROM_FUNCTION(test_printf);
+
+void test_printf_1(void)
+{
+  // Setup kernel and buffers
+  OCL_CREATE_KERNEL_FROM_FILE("test_printf", "test_printf_1");
+  globals[0] = 1;
+  locals[0] = 1;
+
+  // Run the kernel on GPU
+  OCL_NDRANGE(1);
+}
+
+MAKE_UTEST_FROM_FUNCTION(test_printf_1);
+
+void test_printf_2(void)
+{
+  // Setup kernel and buffers
+  OCL_CREATE_KERNEL_FROM_FILE("test_printf", "test_printf_2");
+  globals[0] = 4;
+  locals[0] = 2;
+
+  // Run the kernel on GPU
+  OCL_NDRANGE(1);
+}
+
+MAKE_UTEST_FROM_FUNCTION(test_printf_2);
+
+void test_printf_3(void)
+{
+  char c = '@';
+  // Setup kernel and buffers
+  OCL_CREATE_KERNEL_FROM_FILE("test_printf", "test_printf_3");
+  globals[0] = 1;
+  locals[0] = 1;
+  OCL_SET_ARG(0, sizeof(char), &c);
+
+  // Run the kernel on GPU
+  OCL_NDRANGE(1);
+}
+
+MAKE_UTEST_FROM_FUNCTION(test_printf_3);
+
+void test_printf_4(void)
+{
+  // Setup kernel and buffers
+  OCL_CREATE_KERNEL_FROM_FILE("test_printf", "test_printf_4");
+  globals[0] = 1;
+  locals[0] = 1;
+
+  // Run the kernel on GPU
+  OCL_NDRANGE(1);
+}
+
+MAKE_UTEST_FROM_FUNCTION(test_printf_4);
-- 
1.9.1





More information about the Beignet mailing list