[Beignet] [PATCH] Fix two bugs about command queue destroy.

junyan.he at inbox.com junyan.he at inbox.com
Wed Jan 11 08:36:20 UTC 2017


From: Junyan He <junyan.he at intel.com>

1. Call finish before we destroy the command queue.
   We should make sure all the commands in the queue are
   finished before we really destroy the command_queue.
   If not, may cause event status error. We leave the queue's
   life time to user and do not ref the queue when create
   event.
2. Loose the assert condition when notify queue.
   We have the case when ref of the queue is 0 but still need
   to notify.

Signed-off-by: Junyan He <junyan.he at intel.com>
---
 src/cl_command_queue.c         | 3 +++
 src/cl_command_queue_enqueue.c | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/cl_command_queue.c b/src/cl_command_queue.c
index aa371d0..b855ff6 100644
--- a/src/cl_command_queue.c
+++ b/src/cl_command_queue.c
@@ -81,6 +81,9 @@ cl_command_queue_delete(cl_command_queue queue)
   if (CL_OBJECT_DEC_REF(queue) > 1)
     return;
 
+  /* Before we destroy the queue, we should make sure all
+     the commands in the queue are finished. */
+  cl_command_queue_wait_finish(queue);
   cl_context_remove_queue(queue->ctx, queue);
 
   cl_command_queue_destroy_enqueue(queue);
diff --git a/src/cl_command_queue_enqueue.c b/src/cl_command_queue_enqueue.c
index 91fabf9..44a0761 100644
--- a/src/cl_command_queue_enqueue.c
+++ b/src/cl_command_queue_enqueue.c
@@ -122,7 +122,7 @@ cl_command_queue_notify(cl_command_queue queue)
     return;
   }
 
-  assert(CL_OBJECT_IS_COMMAND_QUEUE(queue));
+  assert(queue && (((cl_base_object)queue)->magic == CL_OBJECT_COMMAND_QUEUE_MAGIC));
   CL_OBJECT_LOCK(queue);
   queue->worker.cookie++;
   CL_OBJECT_NOTIFY_COND(queue);
-- 
2.7.4



More information about the Beignet mailing list