[Beignet] [PATCH 2/2] Implement clGetMemObjectInfo
Zhigang Gong
zhigang.gong at linux.intel.com
Fri Apr 19 01:29:53 PDT 2013
LGTM. Pushed both patches. Thanks.
On Fri, Apr 19, 2013 at 08:12:59AM +0200, Simon Richter wrote:
>
> Currently, only the properties
>
> - CL_MEM_TYPE
> - CL_MEM_FLAGS
> - CL_MEM_SIZE
>
> are implemented.
>
> Signed-off-by: Simon Richter <Simon.Richter at hogyros.de>
> ---
> src/cl_api.c | 7 +++++--
> src/cl_mem.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> src/cl_mem.h | 3 +++
> 3 files changed, 68 insertions(+), 2 deletions(-)
>
> diff --git a/src/cl_api.c b/src/cl_api.c
> index c39ef83..2d84ace 100644
> --- a/src/cl_api.c
> +++ b/src/cl_api.c
> @@ -386,8 +386,11 @@ clGetMemObjectInfo(cl_mem memobj,
> void * param_value,
> size_t * param_value_size_ret)
> {
> - NOT_IMPLEMENTED;
> - return 0;
> + return cl_get_mem_object_info(memobj,
> + param_name,
> + param_value_size,
> + param_value,
> + param_value_size_ret);
> }
>
> cl_int
> diff --git a/src/cl_mem.c b/src/cl_mem.c
> index 126b927..14a79da 100644
> --- a/src/cl_mem.c
> +++ b/src/cl_mem.c
> @@ -31,6 +31,66 @@
> #include <assert.h>
> #include <stdio.h>
>
> +#define FIELD_SIZE(CASE,TYPE) \
> + case JOIN(CL_,CASE): \
> + if(param_value_size_ret) \
> + *param_value_size_ret = sizeof(TYPE); \
> + if(!param_value) \
> + return CL_SUCCESS; \
> + if(param_value_size < sizeof(TYPE)) \
> + return CL_INVALID_VALUE; \
> + break;
> +
> +LOCAL cl_int
> +cl_get_mem_object_info(cl_mem mem,
> + cl_mem_info param_name,
> + size_t param_value_size,
> + void *param_value,
> + size_t *param_value_size_ret)
> +{
> + switch(param_name)
> + {
> + FIELD_SIZE(MEM_TYPE, cl_mem_object_type);
> + FIELD_SIZE(MEM_FLAGS, cl_mem_flags);
> + FIELD_SIZE(MEM_SIZE, size_t);
> + FIELD_SIZE(MEM_HOST_PTR, void *);
> + FIELD_SIZE(MEM_MAP_COUNT, cl_uint);
> + FIELD_SIZE(MEM_REFERENCE_COUNT, cl_uint);
> + FIELD_SIZE(MEM_CONTEXT, cl_context);
> + default:
> + return CL_INVALID_VALUE;
> + }
> +
> + switch(param_name)
> + {
> + case CL_MEM_TYPE:
> + *((cl_mem_object_type *)param_value) = mem->type;
> + break;
> + case CL_MEM_FLAGS:
> + *((cl_mem_flags *)param_value) = mem->flags;
> + break;
> + case CL_MEM_SIZE:
> + *((size_t *)param_value) = cl_buffer_get_size(mem->bo);
> + break;
> + case CL_MEM_HOST_PTR:
> + NOT_IMPLEMENTED;
> + break;
> + case CL_MEM_MAP_COUNT:
> + NOT_IMPLEMENTED;
> + break;
> + case CL_MEM_REFERENCE_COUNT:
> + NOT_IMPLEMENTED;
> + break;
> + case CL_MEM_CONTEXT:
> + NOT_IMPLEMENTED;
> + break;
> + }
> +
> + return CL_SUCCESS;
> +}
> +
> +#undef FIELD_SIZE
> +
> static cl_mem
> cl_mem_allocate(cl_context ctx,
> cl_mem_flags flags,
> diff --git a/src/cl_mem.h b/src/cl_mem.h
> index 8e7a2dd..836deb4 100644
> --- a/src/cl_mem.h
> +++ b/src/cl_mem.h
> @@ -48,6 +48,9 @@ struct _cl_mem {
> cl_image_tiling_t tiling; /* only IVB+ supports TILE_[X,Y] (image only) */
> };
>
> +/* Query information about a memory object */
> +extern cl_int cl_get_mem_object_info(cl_mem, cl_mem_info, size_t, void *, size_t *);
> +
> /* Create a new memory object and initialize it with possible user data */
> extern cl_mem cl_mem_new(cl_context, cl_mem_flags, size_t, void*, cl_int*);
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list