@@ -264,50 +264,60 @@ cl_int CL_API_CALL clEnqueueWaitSemaphoresKHR_EMU(
264264 return CL_INVALID_VALUE;
265265 }
266266
267- cl_context q_context;
267+ cl_context q_context = nullptr ;
268268 retVal = g_pNextDispatch->clGetCommandQueueInfo (
269- command_queue, CL_QUEUE_CONTEXT, sizeof (q_context), &q_context, nullptr );
270- if (retVal != CL_SUCCESS)
271- return retVal;
269+ command_queue,
270+ CL_QUEUE_CONTEXT,
271+ sizeof (q_context),
272+ &q_context,
273+ nullptr );
274+ if ( retVal != CL_SUCCESS )
275+ {
276+ return retVal;
277+ }
272278
273- // CL_INVALID_EVENT_WAIT_LIST
274- // -event_wait_list is NULL and num_events_in_wait_list is not 0, or
275- // -event_wait_list is not NULL and num_events_in_wait_list is 0, or
276- if ((num_events_in_wait_list>0 &&event_wait_list==nullptr ) ||
277- (num_events_in_wait_list==0 &&event_wait_list!=nullptr ))
279+ if ( (num_events_in_wait_list > 0 && event_wait_list == nullptr ) ||
280+ (num_events_in_wait_list == 0 && event_wait_list != nullptr ) )
278281 {
279282 return CL_INVALID_EVENT_WAIT_LIST;
280283 }
281- else
284+
285+ for ( cl_uint i = 0 ; i < num_events_in_wait_list; i++ )
282286 {
283- for (cl_uint i= 0 ; i<num_events_in_wait_list; i++ )
287+ if ( event_wait_list[i] == nullptr )
284288 {
285- // CL_INVALID_EVENT_WAIT_LIST - event objects in event_wait_list are
286- // not valid events.
287- if (event_wait_list[i] == nullptr )
288289 return CL_INVALID_EVENT_WAIT_LIST;
290+ }
289291
290- // CL_INVALID_CONTEXT - the context associated with command_queue and
291- // that associated with events in event_wait_list are not the same
292- cl_context e_context;
293- retVal = g_pNextDispatch->clGetEventInfo (
294- event_wait_list[i], CL_EVENT_CONTEXT, sizeof (e_context),
295- &e_context, nullptr );
296- if (retVal != CL_SUCCESS)
297- return retVal;
298- if (q_context != e_context)
292+ cl_context e_context = nullptr ;
293+ retVal = g_pNextDispatch->clGetEventInfo (
294+ event_wait_list[i],
295+ CL_EVENT_CONTEXT,
296+ sizeof (e_context),
297+ &e_context,
298+ nullptr );
299+ if ( retVal != CL_SUCCESS )
300+ {
301+ return retVal; // or CL_INVALID_EVENT_WAIT_LIST?
302+ }
303+ if ( q_context != e_context )
304+ {
299305 return CL_INVALID_CONTEXT;
306+ }
300307
301- // CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST - the execution status
302- // of any of the events in event_wait_list is a negative integer
303- // value.
304- cl_int status = 0 ;
305- retVal = g_pNextDispatch->clGetEventInfo (
306- event_wait_list[i], CL_EVENT_COMMAND_EXECUTION_STATUS,
307- sizeof (status), &status, nullptr );
308- if (retVal != CL_SUCCESS)
309- return retVal;
310- if (status < 0 )
308+ cl_int status = 0 ;
309+ retVal = g_pNextDispatch->clGetEventInfo (
310+ event_wait_list[i],
311+ CL_EVENT_COMMAND_EXECUTION_STATUS,
312+ sizeof (status),
313+ &status,
314+ nullptr );
315+ if ( retVal != CL_SUCCESS )
316+ {
317+ return retVal; // or CL_INVALID_EVENT_WAIT_LIST?
318+ }
319+ if ( status < 0 )
320+ {
311321 return CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST;
312322 }
313323 }
@@ -324,11 +334,9 @@ cl_int CL_API_CALL clEnqueueWaitSemaphoresKHR_EMU(
324334 {
325335 return CL_INVALID_SEMAPHORE_KHR;
326336 }
327- if ( semaphores[i]->Context != q_context)
337+ if ( semaphores[i]->Context != q_context )
328338 {
329- // CL_INVALID_CONTEXT - the context associated with command_queue and
330- // any of the semaphore objects in sema_objects are not the same
331- return CL_INVALID_CONTEXT;
339+ return CL_INVALID_CONTEXT;
332340 }
333341 if ( semaphores[i]->Event == nullptr )
334342 {
@@ -376,51 +384,61 @@ cl_int CL_API_CALL clEnqueueSignalSemaphoresKHR_EMU(
376384 return CL_INVALID_VALUE;
377385 }
378386
379- cl_context q_context;
387+ cl_context q_context = nullptr ;
380388 retVal = g_pNextDispatch->clGetCommandQueueInfo (
381- command_queue, CL_QUEUE_CONTEXT, sizeof (q_context), &q_context, nullptr );
389+ command_queue,
390+ CL_QUEUE_CONTEXT,
391+ sizeof (q_context),
392+ &q_context,
393+ nullptr );
382394 if (retVal != CL_SUCCESS)
383- return retVal;
395+ {
396+ return retVal;
397+ }
384398
385- // CL_INVALID_EVENT_WAIT_LIST
386- // -event_wait_list is NULL and num_events_in_wait_list is not 0, or
387- // -event_wait_list is not NULL and num_events_in_wait_list is 0, or
388- if ((num_events_in_wait_list>0 &&event_wait_list==nullptr ) ||
389- (num_events_in_wait_list==0 &&event_wait_list!=nullptr ))
399+ if ( (num_events_in_wait_list > 0 && event_wait_list == nullptr ) ||
400+ (num_events_in_wait_list == 0 && event_wait_list != nullptr ) )
390401 {
391402 return CL_INVALID_EVENT_WAIT_LIST;
392403 }
393- else
404+
405+ for ( cl_uint i = 0 ; i < num_events_in_wait_list; i++ )
394406 {
395- for (cl_uint i=0 ; i<num_events_in_wait_list; i++)
396- {
397- // CL_INVALID_EVENT_WAIT_LIST - event objects in event_wait_list are
398- // not valid events.
399- if (event_wait_list[i] == nullptr )
400- return CL_INVALID_EVENT_WAIT_LIST;
401-
402- // CL_INVALID_CONTEXT - the context associated with command_queue and
403- // that associated with events in event_wait_list are not the same
404- cl_context e_context;
405- retVal = g_pNextDispatch->clGetEventInfo (
406- event_wait_list[i], CL_EVENT_CONTEXT, sizeof (e_context),
407- &e_context, nullptr );
408- if (retVal != CL_SUCCESS)
409- return retVal;
410- if (q_context != e_context)
411- return CL_INVALID_CONTEXT;
412-
413- // CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST - the execution status
414- // of any of the events in event_wait_list is a negative integer
415- // value.
416- cl_int status = 0 ;
417- retVal = g_pNextDispatch->clGetEventInfo (
418- event_wait_list[i], CL_EVENT_COMMAND_EXECUTION_STATUS,
419- sizeof (status), &status, nullptr );
420- if (retVal != CL_SUCCESS)
421- return retVal;
422- if (status < 0 )
423- return CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST;
407+ if (event_wait_list[i] == nullptr )
408+ {
409+ return CL_INVALID_EVENT_WAIT_LIST;
410+ }
411+
412+ cl_context e_context = nullptr ;
413+ retVal = g_pNextDispatch->clGetEventInfo (
414+ event_wait_list[i],
415+ CL_EVENT_CONTEXT,
416+ sizeof (e_context),
417+ &e_context,
418+ nullptr );
419+ if ( retVal != CL_SUCCESS )
420+ {
421+ return retVal;
422+ }
423+ if ( q_context != e_context )
424+ {
425+ return CL_INVALID_CONTEXT;
426+ }
427+
428+ cl_int status = 0 ;
429+ retVal = g_pNextDispatch->clGetEventInfo (
430+ event_wait_list[i],
431+ CL_EVENT_COMMAND_EXECUTION_STATUS,
432+ sizeof (status),
433+ &status,
434+ nullptr );
435+ if ( retVal != CL_SUCCESS )
436+ {
437+ return retVal;
438+ }
439+ if ( status < 0 )
440+ {
441+ return CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST;
424442 }
425443 }
426444
@@ -430,11 +448,9 @@ cl_int CL_API_CALL clEnqueueSignalSemaphoresKHR_EMU(
430448 {
431449 return CL_INVALID_SEMAPHORE_KHR;
432450 }
433- if ( semaphores[i]->Context != q_context)
451+ if ( semaphores[i]->Context != q_context )
434452 {
435- // CL_INVALID_CONTEXT - the context associated with command_queue and
436- // any of the semaphore objects in sema_objects are not the same
437- return CL_INVALID_CONTEXT;
453+ return CL_INVALID_CONTEXT;
438454 }
439455 if ( semaphores[i]->Event != nullptr )
440456 {
0 commit comments