[Beignet] [PATCH] check image from buffer's base address alignment.

Yang, Rong R rong.r.yang at intel.com
Tue Nov 24 19:28:51 PST 2015


Can you return relevant error code instead of assert?

> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> xionghu.luo at intel.com
> Sent: Monday, November 16, 2015 18:15
> To: beignet at lists.freedesktop.org
> Cc: Luo, Xionghu
> Subject: [Beignet] [PATCH] check image from buffer's base address
> alignment.
> 
> From: Luo Xionghu <xionghu.luo at intel.com>
> 
> per spec, if create image from USE_HOST_PTR buffer, the buffer's base
> address need be aligned.
> 
> Signed-off-by: Luo Xionghu <xionghu.luo at intel.com>
> ---
>  src/cl_mem.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/cl_mem.c b/src/cl_mem.c index 9a6bb83..96b9381 100644
> --- a/src/cl_mem.c
> +++ b/src/cl_mem.c
> @@ -327,6 +327,12 @@ cl_mem_allocate(enum cl_mem_type type,
>      }
> 
>      if(type == CL_MEM_IMAGE_TYPE && buffer != NULL) {
> +      // if create image from USE_HOST_PTR buffer, the buffer's base address
> need be aligned.
> +      if(buffer->is_userptr) {
> +        int base_alignement = 0;
> +        cl_get_device_info(ctx->device,
> CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT, sizeof(base_alignement),
> &base_alignement, NULL);
> +        assert(ALIGN((unsigned long)buffer->host_ptr, base_alignement) ==
> (unsigned long)buffer->host_ptr);
> +      }
>        // if the image if created from buffer, should use the bo directly to share
> same bo.
>        mem->bo = buffer->bo;
>        cl_mem_image(mem)->is_image_from_buffer = 1;
> --
> 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