[Beignet] [PATCH 2/2] utests: extent get_image_size cases to other informations..

Zhigang Gong zhigang.gong at linux.intel.com
Mon May 20 02:00:38 PDT 2013


Extent it to test all the supported image informations.

Signed-off-by: Zhigang Gong <zhigang.gong at linux.intel.com>
---
 kernels/test_get_image_info.cl     | 13 +++++++++++
 kernels/test_get_image_size.cl     |  9 --------
 utests/CMakeLists.txt              |  2 +-
 utests/compiler_get_image_info.cpp | 46 ++++++++++++++++++++++++++++++++++++++
 utests/compiler_get_image_size.cpp | 37 ------------------------------
 5 files changed, 60 insertions(+), 47 deletions(-)
 create mode 100644 kernels/test_get_image_info.cl
 delete mode 100644 kernels/test_get_image_size.cl
 create mode 100644 utests/compiler_get_image_info.cpp
 delete mode 100644 utests/compiler_get_image_size.cpp

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_info.cpp b/utests/compiler_get_image_info.cpp
new file mode 100644
index 0000000..f1b12c0
--- /dev/null
+++ b/utests/compiler_get_image_info.cpp
@@ -0,0 +1,46 @@
+#include "utest_helper.hpp"
+
+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_IMAGE3D;
+  desc.image_width = w;
+  desc.image_height = h;
+  desc.image_depth = depth;
+  desc.image_row_pitch = 0;
+
+  // Setup kernel and images
+  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 << 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_info);
diff --git a/utests/compiler_get_image_size.cpp b/utests/compiler_get_image_size.cpp
deleted file mode 100644
index 49c08ad..0000000
--- a/utests/compiler_get_image_size.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-#include "utest_helper.hpp"
-
-static void compiler_get_image_size(void)
-{
-  const size_t w = 256;
-  const size_t h = 512;
-  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_width = w;
-  desc.image_height = h;
-  desc.image_row_pitch = 0;
-
-  // Setup kernel and images
-  OCL_CREATE_KERNEL("test_get_image_size");
-
-  OCL_CREATE_IMAGE(buf[0], 0, &format, &desc, NULL);
-  OCL_CREATE_BUFFER(buf[1], 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]);
-  globals[0] = 32;
-  locals[0] = 16;
-  OCL_NDRANGE(1);
-
-  // Check result
-  OCL_MAP_BUFFER(1);
-  for (uint32_t i = 0; i < 32; i++)
-    OCL_ASSERT(((uint32_t*)buf_data[1])[i] == ((w << 16) | (h)));
-  OCL_UNMAP_BUFFER(0);
-}
-
-MAKE_UTEST_FROM_FUNCTION(compiler_get_image_size);
-- 
1.7.11.7



More information about the Beignet mailing list