[Beignet] [PATCH] do not call memcpy for cl_enqueue_read_buffer if userptr is enabled
Guo Yejun
yejun.guo at intel.com
Sun Jan 3 17:45:18 PST 2016
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
More information about the Beignet
mailing list