@@ -798,21 +798,24 @@ pi_result _pi_context::finalize() {
798
798
// Destroy the command list used for initializations
799
799
ZE_CALL (zeCommandListDestroy, (ZeCommandListInit));
800
800
801
- std::lock_guard<std::mutex> Lock (ZeCommandListCacheMutex);
802
- for (ze_command_list_handle_t &ZeCommandList : ZeComputeCommandListCache) {
803
- if (ZeCommandList)
804
- ZE_CALL (zeCommandListDestroy, (ZeCommandList));
805
- }
806
- for (ze_command_list_handle_t &ZeCommandList : ZeCopyCommandListCache) {
807
- if (ZeCommandList)
808
- ZE_CALL (zeCommandListDestroy, (ZeCommandList));
809
- }
810
-
811
801
// Adjust the number of command lists created on this platform.
812
802
auto Platform = Devices[0 ]->Platform ;
813
- Platform->ZeGlobalCommandListCount -= ZeComputeCommandListCache.size ();
814
- Platform->ZeGlobalCommandListCount -= ZeCopyCommandListCache.size ();
815
803
804
+ std::lock_guard<std::mutex> Lock (ZeCommandListCacheMutex);
805
+ for (auto &List : ZeComputeCommandListCache) {
806
+ for (ze_command_list_handle_t &ZeCommandList : List.second ) {
807
+ if (ZeCommandList)
808
+ ZE_CALL (zeCommandListDestroy, (ZeCommandList));
809
+ }
810
+ Platform->ZeGlobalCommandListCount -= List.second .size ();
811
+ }
812
+ for (auto &List : ZeCopyCommandListCache) {
813
+ for (ze_command_list_handle_t &ZeCommandList : List.second ) {
814
+ if (ZeCommandList)
815
+ ZE_CALL (zeCommandListDestroy, (ZeCommandList));
816
+ }
817
+ Platform->ZeGlobalCommandListCount -= List.second .size ();
818
+ }
816
819
return PI_SUCCESS;
817
820
}
818
821
@@ -825,9 +828,10 @@ bool _pi_queue::isInOrderQueue() const {
825
828
pi_result _pi_queue::resetCommandList (pi_command_list_ptr_t CommandList,
826
829
bool MakeAvailable) {
827
830
bool UseCopyEngine = CommandList->second .isCopy ();
828
- auto &ZeCommandListCache = UseCopyEngine
829
- ? this ->Context ->ZeCopyCommandListCache
830
- : this ->Context ->ZeComputeCommandListCache ;
831
+ auto &ZeCommandListCache =
832
+ UseCopyEngine
833
+ ? this ->Context ->ZeCopyCommandListCache [this ->Device ->ZeDevice ]
834
+ : this ->Context ->ZeComputeCommandListCache [this ->Device ->ZeDevice ];
831
835
832
836
// Fence had been signalled meaning the associated command-list completed.
833
837
// Reset the fence and put the command list into a cache for reuse in PI
@@ -1048,9 +1052,10 @@ _pi_context::getAvailableCommandList(pi_queue Queue,
1048
1052
_pi_result pi_result = PI_OUT_OF_RESOURCES;
1049
1053
ZeStruct<ze_fence_desc_t > ZeFenceDesc;
1050
1054
1051
- auto &ZeCommandListCache = UseCopyEngine
1052
- ? Queue->Context ->ZeCopyCommandListCache
1053
- : Queue->Context ->ZeComputeCommandListCache ;
1055
+ auto &ZeCommandListCache =
1056
+ UseCopyEngine
1057
+ ? Queue->Context ->ZeCopyCommandListCache [Queue->Device ->ZeDevice ]
1058
+ : Queue->Context ->ZeComputeCommandListCache [Queue->Device ->ZeDevice ];
1054
1059
1055
1060
// Initally, we need to check if a command list has already been created
1056
1061
// on this device that is available for use. If so, then reuse that
@@ -1068,7 +1073,7 @@ _pi_context::getAvailableCommandList(pi_queue Queue,
1068
1073
CommandList->second .InUse = true ;
1069
1074
} else {
1070
1075
// If there is a command list available on this context, but it
1071
- // wasn't yet used in this queue then creat a new entry in this
1076
+ // wasn't yet used in this queue then create a new entry in this
1072
1077
// queue's map to hold the fence and other associated command
1073
1078
// list information.
1074
1079
0 commit comments