[Beignet] [PATCH] Runtime: fix the context ref is not 0 assert when delete.

Yang Rong rong.r.yang at intel.com
Thu Jul 20 05:40:13 UTC 2017


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



More information about the Beignet mailing list