[Beignet] [PATCH V2] Implement api clCreateKernelsInProgram.
Zhigang Gong
zhigang.gong at linux.intel.com
Wed Oct 9 22:26:53 PDT 2013
LGTM, thanks.
On Thu, Oct 10, 2013 at 11:44:27AM +0800, Yang Rong wrote:
>
> Signed-off-by: Yang Rong <rong.r.yang at intel.com>
> ---
> src/cl_api.c | 22 ++++++++++++++++++++--
> src/cl_program.c | 22 ++++++++++++++++++++++
> src/cl_program.h | 3 +++
> 3 files changed, 45 insertions(+), 2 deletions(-)
>
> diff --git a/src/cl_api.c b/src/cl_api.c
> index 4b3f6e2..6036a93 100644
> --- a/src/cl_api.c
> +++ b/src/cl_api.c
> @@ -981,8 +981,26 @@ clCreateKernelsInProgram(cl_program program,
> cl_kernel * kernels,
> cl_uint * num_kernels_ret)
> {
> - NOT_IMPLEMENTED;
> - return 0;
> + cl_int err = CL_SUCCESS;
> +
> + CHECK_PROGRAM (program);
> + if (program->is_built == CL_FALSE) {
> + err = CL_INVALID_PROGRAM_EXECUTABLE;
> + goto error;
> + }
> + if (kernels && num_kernels < program->ker_n) {
> + err = CL_INVALID_VALUE;
> + goto error;
> + }
> +
> + if(num_kernels_ret)
> + *num_kernels_ret = program->ker_n;
> +
> + if(kernels)
> + err = cl_program_create_kernels_in_program(program, kernels);
> +
> +error:
> + return err;
> }
>
> cl_int
> diff --git a/src/cl_program.c b/src/cl_program.c
> index a0e0104..d5f19da 100644
> --- a/src/cl_program.c
> +++ b/src/cl_program.c
> @@ -386,3 +386,25 @@ error:
> goto exit;
> }
>
> +LOCAL cl_int
> +cl_program_create_kernels_in_program(cl_program p, cl_kernel* ker)
> +{
> + int i = 0;
> +
> + if(ker == NULL)
> + return CL_SUCCESS;
> +
> + for (i = 0; i < p->ker_n; ++i) {
> + TRY_ALLOC_NO_ERR(ker[i], cl_kernel_dup(p->ker[i]));
> + }
> +
> + return CL_SUCCESS;
> +
> +error:
> + do {
> + cl_kernel_delete(ker[i]);
> + ker[i--] = NULL;
> + } while(i > 0);
> +
> + return CL_OUT_OF_HOST_MEMORY;
> +}
> diff --git a/src/cl_program.h b/src/cl_program.h
> index de82fd5..2cb547a 100644
> --- a/src/cl_program.h
> +++ b/src/cl_program.h
> @@ -68,6 +68,9 @@ extern void cl_program_add_ref(cl_program);
> /* Create a kernel for the OCL user */
> extern cl_kernel cl_program_create_kernel(cl_program, const char*, cl_int*);
>
> +/* creates kernel objects for all kernel functions in program. */
> +extern cl_int cl_program_create_kernels_in_program(cl_program, cl_kernel*);
> +
> /* Create a program from OCL source */
> extern cl_program
> cl_program_create_from_source(cl_context ctx,
> --
> 1.8.1.2
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list