From 29a95a46f8e31d73b58be031aa6a7342eedfa887 Mon Sep 17 00:00:00 2001 From: Zhigang Gong Date: Mon, 20 May 2013 16:41:28 +0800 Subject: [PATCH] utests: extent get_image_size cases to other informations.. Extent it to test all the supported image informations. Signed-off-by: Zhigang Gong Tested-by: Simon Richter --- kernels/test_get_image_info.cl | 13 +++++++++++ kernels/test_get_image_size.cl | 9 -------- utests/CMakeLists.txt | 2 +- ..._image_size.cpp => compiler_get_image_info.cpp} | 25 ++++++++++++++++------ 4 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 kernels/test_get_image_info.cl delete mode 100644 kernels/test_get_image_size.cl rename utests/{compiler_get_image_size.cpp => compiler_get_image_info.cpp} (50%) diff --git a/kernels/test_get_image_info.cl b/kernels/test_get_image_info.cl new file mode 100644 index 0000000..8f69b75 --- /dev/null +++ b/kernels/test_get_image_info.cl @@ -0,0 +1,13 @@ +__kernel void +test_get_image_info(__write_only image3d_t src, __global int *size, __global int *fmt) +{ + int id = (int)get_global_id(0); + int w, h, depth; + w = get_image_width(src); + h = get_image_height(src); + depth = get_image_depth(src); + int channel_data_type = get_image_channel_data_type(src); + int channel_order = get_image_channel_order(src); + size[id] = (w << 20 | h << 8 | depth); + fmt[id] = (channel_data_type << 16 | channel_order); +} diff --git a/kernels/test_get_image_size.cl b/kernels/test_get_image_size.cl deleted file mode 100644 index aeb7d66..0000000 --- a/kernels/test_get_image_size.cl +++ /dev/null @@ -1,9 +0,0 @@ -__kernel void -test_get_image_size(__write_only image2d_t src, __global int *info) -{ - int id = (int)get_global_id(0); - int w, h; - w = get_image_width(src); - h = get_image_height(src); - info[id] = (w << 16 | h); -} diff --git a/utests/CMakeLists.txt b/utests/CMakeLists.txt index 2ba01c4..63c873d 100644 --- a/utests/CMakeLists.txt +++ b/utests/CMakeLists.txt @@ -75,7 +75,7 @@ set (utests_sources compiler_movforphi_undef.cpp compiler_volatile.cpp compiler_copy_image1.cpp - compiler_get_image_size.cpp + compiler_get_image_info.cpp runtime_createcontext.cpp utest_assert.cpp utest.cpp diff --git a/utests/compiler_get_image_size.cpp b/utests/compiler_get_image_info.cpp similarity index 50% rename from utests/compiler_get_image_size.cpp rename to utests/compiler_get_image_info.cpp index 49c08ad..3b9d132 100644 --- a/utests/compiler_get_image_size.cpp +++ b/utests/compiler_get_image_info.cpp @@ -1,37 +1,50 @@ #include "utest_helper.hpp" -static void compiler_get_image_size(void) +static void compiler_get_image_info(void) { const size_t w = 256; const size_t h = 512; + const size_t depth = 3; cl_image_format format; cl_image_desc desc; format.image_channel_order = CL_RGBA; format.image_channel_data_type = CL_UNSIGNED_INT8; - desc.image_type = CL_MEM_OBJECT_IMAGE2D; + desc.image_type = CL_MEM_OBJECT_IMAGE3D; desc.image_width = w; desc.image_height = h; + desc.image_depth = depth; desc.image_row_pitch = 0; + desc.image_slice_pitch = 0; + desc.num_mip_levels = 0; + desc.num_samples = 0; + desc.buffer = NULL; // Setup kernel and images - OCL_CREATE_KERNEL("test_get_image_size"); + OCL_CREATE_KERNEL("test_get_image_info"); OCL_CREATE_IMAGE(buf[0], 0, &format, &desc, NULL); OCL_CREATE_BUFFER(buf[1], 0, 32 * sizeof(int), NULL); + OCL_CREATE_BUFFER(buf[2], 0, 32 * sizeof(int), NULL); // Run the kernel OCL_SET_ARG(0, sizeof(cl_mem), &buf[0]); OCL_SET_ARG(1, sizeof(cl_mem), &buf[1]); + OCL_SET_ARG(2, sizeof(cl_mem), &buf[2]); globals[0] = 32; locals[0] = 16; OCL_NDRANGE(1); // Check result OCL_MAP_BUFFER(1); + OCL_MAP_BUFFER(2); for (uint32_t i = 0; i < 32; i++) - OCL_ASSERT(((uint32_t*)buf_data[1])[i] == ((w << 16) | (h))); - OCL_UNMAP_BUFFER(0); + { + OCL_ASSERT(((uint32_t*)buf_data[1])[i] == ((w << 20) | (h << 8) | depth)); + OCL_ASSERT(((uint32_t*)buf_data[2])[i] == ((CL_UNSIGNED_INT8 << 16) | CL_RGBA)); + } + OCL_UNMAP_BUFFER(1); + OCL_UNMAP_BUFFER(2); } -MAKE_UTEST_FROM_FUNCTION(compiler_get_image_size); +MAKE_UTEST_FROM_FUNCTION(compiler_get_image_info); -- 2.7.4