One comment. Thanks find and fix it. > -----Original Message----- > From: Beignet [mailto:[email protected]] On Behalf Of > David Couturier > Sent: Friday, March 20, 2015 08:20 > To: Zou, Nanhai > Cc: [email protected] > Subject: [Beignet] [PATCH] Fix: Event callback that not executed when > command already marked CL_COMPLETE > > 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. > > Fixed by adding a check at the end of the cl_event_set_callback function. > > All tests passed. > > Signed-off-by: David Couturier <[email protected]> > --- > src/cl_event.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/src/cl_event.c b/src/cl_event.c index f70e531..df4a5a5 100644 > --- a/src/cl_event.c > +++ b/src/cl_event.c > @@ -183,6 +183,21 @@ cl_int cl_event_set_callback(cl_event event , > cb->next = event->user_cb; > event->user_cb = cb; > > + // It is possible that the event enqueued is already completed. > + // clEnqueueReadBuffer can be synchronious and when the callback // > + is registered after, it still needs to get executed. > + if(event->status == CL_COMPLETE) { > + /* Call user callback */ > + user_callback *user_cb = event->user_cb; > + while(user_cb) { > + if(user_cb->status >= CL_COMPLETE) { > + user_cb->executed = CL_TRUE; > + user_cb->pfn_notify(event, event->status, > user_cb->user_data); > + } > + user_cb = user_cb->next; > + }
I think only the current callback should be called. Assume the scenario: clEnqueueReadBuffer(......,ev); clSetEventCallback(ev, CL_SUBMITTED, ...); clSetEventCallback(ev, CL_COMPLETE, ....); In the second clSetEventCallback, the first callback have been executed, only need execute the second callback. So need execute current callback when the event's status <= command_exec_callback_type. > + } > + > exit: > return err; > error: > -- > 1.9.1 > _______________________________________________ > Beignet mailing list > [email protected] > http://lists.freedesktop.org/mailman/listinfo/beignet _______________________________________________ Beignet mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/beignet
