Skip to content

Commit 6f240fc

Browse files
[UR][L0] Event cleanup in urEnqueueKernelLaunch
When using internal events we do not clean up after execution. In the case of repeated call to urEnqueueKernelLaunch we eventually return UR_RESULT_ERROR_OUT_OF_RESOURCES. Signed-off-by: Zhang, Winston <[email protected]>
1 parent e6de775 commit 6f240fc

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,20 @@ ur_result_t urEnqueueKernelLaunch(
221221
UR_CALL(Queue->executeCommandList(CommandList, false /*IsBlocking*/,
222222
true /*OKToBatchCommand*/));
223223

224+
// For internal events, trigger cleanup to prevent event pool exhaustion
225+
// by ensuring completed internal events are cleaned up periodically
226+
if (IsInternal) {
227+
if (Queue->UsingImmCmdLists) {
228+
UR_CALL(CleanupEventsInImmCmdLists(Queue, false /*QueueLocked*/,
229+
false /*QueueSynced*/,
230+
nullptr /*CompletedEvent*/));
231+
} else {
232+
// For regular command lists, call resetCommandLists to clean up
233+
// completed command lists and their associated events
234+
UR_CALL(resetCommandLists(Queue));
235+
}
236+
}
237+
224238
return UR_RESULT_SUCCESS;
225239
}
226240

unified-runtime/source/adapters/level_zero/kernel.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "common.hpp"
1515
#include "common/ur_ref_count.hpp"
1616
#include "memory.hpp"
17+
#include "queue.hpp"
1718

1819
struct ur_kernel_handle_t_ : ur_object {
1920
ur_kernel_handle_t_(bool OwnZeHandle, ur_program_handle_t Program)

0 commit comments

Comments
 (0)