Enlarge the global mem size.
authorYang Rong <rong.r.yang@intel.com>
Wed, 27 Nov 2013 06:06:50 +0000 (14:06 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Wed, 27 Nov 2013 08:26:07 +0000 (16:26 +0800)
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@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
src/cl_gt_device.h
src/cl_mem.c

index e8fa362..d53588f 100644 (file)
@@ -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,
index 8c9f8a8..1380176 100644 (file)
@@ -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) {