diff options
author | Yang Rong <rong.r.yang@intel.com> | 2014-05-20 10:46:19 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2014-05-22 13:06:45 +0800 |
commit | de996fa90c26997a9d2ecd22192c146a661161f3 (patch) | |
tree | 0df219ea9a2e668e68d346f934932b3539273705 /src/cl_enqueue.c | |
parent | a13372ca0116861983a64868d9165dd7b7119e51 (diff) | |
download | beignet-de996fa90c26997a9d2ecd22192c146a661161f3.tar.gz |
Fix map gtt fail when memory object size is too large.
After max allocate size is changed to 256M, the large memory object would map gtt
fail in some system. So when image size is large then 128M, disable tiling, and
used normal map. But in function clEnqueueMapBuffer/Image, may still fail because
unsync map.
Signed-off-by: Yang Rong <rong.r.yang@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'src/cl_enqueue.c')
-rw-r--r-- | src/cl_enqueue.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/cl_enqueue.c b/src/cl_enqueue.c index 330d2301..800668d8 100644 --- a/src/cl_enqueue.c +++ b/src/cl_enqueue.c @@ -246,17 +246,21 @@ cl_int cl_enqueue_map_buffer(enqueue_data *data) mem->type == CL_MEM_SUBBUFFER_TYPE); struct _cl_mem_buffer* buffer = (struct _cl_mem_buffer*)mem; - //because using unsync map in clEnqueueMapBuffer, so force use map_gtt here - if (!(ptr = cl_mem_map_gtt(mem))) { + if(data->unsync_map == 1) + //because using unsync map in clEnqueueMapBuffer, so force use map_gtt here + ptr = cl_mem_map_gtt(mem); + else + ptr = cl_mem_map_auto(mem); + + if (ptr == NULL) { err = CL_MAP_FAILURE; goto error; } - - ptr = (char*)ptr + data->offset + buffer->sub_offset; - assert(data->ptr == ptr); + data->ptr = ptr; if(mem->flags & CL_MEM_USE_HOST_PTR) { assert(mem->host_ptr); + ptr = (char*)ptr + data->offset + buffer->sub_offset; memcpy(mem->host_ptr + data->offset, ptr, data->size); } @@ -271,12 +275,17 @@ cl_int cl_enqueue_map_image(enqueue_data *data) void *ptr = NULL; CHECK_IMAGE(mem, image); - if (!(ptr = cl_mem_map_gtt(mem))) { + if(data->unsync_map == 1) + //because using unsync map in clEnqueueMapBuffer, so force use map_gtt here + ptr = cl_mem_map_gtt(mem); + else + ptr = cl_mem_map_auto(mem); + + if (ptr == NULL) { err = CL_MAP_FAILURE; goto error; } - - assert(data->ptr == (char*)ptr + data->offset); + data->ptr = ptr; if(mem->flags & CL_MEM_USE_HOST_PTR) { assert(mem->host_ptr); @@ -323,7 +332,7 @@ cl_int cl_enqueue_unmap_mem_object(enqueue_data *data) assert(v_ptr == mapped_ptr); } - cl_mem_unmap_gtt(memobj); + cl_mem_unmap_auto(memobj); /* shrink the mapped slot. */ if (memobj->mapped_ptr_sz/2 > memobj->map_ref) { |