Skip to content

[SYCL] Fix calculation of unreleased events in a pool #4730

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
Oct 8, 2021
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
8 changes: 7 additions & 1 deletion sycl/plugins/level_zero/pi_level_zero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,11 @@ _pi_context::getFreeSlotInExistingOrNewPool(ze_event_pool_handle_t &Pool,
ZE_CALL(zeEventPoolCreate, (ZeContext, &ZeEventPoolDesc, ZeDevices.size(),
&ZeDevices[0], ZePool));
NumEventsAvailableInEventPool[*ZePool] = MaxNumEventsPerPool - 1;
NumEventsUnreleasedInEventPool[*ZePool] = MaxNumEventsPerPool;
NumEventsUnreleasedInEventPool[*ZePool] = 1;
} else {
Index = MaxNumEventsPerPool - NumEventsAvailableInEventPool[*ZePool];
--NumEventsAvailableInEventPool[*ZePool];
++NumEventsUnreleasedInEventPool[*ZePool];
}
Pool = *ZePool;
return PI_SUCCESS;
Expand All @@ -466,6 +467,8 @@ pi_result _pi_context::decrementUnreleasedEventsInPool(pi_event Event) {

// Put the empty pool to the cache of the pools.
std::lock_guard<std::mutex> Lock(ZeEventPoolCacheMutex);
if (NumEventsUnreleasedInEventPool[Event->ZeEventPool] == 0)
die("Invalid event release: event pool doesn't have unreleased events");
if (--NumEventsUnreleasedInEventPool[Event->ZeEventPool] == 0) {
if (ZeEventPoolCache.front() != Event->ZeEventPool) {
ZeEventPoolCache.push_back(Event->ZeEventPool);
Expand All @@ -474,6 +477,9 @@ pi_result _pi_context::decrementUnreleasedEventsInPool(pi_event Event) {
}

if (Event->ZeHostVisibleEventPool) {
if (NumEventsUnreleasedInEventPool[Event->ZeEventPool] == 0)
die("Invalid host visible event release: host visible event pool doesn't "
"have unreleased events");
if (--NumEventsUnreleasedInEventPool[Event->ZeHostVisibleEventPool] == 0) {
if (ZeHostVisibleEventPoolCache.front() !=
Event->ZeHostVisibleEventPool) {
Expand Down