From 2dbe0800a9cc16dcf87ee93edfb51e9f62553847 Mon Sep 17 00:00:00 2001 From: Ewan Crawford Date: Mon, 12 Aug 2024 10:45:27 +0100 Subject: [PATCH] Command-buffer immediate command-list CTS fix As discovered in https://github.com/oneapi-src/unified-runtime/pull/1951#issuecomment-2278519730 there is an issue running the command-buffer CTS tests on L0 with command-lists enabled. After investigating, this was because the CTS tests we're not using the output event parameter to command-buffer enqueue. In the L0 adapter code a path for registering an event with the queue to waiting on the workload was guarded by this event being set. Therefore `urQueueFinish` was not working as expected, as the queue was not aware of this work to wait on. Fixed by always registering the work to wait on with the queue, and miss out on propagation of the created event when user doesn't pass an output event, rather than not creating it at all. --- source/adapters/level_zero/command_buffer.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/source/adapters/level_zero/command_buffer.cpp b/source/adapters/level_zero/command_buffer.cpp index d69f08cc1b..ff4f0b56bc 100644 --- a/source/adapters/level_zero/command_buffer.cpp +++ b/source/adapters/level_zero/command_buffer.cpp @@ -1300,13 +1300,14 @@ ur_result_t waitForDependencies(ur_exp_command_buffer_handle_t CommandBuffer, * @param[in] CommandBuffer The command buffer. * @param[in] Queue The UR queue used to submit the command buffer. * @param[in] SignalCommandList The command-list to append the barrier to. - * @param[out] Event The host visible event which will be returned to the user. + * @param[out][optional] Event The host visible event which will be returned + * to the user, if user passed an output parameter to the UR API. * @return UR_RESULT_SUCCESS or an error code on failure */ ur_result_t createUserEvent(ur_exp_command_buffer_handle_t CommandBuffer, ur_queue_handle_legacy_t Queue, ur_command_list_ptr_t SignalCommandList, - ur_event_handle_t &Event) { + ur_event_handle_t *Event) { // Execution event for this enqueue of the UR command-buffer ur_event_handle_t RetEvent{}; @@ -1342,7 +1343,9 @@ ur_result_t createUserEvent(ur_exp_command_buffer_handle_t CommandBuffer, &(CommandBuffer->SignalEvent->ZeEvent))); } - Event = RetEvent; + if (Event) { + *Event = RetEvent; + } return UR_RESULT_SUCCESS; } @@ -1405,9 +1408,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferEnqueueExp( ZE2UR_CALL(zeCommandListAppendEventReset, (SignalCommandList->first, CommandBuffer->AllResetEvent->ZeEvent)); - if (Event) { - UR_CALL(createUserEvent(CommandBuffer, Queue, SignalCommandList, *Event)); - } + // Appends a wait on the main command-list signal and registers output Event + // parameter with signal command-list completing. + UR_CALL(createUserEvent(CommandBuffer, Queue, SignalCommandList, Event)); UR_CALL(Queue->executeCommandList(SignalCommandList, false, false));