Skip to content

Commit c9cba79

Browse files
authored
[UR][L0] Move async pool cleanup after queue sync (#18331)
In a scenario where the AsyncPool freelist contains an entry tied to a free event that hasn't completed yet, performing freelist cleanup before queue sync can result in freeing memory that's actively in use.
1 parent 06b0d43 commit c9cba79

File tree

1 file changed

+3
-2
lines changed
  • unified-runtime/source/adapters/level_zero

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,8 +615,6 @@ ur_result_t urQueueRelease(
615615
return UR_RESULT_SUCCESS;
616616
}
617617

618-
Queue->Context->AsyncPool.cleanupPoolsForQueue(Queue);
619-
620618
// When external reference count goes to zero it is still possible
621619
// that internal references still exists, e.g. command-lists that
622620
// are not yet completed. So do full queue synchronization here
@@ -630,6 +628,9 @@ ur_result_t urQueueRelease(
630628
if (Res == UR_RESULT_SUCCESS)
631629
UR_CALL(Queue->synchronize());
632630

631+
// Cleanup the allocations from 'AsyncPool' made by this queue.
632+
Queue->Context->AsyncPool.cleanupPoolsForQueue(Queue);
633+
633634
// Destroy all the fences created associated with this queue.
634635
for (auto it = Queue->CommandListMap.begin();
635636
it != Queue->CommandListMap.end(); ++it) {

0 commit comments

Comments
 (0)