Skip to content

Commit 67e63cf

Browse files
[SYCL][L0] Optimize sync of an in-order queue (#8601)
Signed-off-by: Sergey V Maslov <[email protected]>
1 parent fea99cc commit 67e63cf

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

sycl/plugins/level_zero/pi_level_zero.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5726,17 +5726,28 @@ pi_result _pi_queue::synchronize() {
57265726
return PI_SUCCESS;
57275727
};
57285728

5729-
for (auto &QueueMap : {ComputeQueueGroupsByTID, CopyQueueGroupsByTID})
5730-
for (auto &QueueGroup : QueueMap) {
5731-
if (Device->ImmCommandListUsed) {
5732-
for (auto ImmCmdList : QueueGroup.second.ImmCmdLists)
5733-
syncImmCmdList(this, ImmCmdList);
5734-
} else {
5735-
for (auto &ZeQueue : QueueGroup.second.ZeQueues)
5736-
if (ZeQueue)
5737-
ZE_CALL(zeHostSynchronize, (ZeQueue));
5729+
// Do nothing if the queue is empty
5730+
if (!LastCommandEvent)
5731+
return PI_SUCCESS;
5732+
5733+
// For in-order queue just wait for the last command.
5734+
if (isInOrderQueue()) {
5735+
ZE_CALL(zeHostSynchronize, (LastCommandEvent->ZeEvent));
5736+
} else {
5737+
// Otherwise sync all L0 queues/immediate command-lists.
5738+
for (auto &QueueMap : {ComputeQueueGroupsByTID, CopyQueueGroupsByTID}) {
5739+
for (auto &QueueGroup : QueueMap) {
5740+
if (Device->ImmCommandListUsed) {
5741+
for (auto ImmCmdList : QueueGroup.second.ImmCmdLists)
5742+
syncImmCmdList(this, ImmCmdList);
5743+
} else {
5744+
for (auto &ZeQueue : QueueGroup.second.ZeQueues)
5745+
if (ZeQueue)
5746+
ZE_CALL(zeHostSynchronize, (ZeQueue));
5747+
}
57385748
}
57395749
}
5750+
}
57405751
LastCommandEvent = nullptr;
57415752

57425753
// With the entire queue synchronized, the active barriers must be done so we

0 commit comments

Comments
 (0)