[Beignet] [PATCH] do not call memcpy for cl_enqueue_read_buffer if userptr is enabled
Yang, Rong R
rong.r.yang at intel.com
Mon Jan 4 22:21:08 PST 2016
LGTM, pushed.
> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> Guo Yejun
> Sent: Monday, January 4, 2016 9:45
> To: beignet at lists.freedesktop.org
> Cc: Guo, Yejun
> Subject: [Beignet] [PATCH] do not call memcpy for cl_enqueue_read_buffer
> if userptr is enabled
>
> sometimes, application invokes read buffer, instead of map buffer, even if
> userptr is enabled. memcpy is not necessary for such case.
>
> Signed-off-by: Guo Yejun <yejun.guo at intel.com>
> ---
> src/cl_enqueue.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/cl_enqueue.c b/src/cl_enqueue.c index cec368c..081ffce
> 100644
> --- a/src/cl_enqueue.c
> +++ b/src/cl_enqueue.c
> @@ -48,7 +48,10 @@ cl_int cl_enqueue_read_buffer(enqueue_data* data)
> if (src_ptr == NULL)
> err = CL_MAP_FAILURE;
> else {
> - memcpy(data->ptr, (char*)src_ptr + data->offset + buffer->sub_offset,
> data->size);
> + //sometimes, application invokes read buffer, instead of map buffer,
> even if userptr is enabled
> + //memcpy is not necessary for this case
> + if (data->ptr != (char*)src_ptr + data->offset + buffer->sub_offset)
> + memcpy(data->ptr, (char*)src_ptr + data->offset +
> + buffer->sub_offset, data->size);
> cl_mem_unmap_auto(mem);
> }
> }
> --
> 1.9.1
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list