utests: extent get_image_size cases to other informations..
authorZhigang Gong <zhigang.gong@linux.intel.com>
Mon, 20 May 2013 08:41:28 +0000 (16:41 +0800)
committerZhigang Gong <zhigang.gong@linux.intel.com>
Tue, 21 May 2013 08:44:09 +0000 (16:44 +0800)
Extent it to test all the supported image informations.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Tested-by: Simon Richter <Simon.Richter@hogyros.de>
kernels/test_get_image_info.cl [new file with mode: 0644]
kernels/test_get_image_size.cl [deleted file]
utests/CMakeLists.txt
utests/compiler_get_image_info.cpp [moved from utests/compiler_get_image_size.cpp with 50% similarity]

diff --git a/kernels/test_get_image_info.cl b/kernels/test_get_image_info.cl
new file mode 100644 (file)
index 0000000..8f69b75
--- /dev/null
@@ -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 (file)
index aeb7d66..0000000
+++ /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);
-}
index 2ba01c4..63c873d 100644 (file)
@@ -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
similarity index 50%
rename from utests/compiler_get_image_size.cpp
rename to utests/compiler_get_image_info.cpp
index 49c08ad..3b9d132 100644 (file)
@@ -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);