Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,38 @@ ur_result_t ur_exp_command_buffer_handle_t_::finalizeCommandBuffer() {
isFinalized = true;
return UR_RESULT_SUCCESS;
}
ur_event_handle_t ur_exp_command_buffer_handle_t_::getCurrentExecutionEvent(
[[maybe_unused]] locked<ur_command_list_manager> &commandList) {
assert(
commandList->getZeCommandList() ==
commandListManager.get_no_lock()->getZeCommandList() &&
"Provided command list is not the same as the one in the command buffer");
return currentExecution;
}

ur_result_t ur_exp_command_buffer_handle_t_::registerExecutionEvent(
[[maybe_unused]] locked<ur_command_list_manager> &commandList,
ur_event_handle_t nextExecutionEvent) {
assert(
commandList->getZeCommandList() ==
commandListManager.get_no_lock()->getZeCommandList() &&
"Provided command list is not the same as the one in the command buffer");
if (currentExecution) {
UR_CALL(currentExecution->release());
currentExecution = nullptr;
}
if (nextExecutionEvent) {
currentExecution = nextExecutionEvent;
UR_CALL(nextExecutionEvent->retain());
}
return UR_RESULT_SUCCESS;
}

ur_exp_command_buffer_handle_t_::~ur_exp_command_buffer_handle_t_() {
if (currentExecution) {
currentExecution->release();
}
}
namespace ur::level_zero {

ur_result_t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ struct ur_exp_command_buffer_handle_t_ : public _ur_object {
v2::raii::command_list_unique_handle &&commandList,
const ur_exp_command_buffer_desc_t *desc);

~ur_exp_command_buffer_handle_t_() = default;
~ur_exp_command_buffer_handle_t_();

ur_event_handle_t
getCurrentExecutionEvent(locked<ur_command_list_manager> &commandList);
ur_result_t
registerExecutionEvent(locked<ur_command_list_manager> &commandList,
ur_event_handle_t nextExecutionEvent);

lockable<ur_command_list_manager> commandListManager;

Expand All @@ -36,6 +42,8 @@ struct ur_exp_command_buffer_handle_t_ : public _ur_object {
private:
// Indicates if command-buffer was finalized.
bool isFinalized = false;

ur_event_handle_t currentExecution = nullptr;
};

struct ur_exp_command_buffer_command_handle_t_ : public _ur_object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -928,9 +928,29 @@ ur_result_t ur_queue_immediate_in_order_t::enqueueCommandBufferExp(
auto commandListLocked = hCommandBuffer->commandListManager.lock();
ze_command_list_handle_t commandBufferCommandList =
commandListLocked->getZeCommandList();
return enqueueGenericCommandListsExp(1, &commandBufferCommandList, phEvent,
numEventsInWaitList, phEventWaitList,
UR_COMMAND_ENQUEUE_COMMAND_BUFFER_EXP);
ur_event_handle_t internalEvent = nullptr;
if (phEvent == nullptr) {
phEvent = &internalEvent;
}
ur_event_handle_t executionEvent =
hCommandBuffer->getCurrentExecutionEvent(commandListLocked);
std::vector<ur_event_handle_t> extendedWaitList;
if (executionEvent != nullptr) {
extendedWaitList.resize(numEventsInWaitList + 1);
std::copy(phEventWaitList, phEventWaitList + numEventsInWaitList,
extendedWaitList.begin());
extendedWaitList[numEventsInWaitList] = executionEvent;
phEventWaitList = extendedWaitList.data();
numEventsInWaitList++;
}
UR_CALL(enqueueGenericCommandListsExp(1, &commandBufferCommandList, phEvent,
numEventsInWaitList, phEventWaitList,
UR_COMMAND_ENQUEUE_COMMAND_BUFFER_EXP));
UR_CALL(hCommandBuffer->registerExecutionEvent(commandListLocked, *phEvent));
if (internalEvent != nullptr) {
internalEvent->release();
}
return UR_RESULT_SUCCESS;
}

ur_result_t ur_queue_immediate_in_order_t::enqueueKernelLaunchCustomExp(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ static void checkCommandBufferUpdateSupport(

struct urCommandBufferExpTest : uur::urContextTest {
void SetUp() override {
UUR_KNOWN_FAILURE_ON(uur::LevelZeroV2{});

UUR_RETURN_ON_FATAL_FAILURE(uur::urContextTest::SetUp());

Expand All @@ -72,7 +71,6 @@ struct urCommandBufferExpTest : uur::urContextTest {
template <class T>
struct urCommandBufferExpTestWithParam : urQueueTestWithParam<T> {
void SetUp() override {
UUR_KNOWN_FAILURE_ON(uur::LevelZeroV2{});

UUR_RETURN_ON_FATAL_FAILURE(uur::urQueueTestWithParam<T>::SetUp());

Expand All @@ -97,7 +95,6 @@ struct urCommandBufferExpTestWithParam : urQueueTestWithParam<T> {

struct urCommandBufferExpExecutionTest : uur::urKernelExecutionTest {
void SetUp() override {
UUR_KNOWN_FAILURE_ON(uur::LevelZeroV2{});

UUR_RETURN_ON_FATAL_FAILURE(uur::urKernelExecutionTest::SetUp());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ TEST_P(InvalidUpdateTest, CommandBufferMismatch) {
// that isn't supported.
struct InvalidUpdateCommandBufferExpExecutionTest : uur::urKernelExecutionTest {
void SetUp() override {
UUR_KNOWN_FAILURE_ON(uur::LevelZeroV2{});

program_name = "fill_usm";
UUR_RETURN_ON_FATAL_FAILURE(uur::urKernelExecutionTest::SetUp());

Expand Down