From ad63a53e5f77eb2a09e0e72cbee60298d6ff4d02 Mon Sep 17 00:00:00 2001 From: "Yang, Rong R" Date: Thu, 20 Jul 2017 13:40:13 +0800 Subject: 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 Reviewed-by: Ruiling Song --- 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 798419aa..d58bf430 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]); } -- cgit v1.2.3