From e5d25dac46ab2f90d9fc66210f3bdc54e72445fe Mon Sep 17 00:00:00 2001 From: Junyan He Date: Tue, 10 Jun 2014 12:53:22 +0800 Subject: [PATCH] Add the utest case for printf Signed-off-by: Junyan He Reviewed-by: Zhigang Gong --- kernels/test_printf.cl | 13 +++++++++++++ utests/CMakeLists.txt | 1 + utests/test_printf.cpp | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 kernels/test_printf.cl create mode 100644 utests/test_printf.cpp diff --git a/kernels/test_printf.cl b/kernels/test_printf.cl new file mode 100644 index 0000000..3f4c98d --- /dev/null +++ b/kernels/test_printf.cl @@ -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)); +} diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt index 1c523cb..76bc56e 100644 --- a/utests/CMakeLists.txt +++ b/utests/CMakeLists.txt @@ -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 index 0000000..ac17d9d --- /dev/null +++ b/utests/test_printf.cpp @@ -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); -- 2.7.4