[Beignet] *** SPAM LEVEL 4.053 *** Re: [PATCH 2/2] utests: extent get_image_size cases to other informations..

Zhigang Gong zhigang.gong at linux.intel.com
Tue May 21 01:10:49 PDT 2013


We should initialize all the image descriptor elements. This is the 2nd version
of unit test cases. Simon, could you give it a try. The patch 1 remains the same.

>From 6d023728e9c32dd06a5dff105ed2986fd63df1fc Mon Sep 17 00:00:00 2001
From: Zhigang Gong <zhigang.gong at linux.intel.com>
Date: Mon, 20 May 2013 16:41:28 +0800
Subject: [PATCH v2 2/2] utests: extent get_image_size cases to other
 informations..

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




On Tue, May 21, 2013 at 09:06:48AM +0200, Simon Richter wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi,
> 
> On 20.05.2013 11:00, Zhigang Gong wrote:
> 
> > Extent it to test all the supported image informations.
> 
> > +++ b/utests/compiler_get_image_info.cpp
> 
> > +  OCL_CREATE_IMAGE(buf[0], 0, &format, &desc, NULL);
> 
> I get an assertion failure here:
> 
> compiler_get_image_info:
>   compiler_get_image_info()    [FAILED]
>     Error: error calling clCreateImage with errorCL_INVALID_IMAGE_SIZE
> 
>    Simon
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.12 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iJwEAQECAAYFAlGbHQcACgkQ0sfeulffv7thdwP+M27yYxZ81Yy/oT8SASahGPNa
> TTeotPFm9Pg+prPCG/ERGqXCrVDIOyIzVFPzdUlDyvcWX2A4StxFwPd6b7IbVaja
> 2osb80G5Ckfusr7U64nr8CPNKsh/vz/9BgauHVNe1iQDG6iJKfiMk5mv9YXLc+LW
> L0OAFrz9dbLPxo4T6Ok=
> =gY4G
> -----END PGP SIGNATURE-----
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list