[Beignet] [PATCH 1/2] Enlarge the global mem size.

Yang Rong rong.r.yang at intel.com
Tue Nov 26 22:06:50 PST 2013


When create image, due to alignment, will casue size large than max alloc size.
Enlarge the global memory size and using it to check size when alloc.

Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
 src/cl_gt_device.h |  2 +-
 src/cl_mem.c       | 10 +++-------
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/cl_gt_device.h b/src/cl_gt_device.h
index e8fa362..d53588f 100644
--- a/src/cl_gt_device.h
+++ b/src/cl_gt_device.h
@@ -51,7 +51,7 @@
 .min_data_type_align_size = sizeof(cl_long) * 16,
 .single_fp_config = 0, /* XXX */
 .global_mem_cache_type = CL_READ_WRITE_CACHE,
-.global_mem_size = 128 * 1024 * 1024,
+.global_mem_size = 256 * 1024 * 1024,
 .max_constant_buffer_size = 512 << 10,
 .max_constant_args = 8,
 .error_correction_support = CL_FALSE,
diff --git a/src/cl_mem.c b/src/cl_mem.c
index 8c9f8a8..1380176 100644
--- a/src/cl_mem.c
+++ b/src/cl_mem.c
@@ -59,12 +59,7 @@ cl_get_mem_object_type(cl_mem mem)
     case CL_MEM_GL_IMAGE_TYPE:
     {
       struct _cl_mem_image *image = cl_mem_image(mem);
-      if (image->depth == 1)
-        return CL_MEM_OBJECT_IMAGE1D;
-      else if (image->depth == 2)
-        return CL_MEM_OBJECT_IMAGE2D;
-      else if (image->depth == 3)
-        return CL_MEM_OBJECT_IMAGE3D;
+      return image->image_type;
     }
     default:
       return CL_MEM_OBJECT_BUFFER;
@@ -209,8 +204,9 @@ cl_mem_allocate(enum cl_mem_type type,
 
   assert(ctx);
 
+  /* Due to alignment, the image size may exceed alloc max size, check global mem instead */
   if ((err = cl_get_device_info(ctx->device,
-                                CL_DEVICE_MAX_MEM_ALLOC_SIZE,
+                                CL_DEVICE_GLOBAL_MEM_SIZE,
                                 sizeof(max_mem_size),
                                 &max_mem_size,
                                 NULL)) != CL_SUCCESS) {
-- 
1.8.1.2



More information about the Beignet mailing list