diff options
author | Junyan He <junyan.he@linux.intel.com> | 2016-01-28 12:20:06 +0800 |
---|---|---|
committer | Yang Rong <rong.r.yang@intel.com> | 2016-04-27 16:17:52 +0800 |
commit | 161423aaf0d273f5084e61413846deb063081413 (patch) | |
tree | fea9ae8519ed54c906f44aea511252ab40f72258 | |
parent | dd15b29b4b2449671779741fdb7a6a89f06d915a (diff) |
Add several printf utest cases.
Signed-off-by: Junyan He <junyan.he@linux.intel.com>
Reviewed-by: Yan Wang <yan.wang@linux.intel.com>
Reviewed-by: Junyan He <junyan.he@linux.intel.com>
-rw-r--r-- | kernels/test_printf.cl | 46 | ||||
-rw-r--r-- | utests/test_printf.cpp | 54 |
2 files changed, 100 insertions, 0 deletions
diff --git a/kernels/test_printf.cl b/kernels/test_printf.cl index 0a59e88f..a2d3af97 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 36015745..84c3fae3 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); |