diff options
author | Junyan He <junyan.he@intel.com> | 2017-01-05 20:53:56 +0800 |
---|---|---|
committer | Yang Rong <rong.r.yang@intel.com> | 2017-01-06 17:33:12 +0800 |
commit | 06d2f24d19875432261492688c8c17281a5b3514 (patch) | |
tree | e3cbaa91022f15a7478c7524d700bc367da47be5 /src/cl_context.c | |
parent | 1396a0eb5a60bbd048b30165b2ed8a7f54968381 (diff) | |
download | beignet-06d2f24d19875432261492688c8c17281a5b3514.tar.gz |
Fix a event notify bug.
When a event complete, we need to notify all the command_queue
within the same context. But sometime, some command_queue in
the context is already invalid.
Modify to ensure all the command_queue to be notified are
valid.
Signed-off-by: Junyan He <junyan.he@intel.com>
Reviewed-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'src/cl_context.c')
-rw-r--r-- | src/cl_context.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/cl_context.c b/src/cl_context.c index 65e79098..3f2e7578 100644 --- a/src/cl_context.c +++ b/src/cl_context.c @@ -46,9 +46,11 @@ cl_context_add_queue(cl_context ctx, cl_command_queue queue) { cl_context_add_ref(ctx); CL_OBJECT_LOCK(ctx); + while (ctx->queue_modify_disable) { + CL_OBJECT_WAIT_ON_COND(ctx); + } list_add_tail(&ctx->queues, &queue->base.node); ctx->queue_num++; - ctx->queue_cookie++; CL_OBJECT_UNLOCK(ctx); queue->ctx = ctx; @@ -57,10 +59,13 @@ cl_context_add_queue(cl_context ctx, cl_command_queue queue) { LOCAL void cl_context_remove_queue(cl_context ctx, cl_command_queue queue) { assert(queue->ctx == ctx); + CL_OBJECT_LOCK(ctx); + while (ctx->queue_modify_disable) { + CL_OBJECT_WAIT_ON_COND(ctx); + } list_node_del(&queue->base.node); ctx->queue_num--; - ctx->queue_cookie++; CL_OBJECT_UNLOCK(ctx); cl_context_delete(ctx); @@ -333,7 +338,7 @@ cl_context_new(struct _cl_context_prop *props, cl_uint dev_num, cl_device_id* al list_init(&ctx->samplers); list_init(&ctx->events); list_init(&ctx->programs); - ctx->queue_cookie = 1; + ctx->queue_modify_disable = CL_FALSE; TRY_ALLOC_NO_ERR (ctx->drv, cl_driver_new(props)); ctx->props = *props; ctx->ver = cl_driver_get_ver(ctx->drv); |