Skip to content

[UR][L0v2] Restrict events reset during command buffer enqueue #18990

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -84,6 +84,7 @@ ur_exp_command_buffer_handle_t_::getSyncPoint(ur_event_handle_t event) {
throw UR_RESULT_ERROR_OUT_OF_RESOURCES;
}
syncPoints.push_back(event);
usedSyncPoints.push_back(false);
return static_cast<ur_exp_command_buffer_sync_point_t>(syncPoints.size() - 1);
}

Expand All @@ -99,6 +100,7 @@ ur_event_handle_t *ur_exp_command_buffer_handle_t_::getWaitListFromSyncPoints(
UR_LOG(ERR, "Invalid sync point");
throw UR_RESULT_ERROR_INVALID_VALUE;
}
usedSyncPoints[pSyncPointWaitList[i]] = true;
syncPointWaitList[i] = syncPoints[pSyncPointWaitList[i]];
}
return syncPointWaitList.data();
Expand Down Expand Up @@ -132,9 +134,13 @@ ur_result_t ur_exp_command_buffer_handle_t_::finalizeCommandBuffer() {
if (!isInOrder) {
ZE2UR_CALL(zeCommandListAppendBarrier,
(commandListLocked->getZeCommandList(), nullptr, 0, nullptr));
for (auto &event : syncPoints) {
ZE2UR_CALL(zeCommandListAppendEventReset,
(commandListLocked->getZeCommandList(), event->getZeEvent()));
for (size_t i = 0; i < usedSyncPoints.size(); ++i) {
if (!usedSyncPoints[i]) {
continue;
}
ZE2UR_CALL(
zeCommandListAppendEventReset,
(commandListLocked->getZeCommandList(), syncPoints[i]->getZeEvent()));
}
ZE2UR_CALL(zeCommandListAppendBarrier,
(commandListLocked->getZeCommandList(), nullptr, 0, nullptr));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ struct ur_exp_command_buffer_handle_t_ : public ur_object {
// Stores all sync points that are created by the command buffer.
std::vector<ur_event_handle_t> syncPoints;

// Stores all sync points that should be reset after execution.
std::vector<bool> usedSyncPoints;

// Temporary storage for sync points that are passed to function that require
// array of events. This is used to avoid allocating a new memory every time.
std::vector<ur_event_handle_t> syncPointWaitList;
Expand Down