Skip to content

Commit 957c657

Browse files
committed
Restrict events reset during command buffer enqueue
1 parent 1eb75c7 commit 957c657

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ ur_event_handle_t *ur_exp_command_buffer_handle_t_::getWaitListFromSyncPoints(
9999
UR_LOG(ERR, "Invalid sync point");
100100
throw UR_RESULT_ERROR_INVALID_VALUE;
101101
}
102+
usedSyncPoints.insert(pSyncPointWaitList[i]);
102103
syncPointWaitList[i] = syncPoints[pSyncPointWaitList[i]];
103104
}
104105
return syncPointWaitList.data();
@@ -132,9 +133,10 @@ ur_result_t ur_exp_command_buffer_handle_t_::finalizeCommandBuffer() {
132133
if (!isInOrder) {
133134
ZE2UR_CALL(zeCommandListAppendBarrier,
134135
(commandListLocked->getZeCommandList(), nullptr, 0, nullptr));
135-
for (auto &event : syncPoints) {
136+
for (auto &event : usedSyncPoints) {
136137
ZE2UR_CALL(zeCommandListAppendEventReset,
137-
(commandListLocked->getZeCommandList(), event->getZeEvent()));
138+
(commandListLocked->getZeCommandList(),
139+
syncPoints[event]->getZeEvent()));
138140
}
139141
ZE2UR_CALL(zeCommandListAppendBarrier,
140142
(commandListLocked->getZeCommandList(), nullptr, 0, nullptr));

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ struct ur_exp_command_buffer_handle_t_ : public ur_object {
6666
// Stores all sync points that are created by the command buffer.
6767
std::vector<ur_event_handle_t> syncPoints;
6868

69+
// Stores all sync points that should be reset after execution.
70+
std::unordered_set<ur_exp_command_buffer_sync_point_t> usedSyncPoints;
71+
6972
// Temporary storage for sync points that are passed to function that require
7073
// array of events. This is used to avoid allocating a new memory every time.
7174
std::vector<ur_event_handle_t> syncPointWaitList;

0 commit comments

Comments
 (0)