Skip to content

Commit 3a6390f

Browse files
committed
[SYCL][Graph][UR] Elide second barrier in graph finalize if possible
1 parent 9283d86 commit 3a6390f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,24 @@ ur_result_t ur_exp_command_buffer_handle_t_::finalizeCommandBuffer() {
131131
auto commandListLocked = commandListManager.lock();
132132
UR_ASSERT(!isFinalized, UR_RESULT_ERROR_INVALID_OPERATION);
133133

134+
size_t numEventResets = 0;
135+
134136
if (!isInOrder) {
135137
ZE2UR_CALL(zeCommandListAppendBarrier,
136138
(commandListLocked->getZeCommandList(), nullptr, 0, nullptr));
137139
for (size_t i = 0; i < usedSyncPoints.size(); ++i) {
138140
if (!usedSyncPoints[i]) {
139141
continue;
140142
}
143+
++numEventResets;
141144
ZE2UR_CALL(
142145
zeCommandListAppendEventReset,
143146
(commandListLocked->getZeCommandList(), syncPoints[i]->getZeEvent()));
144147
}
145-
ZE2UR_CALL(zeCommandListAppendBarrier,
146-
(commandListLocked->getZeCommandList(), nullptr, 0, nullptr));
148+
149+
if (numEventResets)
150+
ZE2UR_CALL(zeCommandListAppendBarrier,
151+
(commandListLocked->getZeCommandList(), nullptr, 0, nullptr));
147152
}
148153
// Close the command lists and have them ready for dispatch.
149154
ZE2UR_CALL(zeCommandListClose, (commandListLocked->getZeCommandList()));

0 commit comments

Comments
 (0)