summaryrefslogtreecommitdiff
path: root/src/cl_event.h
diff options
context:
space:
mode:
authorDavid Couturier <david.couturier@polymtl.ca>2015-03-24 13:22:12 -0400
committerZhigang Gong <zhigang.gong@intel.com>2015-03-27 16:55:36 +0800
commit89bc7657d55a18baf4cb743eb4d659edb2475fc1 (patch)
tree83e3ed2b28ec8d82c1f829a5143133e738c54887 /src/cl_event.h
parent2b755aa1292f58b65636f8eafc9a1b9ed20321ad (diff)
downloadbeignet-89bc7657d55a18baf4cb743eb4d659edb2475fc1.tar.gz
Fix: (v3) Event callback that were not executed when command was already CL_COMPLETE + thread safety for callbacks
When trying to register a callback on the clEnqueueReadBuffer command, since it is processed synchroniously all the time, the command was marked CL_COMPLETE every time. If the event returned by clEnqueueReadBuffer was then used to register a callback function, the callback function did no check to execute it if nessary. Modified the handling of the callback registration in cl_set_event_callback to only call the callback being created if it's status is already reached. Added thread safety measures for pfn_notify calls since the status value can be changed while executing the callback. Grouped the pfn_notify calls to a unified function cl_event_call_callback that handles thread safety: it queues callbacks in a node list while under the protection of pthread_mutex and then calls the callbacks outside of the pthread_mutex (this is required because the callback can deadlock if it calls a cl_api function that uses the mutex) Signed-off-by: David Couturier <david.couturier@polymtl.ca> Reviewed-by: "Yang, Rong R" <rong.r.yang@intel.com>
Diffstat (limited to 'src/cl_event.h')
-rw-r--r--src/cl_event.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/cl_event.h b/src/cl_event.h
index 07305306..9bb2ac87 100644
--- a/src/cl_event.h
+++ b/src/cl_event.h
@@ -78,8 +78,10 @@ cl_event cl_event_new(cl_context, cl_command_queue, cl_command_type, cl_bool);
void cl_event_delete(cl_event);
/* Add one more reference to this object */
void cl_event_add_ref(cl_event);
-/* Rigister a user callback function for specific commond execution status */
+/* Register a user callback function for specific commond execution status */
cl_int cl_event_set_callback(cl_event, cl_int, EVENT_NOTIFY, void *);
+/* Execute the event's callback if the event's status supersedes the callback's status. Free the callback if specified */
+void cl_event_call_callback(cl_event event, cl_int status, cl_bool free_cb);
/* Check events wait list for enqueue commonds */
cl_int cl_event_check_waitlist(cl_uint, const cl_event *, cl_event *, cl_context);
/* Wait the all events in wait list complete */