[Beignet] [PATCH 2/2] Fix bug of size of tmp_ker_buf for TILE_Y copying of large image.
yan.wang at linux.intel.com
yan.wang at linux.intel.com
Fri May 26 08:07:20 UTC 2017
From: Yan Wang <yan.wang at linux.intel.com>
the size should be calculated based region and bpp of image instead
of the whole image size.
Otherwise, it will cause allocations of conformance test failed.
Signed-off-by: Yan Wang <yan.wang at linux.intel.com>
---
src/cl_api_mem.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/cl_api_mem.c b/src/cl_api_mem.c
index 7b58236..209d0dc 100644
--- a/src/cl_api_mem.c
+++ b/src/cl_api_mem.c
@@ -1537,12 +1537,13 @@ clEnqueueMapImageByKernel(cl_command_queue command_queue,
if (image->tmp_ker_buf)
clReleaseMemObject(image->tmp_ker_buf);
+ size_t buf_size = region[0] * region[1] * region[2] * image->bpp;
if(mem->flags & CL_MEM_USE_HOST_PTR)
image->tmp_ker_buf =
- clCreateBuffer(command_queue->ctx, CL_MEM_USE_HOST_PTR, mem->size, mem->host_ptr, &err);
+ clCreateBuffer(command_queue->ctx, CL_MEM_USE_HOST_PTR, buf_size, mem->host_ptr, &err);
else
image->tmp_ker_buf =
- clCreateBuffer(command_queue->ctx, CL_MEM_ALLOC_HOST_PTR, mem->size, NULL, &err);
+ clCreateBuffer(command_queue->ctx, CL_MEM_ALLOC_HOST_PTR, buf_size, NULL, &err);
if (image->tmp_ker_buf == NULL || err != CL_SUCCESS) {
image->tmp_ker_buf = NULL;
*errcode_ret = err;
@@ -1559,7 +1560,7 @@ clEnqueueMapImageByKernel(cl_command_queue command_queue,
}
return clEnqueueMapBuffer(command_queue, image->tmp_ker_buf, blocking_map, map_flags, 0,
- mem->size, num_events_in_wait_list, event_wait_list, event, errcode_ret);
+ buf_size, num_events_in_wait_list, event_wait_list, event, errcode_ret);
}
void *
@@ -1778,8 +1779,9 @@ clEnqueueReadImageByKernel(cl_command_queue command_queue,
if (image->tmp_ker_buf)
clReleaseMemObject(image->tmp_ker_buf);
+ size_t buf_size = region[0] * region[1] * region[2] * image->bpp;
image->tmp_ker_buf = clCreateBuffer(command_queue->ctx, CL_MEM_ALLOC_HOST_PTR,
- mem->size, NULL, &err);
+ buf_size, NULL, &err);
if (image->tmp_ker_buf == NULL || err != CL_SUCCESS) {
image->tmp_ker_buf = NULL;
return err;
@@ -1794,7 +1796,7 @@ clEnqueueReadImageByKernel(cl_command_queue command_queue,
}
return clEnqueueReadBuffer(command_queue, image->tmp_ker_buf, blocking_read, 0,
- mem->size, ptr, num_events_in_wait_list, event_wait_list, event);
+ buf_size, ptr, num_events_in_wait_list, event_wait_list, event);
}
cl_int
@@ -1985,7 +1987,8 @@ clEnqueueWriteImageByKernel(cl_command_queue command_queue,
if (image->tmp_ker_buf)
clReleaseMemObject(image->tmp_ker_buf);
- image->tmp_ker_buf = clCreateBuffer(command_queue->ctx, CL_MEM_USE_HOST_PTR, mem->size, (void*)ptr, &err);
+ size_t buf_size = region[0] * region[1] * region[2] * image->bpp;
+ image->tmp_ker_buf = clCreateBuffer(command_queue->ctx, CL_MEM_USE_HOST_PTR, buf_size, (void*)ptr, &err);
if (image->tmp_ker_buf == NULL || err != CL_SUCCESS) {
image->tmp_ker_buf = NULL;
return err;
--
2.7.4
More information about the Beignet
mailing list