runtime: fix some subtle event bugs.
authorZhigang Gong <zhigang.gong@intel.com>
Thu, 10 Jul 2014 10:57:53 +0000 (18:57 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Fri, 11 Jul 2014 10:25:25 +0000 (18:25 +0800)
commit5bb03032ec59ffe8d2055107e2ffb96b97e40c55
treed6739b97bd4bea8ef1590a6dcfc8723070aed265
parentcb8285a8be3dcb4aca7e896f2c45715f30f8aee6
runtime: fix some subtle event bugs.

This patch fix the following two bugs in event handling.
1. When it's time to call a event's user call back function, we need to
   set the executed to true before the call. As that call back function
   may call into clReleaseEvent(), and if we don't set the executed status
   to true, it will enter infinite recursive loop.

2. After the user call clEnqueueNDRangeKernel to get a valid event, the
   user set a call back function to that event, and in that call back
   function, it will release that event. This scenario is totally correct.
   But our current event handling doesn't have a deadicated timer thread to
   update those on-the-fly events' status. Thus those events will not have
   a chance to get updated, and those call back function will not executed
   forever. To introduce a complete timer style thread to maintain this type
   of events is too heavy for this fix release. This patch choose an easy
   way to work around it. It will make sure the last gpgpu event to be finished
   before current task to be enqueued.

After this patch, most of the OpenCV 3.0 cases could run smoothly without
any serious issue.

Signed-off-by: Zhigang Gong <zhigang.gong@intel.com>
Reviewed-by: Yang Rong <rong.r.yang@intel.com>
src/cl_api.c
src/cl_command_queue.c
src/cl_event.c
src/cl_event.h