[Beignet] [PATCH] Runtime: fix the context ref is not 0 assert when delete.
Song, Ruiling
ruiling.song at intel.com
Thu Jul 27 03:15:58 UTC 2017
LGTM
Ruiling
> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> Yang Rong
> Sent: Thursday, July 20, 2017 1:40 PM
> To: beignet at lists.freedesktop.org
> Cc: Yang, Rong R <rong.r.yang at intel.com>
> Subject: [Beignet] [PATCH] Runtime: fix the context ref is not 0 assert when
> delete.
>
> The CL_ENQUEUE_FILL_BUFFER_ALIGN8_* internal program is the same
> program, only add the program's ref once, but when delete context,
> caculate the internal program count, will add them individually.
> This mismatch will cause the context be free by mistake.
> New different CL_ENQUEUE_FILL_BUFFER_ALIGN8_* program for clearly.
>
> Signed-off-by: Yang Rong <rong.r.yang at intel.com>
> ---
> src/cl_context.c | 30 ++++++++----------------------
> 1 file changed, 8 insertions(+), 22 deletions(-)
>
> diff --git a/src/cl_context.c b/src/cl_context.c
> index 798419a..d58bf43 100644
> --- a/src/cl_context.c
> +++ b/src/cl_context.c
> @@ -445,32 +445,18 @@ cl_context_get_static_kernel_from_bin(cl_context
> ctx, cl_int index,
>
> ctx->internal_prgs[index]->is_built = 1;
>
> - /* All CL_ENQUEUE_FILL_BUFFER_ALIGN16_xxx use the same program,
> different kernel. */
> - if (index >= CL_ENQUEUE_FILL_BUFFER_ALIGN8_8 && index <=
> CL_ENQUEUE_FILL_BUFFER_ALIGN8_64) {
> - int i = CL_ENQUEUE_FILL_BUFFER_ALIGN8_8;
> - for (; i <= CL_ENQUEUE_FILL_BUFFER_ALIGN8_64; i++) {
> - if (index != i) {
> - assert(ctx->internal_prgs[i] == NULL);
> - assert(ctx->internal_kernels[i] == NULL);
> - cl_program_add_ref(ctx->internal_prgs[index]);
> - ctx->internal_prgs[i] = ctx->internal_prgs[index];
> - }
> -
> - if (i == CL_ENQUEUE_FILL_BUFFER_ALIGN8_8) {
> - ctx->internal_kernels[i] = cl_program_create_kernel(ctx-
> >internal_prgs[index],
> + if (index == CL_ENQUEUE_FILL_BUFFER_ALIGN8_8) {
> + ctx->internal_kernels[index] = cl_program_create_kernel(ctx-
> >internal_prgs[index],
> "__cl_fill_region_align8_2", NULL);
> - } else if (i == CL_ENQUEUE_FILL_BUFFER_ALIGN8_16) {
> - ctx->internal_kernels[i] = cl_program_create_kernel(ctx-
> >internal_prgs[index],
> + } else if (index == CL_ENQUEUE_FILL_BUFFER_ALIGN8_16) {
> + ctx->internal_kernels[index] = cl_program_create_kernel(ctx-
> >internal_prgs[index],
> "__cl_fill_region_align8_4", NULL);
> - } else if (i == CL_ENQUEUE_FILL_BUFFER_ALIGN8_32) {
> - ctx->internal_kernels[i] = cl_program_create_kernel(ctx-
> >internal_prgs[index],
> + } else if (index == CL_ENQUEUE_FILL_BUFFER_ALIGN8_32) {
> + ctx->internal_kernels[index] = cl_program_create_kernel(ctx-
> >internal_prgs[index],
> "__cl_fill_region_align8_8", NULL);
> - } else if (i == CL_ENQUEUE_FILL_BUFFER_ALIGN8_64) {
> - ctx->internal_kernels[i] = cl_program_create_kernel(ctx-
> >internal_prgs[index],
> + } else if (index == CL_ENQUEUE_FILL_BUFFER_ALIGN8_64) {
> + ctx->internal_kernels[index] = cl_program_create_kernel(ctx-
> >internal_prgs[index],
> "__cl_fill_region_align8_16", NULL);
> - } else
> - assert(0);
> - }
> } else {
> ctx->internal_kernels[index] = cl_kernel_dup(ctx->internal_prgs[index]-
> >ker[0]);
> }
> --
> 2.1.4
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list