[Beignet] [PATCH] Delete useless event list in command queue struct.

Yang, Rong R rong.r.yang at intel.com
Mon Oct 10 13:12:16 UTC 2016


ccc

> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> junyan.he at inbox.com
> Sent: Friday, September 30, 2016 15:20
> To: beignet at lists.freedesktop.org
> Subject: [Beignet] [PATCH] Delete useless event list in command queue
> struct.
> 
> From: Junyan He <junyan.he at intel.com>
> 
> Signed-off-by: Junyan He <junyan.he at intel.com>
> ---
>  src/cl_command_queue.c | 73 +++-----------------------------------------------
>  src/cl_command_queue.h | 19 +++----------
>  2 files changed, 7 insertions(+), 85 deletions(-)
> 
> diff --git a/src/cl_command_queue.c b/src/cl_command_queue.c index
> a63efaf..7e7a854 100644
> --- a/src/cl_command_queue.c
> +++ b/src/cl_command_queue.c
> @@ -79,8 +79,9 @@ cl_command_queue_delete(cl_command_queue
> queue)
> 
>    cl_mem_delete(queue->perf);
>    cl_context_remove_queue(queue->ctx, queue);
> -  cl_free(queue->wait_events);
> -  cl_free(queue->barrier_events);
> +  if (queue->barrier_events) {
> +    cl_free(queue->barrier_events);
> +  }
>    CL_OBJECT_DESTROY_BASE(queue);
>    cl_free(queue);
>  }
> @@ -239,74 +240,6 @@ cl_command_queue_flush_gpgpu(cl_gpgpu gpgpu)
>    return CL_SUCCESS;
>  }
> 
> -#define DEFAULT_WAIT_EVENTS_SIZE  16
> -LOCAL void
> -cl_command_queue_insert_event(cl_command_queue queue, cl_event
> event) -{
> -  cl_int i=0;
> -  cl_event *new_list;
> -
> -  assert(queue != NULL);
> -  if(queue->wait_events == NULL) {
> -    queue->wait_events_size = DEFAULT_WAIT_EVENTS_SIZE;
> -    TRY_ALLOC_NO_ERR (queue->wait_events, CALLOC_ARRAY(cl_event,
> queue->wait_events_size));
> -  }
> -
> -  for(i=0; i<queue->wait_events_num; i++) {
> -    if(queue->wait_events[i] == event)
> -      return;   //is in the wait_events, need to insert
> -  }
> -
> -  if(queue->wait_events_num < queue->wait_events_size) {
> -    queue->wait_events[queue->wait_events_num++] = event;
> -    return;
> -  }
> -
> -  //wait_events_num == wait_events_size, array is full
> -  queue->wait_events_size *= 2;
> -  TRY_ALLOC_NO_ERR (new_list, CALLOC_ARRAY(cl_event, queue-
> >wait_events_size));
> -  memcpy(new_list, queue->wait_events, sizeof(cl_event)*queue-
> >wait_events_num);
> -  cl_free(queue->wait_events);
> -  queue->wait_events = new_list;
> -  queue->wait_events[queue->wait_events_num++] = event;
> -  return;
> -
> -exit:
> -  return;
> -error:
> -  if(queue->wait_events)
> -    cl_free(queue->wait_events);
> -  queue->wait_events = NULL;
> -  queue->wait_events_size = 0;
> -  queue->wait_events_num = 0;
> -  goto exit;
> -
> -}
> -
> -LOCAL void
> -cl_command_queue_remove_event(cl_command_queue queue, cl_event
> event) -{
> -  cl_int i=0;
> -
> -  assert(queue->wait_events);
> -  for(i=0; i<queue->wait_events_num; i++) {
> -    if(queue->wait_events[i] == event)
> -      break;
> -  }
> -
> -  if(i == queue->wait_events_num)
> -    return;
> -
> -  if(i == queue->wait_events_num - 1) {
> -    queue->wait_events[i] = NULL;
> -  } else {
> -    for(; i<queue->wait_events_num-1; i++) {
> -      queue->wait_events[i] = queue->wait_events[i+1];
> -    }
> -  }
> -  queue->wait_events_num -= 1;
> -}
> -
>  LOCAL void
>  cl_command_queue_insert_barrier_event(cl_command_queue queue,
> cl_event event)  { diff --git a/src/cl_command_queue.h
> b/src/cl_command_queue.h index 7a8afbf..54a24f7 100644
> --- a/src/cl_command_queue.h
> +++ b/src/cl_command_queue.h
> @@ -44,13 +44,10 @@ struct _cl_command_queue {
>    _cl_base_object base;
>    _cl_command_queue_enqueue_worker worker;
>    cl_context ctx;                      /* Its parent context */
> -  cl_event* barrier_events;               /* Point to array of non-complete user
> events that block this command queue */
> -  cl_int    barrier_events_num;           /* Number of Non-complete user
> events */
> -  cl_int    barrier_events_size;          /* The size of array that wait_events point
> to */
> -  cl_event* wait_events;               /* Point to array of non-complete user
> events that block this command queue */
> -  cl_int    wait_events_num;           /* Number of Non-complete user events
> */
> -  cl_int    wait_events_size;          /* The size of array that wait_events point
> to */
> -  cl_command_queue_properties  props;  /* Queue properties */
> +  cl_event* barrier_events;            /* Point to array of non-complete user
> events that block this command queue */
> +  cl_int barrier_events_num;           /* Number of Non-complete user events
> */
> +  cl_int barrier_events_size;          /* The size of array that wait_events point
> to */
> +  cl_command_queue_properties props;   /* Queue properties */
>    cl_mem perf;                         /* Where to put the perf counters */
> 
>    void* cmrt_event;                    /* the latest CmEvent* of the command queue
> */
> @@ -93,16 +90,8 @@ extern cl_int
> cl_command_queue_bind_surface(cl_command_queue, cl_kernel, cl_gpgp
>  /* Bind all the image surfaces in the GPGPU state */  extern cl_int
> cl_command_queue_bind_image(cl_command_queue, cl_kernel, cl_gpgpu);
> 
> -/* Insert a user event to command's wait_events */ -extern void
> cl_command_queue_insert_event(cl_command_queue, cl_event);
> -
> -/* Remove a user event from command's wait_events */ -extern void
> cl_command_queue_remove_event(cl_command_queue, cl_event);
> -
>  extern void cl_command_queue_insert_barrier_event(cl_command_queue
> queue, cl_event event);
> -
>  extern void
> cl_command_queue_remove_barrier_event(cl_command_queue queue,
> cl_event event);
> -
>  extern void cl_command_queue_notify(cl_command_queue queue);
> extern void cl_command_queue_enqueue_event(cl_command_queue
> queue, cl_event event);  extern cl_int
> cl_command_queue_init_enqueue(cl_command_queue queue);
> --
> 2.7.4
> 
> 
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list