[Beignet] [PATCH] fix w of image when simulate image1dbuffer with image2d

Guo Yejun yejun.guo at intel.com
Fri Sep 2 02:03:50 UTC 2016


and also change the utest to hit the potential case

Signed-off-by: Guo Yejun <yejun.guo at intel.com>
---
 src/cl_mem.c               | 1 -
 utests/image_1D_buffer.cpp | 6 +++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/cl_mem.c b/src/cl_mem.c
index 06e7c18..ad1c8c2 100644
--- a/src/cl_mem.c
+++ b/src/cl_mem.c
@@ -1118,7 +1118,6 @@ _cl_mem_new_image_from_buffer(cl_context ctx,
   if (buffer->flags & CL_MEM_USE_HOST_PTR)
     image->host_ptr = buffer->host_ptr + offset;
   cl_mem_image(image)->offset = offset;
-  cl_mem_image(image)->w = image_desc->image_width;
   cl_mem_add_ref(buffer);
   cl_mem_image(image)->buffer_1d = buffer;
   return image;
diff --git a/utests/image_1D_buffer.cpp b/utests/image_1D_buffer.cpp
index 66eb6e7..fefb241 100644
--- a/utests/image_1D_buffer.cpp
+++ b/utests/image_1D_buffer.cpp
@@ -3,8 +3,8 @@
 
 void image_1D_buffer(void)
 {
-  size_t buffer_sz = 65536;
-  char *buf_content = (char *)malloc(buffer_sz * sizeof(int));
+  size_t buffer_sz = 8192 * 2 + 32;
+  int *buf_content = (int *)malloc(buffer_sz * sizeof(int));
   int error;
   cl_image_desc image_desc;
   cl_image_format image_format;
@@ -13,7 +13,7 @@ void image_1D_buffer(void)
   OCL_CREATE_KERNEL("image_1D_buffer");
 
   for (int32_t i = 0; i < (int32_t)buffer_sz; ++i)
-    buf_content[i] = (rand() & 0xFFFFFFFF);
+    buf_content[i] = rand();
 
   OCL_CREATE_BUFFER(buf[0], CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, buffer_sz * sizeof(int), buf_content);
   OCL_CREATE_BUFFER(buf[1], CL_MEM_READ_WRITE, buffer_sz * sizeof(int), NULL);
-- 
1.9.1



More information about the Beignet mailing list