@@ -364,8 +364,20 @@ pocl_create_event_sync (cl_event notifier_event, cl_event waiting_event)
364
364
}
365
365
}
366
366
367
- if (notifier_event -> status == CL_COMPLETE )
368
- goto FINISH ;
367
+ /* If the notifier event is already complete (or failed),
368
+ don't create an event sync. This is fine since if the wait
369
+ event has no notifier events and gets submitted, it can start
370
+ right away.
371
+ */
372
+ if (notifier_event -> status < 0 || notifier_event -> status == CL_COMPLETE )
373
+ {
374
+ POCL_MSG_PRINT_EVENTS (
375
+ "notifier event %" PRIu64
376
+ " already complete, not creating sync with event %" PRIu64 "\n" ,
377
+ notifier_event -> id , waiting_event -> id );
378
+ goto FINISH ;
379
+ }
380
+
369
381
notify_target = pocl_mem_manager_new_event_node ();
370
382
wait_list_item = pocl_mem_manager_new_event_node ();
371
383
if (!notify_target || !wait_list_item )
@@ -377,6 +389,11 @@ pocl_create_event_sync (cl_event notifier_event, cl_event waiting_event)
377
389
378
390
notify_target -> event = waiting_event ;
379
391
wait_list_item -> event = notifier_event ;
392
+ /* Retain the waiting_event since we hold a reference to it in the notify
393
+ list. This is not needed for the wait_list since the only purpose is to
394
+ keep a count of the number of events it's waiting on.
395
+ */
396
+ POCL_RETAIN_OBJECT_UNLOCKED (waiting_event );
380
397
LL_PREPEND (notifier_event -> notify_list , notify_target );
381
398
LL_PREPEND (waiting_event -> wait_list , wait_list_item );
382
399
@@ -1980,14 +1997,14 @@ pocl_update_event_finished (cl_int status, const char *func, unsigned line,
1980
1997
{
1981
1998
assert (event != NULL );
1982
1999
assert (event -> queue != NULL );
1983
- assert (event -> status > CL_COMPLETE );
1984
2000
int notify_cmdq = CL_FALSE ;
1985
2001
cl_command_buffer_khr command_buffer = NULL ;
1986
2002
_cl_command_node * node = NULL ;
1987
2003
1988
2004
cl_command_queue cq = event -> queue ;
1989
2005
POCL_LOCK_OBJ (cq );
1990
2006
POCL_LOCK_OBJ (event );
2007
+ assert (event -> status > CL_COMPLETE );
1991
2008
if ((cq -> properties & CL_QUEUE_PROFILING_ENABLE )
1992
2009
&& (cq -> device -> has_own_timer == 0 ))
1993
2010
event -> time_end = pocl_gettimemono_ns ();
@@ -2064,45 +2081,6 @@ pocl_update_event_finished (cl_int status, const char *func, unsigned line,
2064
2081
2065
2082
ops -> broadcast (event );
2066
2083
2067
- #ifdef ENABLE_REMOTE_CLIENT
2068
- /* With remote being asynchronous it is possible that an event completion
2069
- * signal is received before some of its dependencies. Therefore this event
2070
- * has to be removed from the notify lists of any remaining events in the
2071
- * wait list.
2072
- *
2073
- * Mind the acrobatics of trying to avoid races with pocl_broadcast and
2074
- * pocl_create_event_sync. */
2075
- event_node * tmp ;
2076
- POCL_LOCK_OBJ (event );
2077
- while ((tmp = event -> wait_list ))
2078
- {
2079
- cl_event notifier = tmp -> event ;
2080
- POCL_UNLOCK_OBJ (event );
2081
- pocl_lock_events_inorder (notifier , event );
2082
- if (tmp != event -> wait_list )
2083
- {
2084
- pocl_unlock_events_inorder (notifier , event );
2085
- POCL_LOCK_OBJ (event );
2086
- continue ;
2087
- }
2088
- event_node * tmp2 ;
2089
- LL_FOREACH (notifier -> notify_list , tmp2 )
2090
- {
2091
- if (tmp2 -> event == event )
2092
- {
2093
- LL_DELETE (notifier -> notify_list , tmp2 );
2094
- pocl_mem_manager_free_event_node (tmp2 );
2095
- break ;
2096
- }
2097
- }
2098
- LL_DELETE (event -> wait_list , tmp );
2099
- pocl_unlock_events_inorder (notifier , event );
2100
- pocl_mem_manager_free_event_node (tmp );
2101
- POCL_LOCK_OBJ (event );
2102
- }
2103
- POCL_UNLOCK_OBJ (event );
2104
- #endif
2105
-
2106
2084
#ifdef POCL_DEBUG_MESSAGES
2107
2085
if (msg != NULL )
2108
2086
{
0 commit comments