Skip to content

[SYCL][L0] Optimize sync of an in-order queue #8601

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 1 commit into from
Mar 10, 2023
Merged
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
29 changes: 20 additions & 9 deletions sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5726,17 +5726,28 @@ pi_result _pi_queue::synchronize() {
return PI_SUCCESS;
};

for (auto &QueueMap : {ComputeQueueGroupsByTID, CopyQueueGroupsByTID})
for (auto &QueueGroup : QueueMap) {
if (Device->ImmCommandListUsed) {
for (auto ImmCmdList : QueueGroup.second.ImmCmdLists)
syncImmCmdList(this, ImmCmdList);
} else {
for (auto &ZeQueue : QueueGroup.second.ZeQueues)
if (ZeQueue)
ZE_CALL(zeHostSynchronize, (ZeQueue));
// Do nothing if the queue is empty
if (!LastCommandEvent)
return PI_SUCCESS;

// For in-order queue just wait for the last command.
if (isInOrderQueue()) {
ZE_CALL(zeHostSynchronize, (LastCommandEvent->ZeEvent));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this works only if LastCommandEvent is the true last event of all the objects in QueueMap::QueueGroup. if so, then this is good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's what is in LastCommandEvent, the last command submitted to the PI/UR queue.

} else {
// Otherwise sync all L0 queues/immediate command-lists.
for (auto &QueueMap : {ComputeQueueGroupsByTID, CopyQueueGroupsByTID}) {
for (auto &QueueGroup : QueueMap) {
if (Device->ImmCommandListUsed) {
for (auto ImmCmdList : QueueGroup.second.ImmCmdLists)
syncImmCmdList(this, ImmCmdList);
} else {
for (auto &ZeQueue : QueueGroup.second.ZeQueues)
if (ZeQueue)
ZE_CALL(zeHostSynchronize, (ZeQueue));
}
}
}
}
LastCommandEvent = nullptr;

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