Skip to content

Commit bd511a2

Browse files
author
Mikołaj Komar
committed
Fix PR comments
1 parent e6161ee commit bd511a2

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

unified-runtime/source/adapters/level_zero/v2/command_buffer.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,32 +47,26 @@ ur_result_t ur_exp_command_buffer_handle_t_::finalizeCommandBuffer() {
4747
isFinalized = true;
4848
return UR_RESULT_SUCCESS;
4949
}
50-
ur_result_t ur_exp_command_buffer_handle_t_::awaitExecution(
51-
locked<ur_command_list_manager> &commandList) {
52-
std::ignore = commandList;
50+
ur_event_handle_t ur_exp_command_buffer_handle_t_::getCurrentExecutionEvent(
51+
[[maybe_unused]] locked<ur_command_list_manager> &commandList) {
5352
assert(
5453
commandList->getZeCommandList() ==
5554
commandListManager.get_no_lock()->getZeCommandList() &&
5655
"Provided command list is not the same as the one in the command buffer");
57-
if (currentExecution) {
58-
ZE2UR_CALL(zeEventHostSynchronize,
59-
(currentExecution->getZeEvent(), UINT64_MAX));
60-
UR_CALL(currentExecution->release());
61-
currentExecution = nullptr;
62-
}
63-
return UR_RESULT_SUCCESS;
56+
return currentExecution;
6457
}
6558

6659
ur_result_t ur_exp_command_buffer_handle_t_::registerExecutionEvent(
67-
locked<ur_command_list_manager> &commandList,
60+
[[maybe_unused]] locked<ur_command_list_manager> &commandList,
6861
ur_event_handle_t nextExecutionEvent) {
69-
std::ignore = commandList;
7062
assert(
7163
commandList->getZeCommandList() ==
7264
commandListManager.get_no_lock()->getZeCommandList() &&
7365
"Provided command list is not the same as the one in the command buffer");
74-
assert(currentExecution == nullptr &&
75-
"Current execution event is not null, it should be awaited first");
66+
if (currentExecution) {
67+
UR_CALL(currentExecution->release());
68+
currentExecution = nullptr;
69+
}
7670
if (nextExecutionEvent) {
7771
currentExecution = nextExecutionEvent;
7872
UR_CALL(nextExecutionEvent->retain());

unified-runtime/source/adapters/level_zero/v2/command_buffer.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ struct ur_exp_command_buffer_handle_t_ : public _ur_object {
2525

2626
~ur_exp_command_buffer_handle_t_();
2727

28-
ur_result_t awaitExecution(locked<ur_command_list_manager> &commandList);
28+
ur_event_handle_t
29+
getCurrentExecutionEvent(locked<ur_command_list_manager> &commandList);
2930
ur_result_t
3031
registerExecutionEvent(locked<ur_command_list_manager> &commandList,
3132
ur_event_handle_t nextExecutionEvent);

unified-runtime/source/adapters/level_zero/v2/queue_immediate_in_order.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,17 @@ ur_result_t ur_queue_immediate_in_order_t::enqueueCommandBufferExp(
932932
if (phEvent == nullptr) {
933933
phEvent = &internalEvent;
934934
}
935-
UR_CALL(hCommandBuffer->awaitExecution(commandListLocked));
935+
ur_event_handle_t executionEvent =
936+
hCommandBuffer->getCurrentExecutionEvent(commandListLocked);
937+
std::vector<ur_event_handle_t> extendedWaitList;
938+
if (executionEvent != nullptr) {
939+
extendedWaitList.resize(numEventsInWaitList + 1);
940+
std::copy(phEventWaitList, phEventWaitList + numEventsInWaitList,
941+
extendedWaitList.begin());
942+
extendedWaitList[numEventsInWaitList] = executionEvent;
943+
phEventWaitList = extendedWaitList.data();
944+
numEventsInWaitList++;
945+
}
936946
UR_CALL(enqueueGenericCommandListsExp(1, &commandBufferCommandList, phEvent,
937947
numEventsInWaitList, phEventWaitList,
938948
UR_COMMAND_ENQUEUE_COMMAND_BUFFER_EXP));

0 commit comments

Comments
 (0)