Skip to content

Commit 731376d

Browse files
authored
Merge pull request #1802 from nrspruit/fix_immediate_cmdlist_reuse
[L0] Fix immediate command list use in Command Queues
2 parents 4030080 + 665d4a6 commit 731376d

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

source/adapters/level_zero/context.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,10 @@ ur_result_t ur_context_handle_t_::getAvailableCommandList(
733733
!(ZeCommandListIt->second.InOrderList)) {
734734
continue;
735735
}
736+
// Only allow to reuse Regular Command Lists
737+
if (ZeCommandListIt->second.IsImmediate) {
738+
continue;
739+
}
736740
auto &ZeCommandList = ZeCommandListIt->first;
737741
auto it = Queue->CommandListMap.find(ZeCommandList);
738742
if (it != Queue->CommandListMap.end()) {

source/adapters/level_zero/context.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
struct l0_command_list_cache_info {
3131
ZeStruct<ze_command_queue_desc_t> ZeQueueDesc;
3232
bool InOrderList = false;
33+
bool IsImmediate = false;
3334
};
3435

3536
struct ur_context_handle_t_ : _ur_object {

source/adapters/level_zero/queue.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ ur_result_t ur_queue_handle_legacy_t_::queueRelease() {
665665
struct l0_command_list_cache_info ListInfo;
666666
ListInfo.ZeQueueDesc = it->second.ZeQueueDesc;
667667
ListInfo.InOrderList = it->second.IsInOrderList;
668+
ListInfo.IsImmediate = it->second.IsImmediate;
668669
ZeCommandListCache.push_back({it->first, ListInfo});
669670
} else {
670671
// A non-reusable comamnd list that came from a make_queue call is
@@ -745,7 +746,8 @@ void ur_queue_handle_legacy_t_::ur_queue_group_t::setImmCmdList(
745746
.insert(std::pair<ze_command_list_handle_t, ur_command_list_info_t>{
746747
ZeCommandList,
747748
ur_command_list_info_t(nullptr, true, false, nullptr, ZeQueueDesc,
748-
queue->useCompletionBatching(), false)})
749+
queue->useCompletionBatching(), false,
750+
false, true)})
749751
.first);
750752
}
751753

@@ -2080,6 +2082,7 @@ ur_result_t ur_queue_handle_legacy_t_::resetCommandList(
20802082
struct l0_command_list_cache_info ListInfo;
20812083
ListInfo.ZeQueueDesc = CommandList->second.ZeQueueDesc;
20822084
ListInfo.InOrderList = CommandList->second.IsInOrderList;
2085+
ListInfo.IsImmediate = CommandList->second.IsImmediate;
20832086
ZeCommandListCache.push_back({CommandList->first, ListInfo});
20842087
}
20852088

@@ -2430,9 +2433,9 @@ ur_queue_handle_legacy_t_::ur_queue_group_t::getImmCmdList() {
24302433
Queue->CommandListMap
24312434
.insert(std::pair<ze_command_list_handle_t, ur_command_list_info_t>{
24322435
ZeCommandList,
2433-
ur_command_list_info_t(nullptr, true, false, nullptr,
2434-
ZeCommandQueueDesc,
2435-
Queue->useCompletionBatching())})
2436+
ur_command_list_info_t(
2437+
nullptr, true, false, nullptr, ZeCommandQueueDesc,
2438+
Queue->useCompletionBatching(), true, false, true)})
24362439
.first;
24372440

24382441
return ImmCmdLists[Index];

source/adapters/level_zero/queue.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,11 @@ struct ur_command_list_info_t {
168168
bool IsClosed, ze_command_queue_handle_t ZeQueue,
169169
ZeStruct<ze_command_queue_desc_t> ZeQueueDesc,
170170
bool UseCompletionBatching, bool CanReuse = true,
171-
bool IsInOrderList = false)
171+
bool IsInOrderList = false, bool IsImmediate = false)
172172
: ZeFence(ZeFence), ZeFenceInUse(ZeFenceInUse), IsClosed(IsClosed),
173173
ZeQueue(ZeQueue), ZeQueueDesc(ZeQueueDesc),
174-
IsInOrderList(IsInOrderList), CanReuse(CanReuse) {
174+
IsInOrderList(IsInOrderList), CanReuse(CanReuse),
175+
IsImmediate(IsImmediate) {
175176
if (UseCompletionBatching) {
176177
completions = ur_completion_batches();
177178
}
@@ -204,6 +205,7 @@ struct ur_command_list_info_t {
204205
// Indicates if this is an inorder list
205206
bool IsInOrderList;
206207
bool CanReuse;
208+
bool IsImmediate;
207209

208210
// Helper functions to tell if this is a copy command-list.
209211
bool isCopy(ur_queue_handle_legacy_t Queue) const;

0 commit comments

Comments
 (0)