[Beignet] [PATCH 1/2] Fix a CL_MEM_HOST_PTR bug.

Yang Rong rong.r.yang at intel.com
Mon Jun 23 07:38:35 PDT 2014


Can't add sub_offset if mem is image.

Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
 src/cl_mem.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/cl_mem.c b/src/cl_mem.c
index e0c4ec9..46d9af1 100644
--- a/src/cl_mem.c
+++ b/src/cl_mem.c
@@ -71,7 +71,6 @@ cl_get_mem_object_info(cl_mem mem,
                 void *param_value,
                 size_t *param_value_size_ret)
 {
-  struct _cl_mem_buffer* buf = (struct _cl_mem_buffer*)mem;
   switch(param_name)
   {
     FIELD_SIZE(MEM_TYPE, cl_mem_object_type);
@@ -99,7 +98,12 @@ cl_get_mem_object_info(cl_mem mem,
     *((size_t *)param_value) = mem->size;
     break;
   case CL_MEM_HOST_PTR:
-    *((size_t *)param_value) = (size_t)mem->host_ptr + buf->sub_offset;
+    if(mem->type == CL_MEM_IMAGE_TYPE) {
+      *((size_t *)param_value) = (size_t)mem->host_ptr;
+    } else {
+      struct _cl_mem_buffer* buf = (struct _cl_mem_buffer*)mem;
+      *((size_t *)param_value) = (size_t)mem->host_ptr + buf->sub_offset;
+    }
     break;
   case CL_MEM_MAP_COUNT:
     *((cl_uint *)param_value) = mem->map_ref;
-- 
1.8.3.2



More information about the Beignet mailing list