[Beignet] [PATCH V2 1/3] support CL_MEM_USE_HOST_PTR with userptr for cl buffer

Zhenyu Wang zhenyuw at linux.intel.com
Thu Nov 6 21:46:01 PST 2014


Overall looks fine to me except some indent issues and better
keep with /* */ comment style in C files.

On 2014.11.06 09:40:05 +0800, Guo Yejun wrote:
> +
> +#ifdef HAS_USERPTR
> +    //currently only cl buf is supported, will add cl image support later
> +    if ((flags & CL_MEM_USE_HOST_PTR) && host_ptr != NULL) {
> +        if (!is_tiled) {    //userptr not support tiling
> +            int page_size = getpagesize();
> +            if ((((unsigned long)host_ptr | sz) & (page_size - 1)) == 0) {  //page aligned
> +              mem->bo = cl_buffer_alloc_userptr(bufmgr, "CL memory object", host_ptr, sz, 0);
> +              if (mem->bo != NULL)
> +                mem->is_userptr = 1;
> +              else
> +                fprintf(stderr, "failed to alloc with host ptr %p %lu, fallback\n", host_ptr, sz);
> +            }
> +        }
> +    }

comment style here, and remove above debug log.

> @@ -690,6 +690,19 @@ cl_buffer intel_share_image_from_libva(cl_context ctx,
>    return (cl_buffer)intel_bo;
>  }
>  
> +static cl_buffer intel_buffer_alloc_userptr(cl_buffer_mgr bufmgr, const char* name, void *data,size_t size, unsigned long flags)
> +{
> +#ifdef HAS_USERPTR
> +  drm_intel_bo *bo;
> +  bo = drm_intel_bo_alloc_userptr((drm_intel_bufmgr *)bufmgr, name, data, I915_TILING_NONE, 0, size, flags);
> +  if (bo == NULL)  //Fallback to unsynchronized userptr allocation if kernel has no MMU notifier enabled.
> +    bo = drm_intel_bo_alloc_userptr((drm_intel_bufmgr *)bufmgr, name, data, I915_TILING_NONE, 0, size, flags | I915_USERPTR_UNSYNCHRONIZED);
> +  return (cl_buffer)bo;
> +#else
> +  return NULL;
> +#endif
> +}

indent and comment style.

-- 
Open Source Technology Center, Intel ltd.

$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/beignet/attachments/20141107/01b7790d/attachment.sig>


More information about the Beignet mailing list