[3/3] Runtime: remove ctx's useless fileds.

Submitted by Yang, Rong R on June 20, 2017, 11:07 a.m.

Details

Message ID 1497956867-27364-3-git-send-email-rong.r.yang@intel.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Beignet

Not browsing as part of any series.

Commit Message

Yang, Rong R June 20, 2017, 11:07 a.m.
built_in_prgs and built_in_kernels seems useless, remove them.

Signed-off-by: Yang Rong <rong.r.yang@intel.com>
---
 src/cl_context.c |  6 ------
 src/cl_context.h |  2 --
 src/cl_program.c | 40 +++++-----------------------------------
 3 files changed, 5 insertions(+), 43 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/cl_context.c b/src/cl_context.c
index f3dd421..798419a 100644
--- a/src/cl_context.c
+++ b/src/cl_context.c
@@ -396,12 +396,6 @@  cl_context_delete(cl_context ctx)
       ctx->internal_prgs[i] = NULL;
       cl_program_delete(p);
     }
-
-    if (ctx->built_in_kernels[i]) {
-      cl_kernel k = ctx->built_in_kernels[i];
-      ctx->built_in_kernels[i] = NULL;
-      cl_kernel_delete(k);
-    }
   }
 
   CL_OBJECT_DEC_REF(ctx);
diff --git a/src/cl_context.h b/src/cl_context.h
index 3a2e13b..36db04f 100644
--- a/src/cl_context.h
+++ b/src/cl_context.h
@@ -126,8 +126,6 @@  struct _cl_context {
                                     /* All programs internal used, for example clEnqueuexxx api use */
   cl_kernel  internal_kernels[CL_INTERNAL_KERNEL_MAX];
                                     /* All kernels  for clenqueuexxx api, for example clEnqueuexxx api use */
-  cl_program built_in_prgs;  /*all built-in kernels belongs to this program only*/
-  cl_kernel  built_in_kernels[CL_INTERNAL_KERNEL_MAX];
   uint32_t ver;                     /* Gen version */
   struct _cl_context_prop props;
   cl_context_properties * prop_user; /* a copy of user passed context properties when create context */
diff --git a/src/cl_program.c b/src/cl_program.c
index bb96d98..3ae0486 100644
--- a/src/cl_program.c
+++ b/src/cl_program.c
@@ -382,54 +382,24 @@  cl_program_create_with_built_in_kernles(cl_context     ctx,
   extern size_t cl_internal_built_in_kernel_str_size;
   char* p_built_in_kernel_str =cl_internal_built_in_kernel_str;
 
-  ctx->built_in_prgs = cl_program_create_from_binary(ctx, 1,
+  cl_program built_in_prgs = cl_program_create_from_binary(ctx, 1,
                                                           &ctx->devices[0],
                                                           (size_t*)&cl_internal_built_in_kernel_str_size,
                                                           (const unsigned char **)&p_built_in_kernel_str,
                                                           &binary_status, &err);
-  if (!ctx->built_in_prgs)
+  if (!built_in_prgs)
     return NULL;
 
-  err = cl_program_build(ctx->built_in_prgs, NULL);
+  err = cl_program_build(built_in_prgs, NULL);
   if (err != CL_SUCCESS)
     return NULL;
 
-  ctx->built_in_prgs->is_built = 1;
-
-  char delims[] = ";";
-  char* saveptr = NULL;
-  char* local_kernel_names;
-  char* kernel = NULL;
-  char* matched_kernel;
-  int i = 0;
-
-  //copy the content to local_kernel_names to protect the kernel_names.
-  TRY_ALLOC(local_kernel_names, cl_calloc(strlen(kernel_names)+1, sizeof(char) ) );
-  memcpy(local_kernel_names, kernel_names, strlen(kernel_names)+1);
-
-  kernel = strtok_r( local_kernel_names, delims , &saveptr);
-  while( kernel != NULL ) {
-    matched_kernel = strstr(ctx->devices[0]->built_in_kernels, kernel);
-    if(matched_kernel){
-      for (i = 0; i < ctx->built_in_prgs->ker_n; ++i) {
-        assert(ctx->built_in_prgs->ker[i]);
-        const char *ker_name = cl_kernel_get_name(ctx->built_in_prgs->ker[i]);
-        if (ker_name != NULL && strcmp(ker_name, kernel) == 0) {
-          break;
-        }
-      }
-
-      ctx->built_in_kernels[i] = cl_program_create_kernel(ctx->built_in_prgs, kernel, NULL);
-    }
-    kernel = strtok_r((char*)saveptr , delims, &saveptr );
-  }
-
-  cl_free(local_kernel_names);
+  built_in_prgs->is_built = 1;
 
 exit:
   if (errcode_ret)
     *errcode_ret = err;
-  return ctx->built_in_prgs;
+  return built_in_prgs;
 error:
   goto exit;