summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYang Rong <rong.r.yang@intel.com>2014-11-21 14:57:27 +0800
committerZhigang Gong <zhigang.gong@intel.com>2014-11-21 15:57:00 +0800
commit9c18f055d6cfbf3fac298194a636ae6767e737e0 (patch)
tree32e25c58b3c9a4417593aedb112cc448374dc90e /src
parent34a91f258aa0e0a8004a1019647efa245b28fc5e (diff)
Fix the opencv_test_core/OCL_Arithm random segment fault.
If call cl_event_delete before call back, then event will be deleted if application release event in the call back. So must move the cl_event_delete at the last. V2: V1 will not delete event if not user event, also need delete it. Signed-off-by: Yang Rong <rong.r.yang@intel.com> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/cl_event.c73
1 files changed, 36 insertions, 37 deletions
diff --git a/src/cl_event.c b/src/cl_event.c
index e20342ad..f70e5318 100644
--- a/src/cl_event.c
+++ b/src/cl_event.c
@@ -436,9 +436,6 @@ void cl_event_set_status(cl_event event, cl_int status)
event->status = status;
pthread_mutex_unlock(&event->ctx->event_lock);
- if(event->status <= CL_COMPLETE)
- cl_event_delete(event);
-
/* Call user callback */
user_cb = event->user_cb;
while(user_cb) {
@@ -449,46 +446,48 @@ void cl_event_set_status(cl_event event, cl_int status)
user_cb = user_cb->next;
}
- if(event->type != CL_COMMAND_USER)
- return;
+ if(event->type == CL_COMMAND_USER) {
+ /* Check all defer enqueue */
+ enqueue_callback *cb, *enqueue_cb = event->waits_head;
+ while(enqueue_cb) {
+ /* Remove this user event in enqueue_cb, update the header if needed. */
+ cl_event_remove_user_event(&enqueue_cb->wait_user_events, event);
+ cl_event_delete(event);
+
+ /* Still wait on other user events */
+ if(enqueue_cb->wait_user_events != NULL) {
+ enqueue_cb = enqueue_cb->next;
+ continue;
+ }
- /* Check all defer enqueue */
- enqueue_callback *cb, *enqueue_cb = event->waits_head;
- while(enqueue_cb) {
- /* Remove this user event in enqueue_cb, update the header if needed. */
- cl_event_remove_user_event(&enqueue_cb->wait_user_events, event);
- cl_event_delete(event);
+ //remove user event frome enqueue_cb's ctx
+ cl_command_queue_remove_event(enqueue_cb->event->queue, event);
+ cl_command_queue_remove_barrier_event(enqueue_cb->event->queue, event);
- /* Still wait on other user events */
- if(enqueue_cb->wait_user_events != NULL) {
+ /* All user events complete, now wait enqueue events */
+ ret = cl_event_wait_events(enqueue_cb->num_events, enqueue_cb->wait_list,
+ enqueue_cb->event->queue);
+ assert(ret != CL_ENQUEUE_EXECUTE_DEFER);
+ ret = ~ret;
+ cb = enqueue_cb;
enqueue_cb = enqueue_cb->next;
- continue;
- }
- //remove user event frome enqueue_cb's ctx
- cl_command_queue_remove_event(enqueue_cb->event->queue, event);
- cl_command_queue_remove_barrier_event(enqueue_cb->event->queue, event);
-
- /* All user events complete, now wait enqueue events */
- ret = cl_event_wait_events(enqueue_cb->num_events, enqueue_cb->wait_list,
- enqueue_cb->event->queue);
- assert(ret != CL_ENQUEUE_EXECUTE_DEFER);
- ret = ~ret;
- cb = enqueue_cb;
- enqueue_cb = enqueue_cb->next;
-
- /* Call the pending operation */
- evt = cb->event;
- /* TODO: if this event wait on several events, one event's
- status is error, the others is complete, what's the status
- of this event? Can't find the description in OpenCL spec.
- Simply update to latest finish wait event.*/
- cl_event_set_status(cb->event, status);
- if(evt->emplict == CL_FALSE) {
- cl_event_delete(evt);
+ /* Call the pending operation */
+ evt = cb->event;
+ /* TODO: if this event wait on several events, one event's
+ status is error, the others is complete, what's the status
+ of this event? Can't find the description in OpenCL spec.
+ Simply update to latest finish wait event.*/
+ cl_event_set_status(cb->event, status);
+ if(evt->emplict == CL_FALSE) {
+ cl_event_delete(evt);
+ }
}
+ event->waits_head = NULL;
}
- event->waits_head = NULL;
+
+ if(event->status <= CL_COMPLETE)
+ cl_event_delete(event);
}
void cl_event_update_status(cl_event event, int wait)