Skip to content

Commit 7d460d3

Browse files
Added previous comments back
Signed-off-by: Zhang, Winston <[email protected]>
1 parent 4da489c commit 7d460d3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

unified-runtime/source/adapters/level_zero/context.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,15 @@ ur_result_t ur_context_handle_t_::getFreeSlotInExistingOrNewPool(
434434
if (!ZePoolCache->empty()) {
435435
if (NumEventsAvailableInEventPool[ZePoolCache->front()] == 0) {
436436
if (DisableEventsCaching) {
437+
// Remove full pool from the cache if events caching is disabled.
438+
// also add pool to cleanup list to prevent leaks.
437439
ZePoolCleanupList.push_back(*ZePoolCache->begin());
438440
ZePoolCache->erase(ZePoolCache->begin());
439441
} else {
442+
// If event caching is enabled then we don't destroy events so there is
443+
// no need to remove pool from the cache and add it back when it has
444+
// available slots. Just keep it in the tail of the cache so that all
445+
// pools can be destroyed during context destruction.
440446
ZePoolCache->push_front(nullptr);
441447
}
442448
}

0 commit comments

Comments
 (0)