@@ -881,6 +881,10 @@ ze_command_list_handle_t CHIPQueueLevel0::getCmdListImm() {
881881 return ZeCmdListImm_;
882882}
883883
884+ ze_command_list_handle_t CHIPQueueLevel0::getCmdListImmCopy () {
885+ return ZeCmdListImmCopy_;
886+ }
887+
884888std::shared_ptr<CHIPEventLevel0> CHIPContextLevel0::getEventFromPool () {
885889 // go through all pools and try to get an allocated event
886890 LOCK (ContextMtx); // Context::EventPools
@@ -936,41 +940,27 @@ Borrowed<FencedCmdList> CHIPContextLevel0::getCmdListReg() {
936940}
937941
938942CHIPQueueLevel0::CHIPQueueLevel0 (CHIPDeviceLevel0 *ChipDev)
939- : CHIPQueueLevel0(ChipDev, 0 , L0_DEFAULT_QUEUE_PRIORITY,
940- LevelZeroQueueType::Compute) {}
943+ : CHIPQueueLevel0(ChipDev, 0 , L0_DEFAULT_QUEUE_PRIORITY) {}
941944
942945CHIPQueueLevel0::CHIPQueueLevel0 (CHIPDeviceLevel0 *ChipDev,
943946 chipstar::QueueFlags Flags)
944- : CHIPQueueLevel0(ChipDev, Flags, L0_DEFAULT_QUEUE_PRIORITY,
945- LevelZeroQueueType::Compute) {}
947+ : CHIPQueueLevel0(ChipDev, Flags, L0_DEFAULT_QUEUE_PRIORITY) {}
946948
947949CHIPQueueLevel0::CHIPQueueLevel0 (CHIPDeviceLevel0 *ChipDev,
948950 chipstar::QueueFlags Flags, int Priority)
949- : CHIPQueueLevel0(ChipDev, Flags, Priority, LevelZeroQueueType::Compute) {}
950-
951- CHIPQueueLevel0::CHIPQueueLevel0 (CHIPDeviceLevel0 *ChipDev,
952- chipstar::QueueFlags Flags, int Priority,
953- LevelZeroQueueType TheType)
954951 : Queue(ChipDev, Flags, Priority), ChipDevLz_(ChipDev),
955952 ChipCtxLz_(static_cast <CHIPContextLevel0 *>(ChipDev->getContext ())) {
956953 logTrace (" CHIPQueueLevel0() {}" , (void *)this );
957954 ChipDevLz_ = ChipDev;
958955 auto Ctx = ChipDevLz_->getContext ();
959956 ChipCtxLz_ = (CHIPContextLevel0 *)Ctx;
960957
961- if (TheType == Compute) {
962- QueueProperties_ = ChipDev->getComputeQueueProps ();
963- QueueDescriptor_ = ChipDev->getNextComputeQueueDesc (Priority);
964- CommandListDesc_ = ChipDev->getCommandListComputeDesc ();
965- } else if (TheType == Copy) {
966- QueueProperties_ = ChipDev->getCopyQueueProps ();
967- QueueDescriptor_ = ChipDev->getNextCopyQueueDesc (Priority);
968- CommandListDesc_ = ChipDev->getCommandListCopyDesc ();
969-
970- } else {
971- CHIPERR_LOG_AND_ABORT (" Unknown queue type requested" );
972- }
973- QueueType = TheType;
958+ QueueProperties_ = ChipDev->getComputeQueueProps ();
959+ QueueDescriptor_ = ChipDev->getNextComputeQueueDesc (Priority);
960+ CommandListDesc_ = ChipDev->getCommandListComputeDesc ();
961+ QueuePropertiesCopy_ = ChipDev->getCopyQueueProps ();
962+ QueueDescriptorCopy_ = ChipDev->getNextCopyQueueDesc (Priority);
963+ CommandListDescCopy_ = ChipDev->getCommandListCopyDesc ();
974964
975965 SharedBuf_ =
976966 ChipCtxLz_->allocateImpl (32 , 8 , hipMemoryType::hipMemoryTypeUnified);
@@ -1011,6 +1001,14 @@ void CHIPQueueLevel0::initializeCmdListImm() {
10111001 zeStatus = zeCommandListCreateImmediate (ZeCtx_, ZeDev_, &QueueDescriptor_,
10121002 &ZeCmdListImm_);
10131003 CHIPERR_CHECK_LOG_AND_THROW_TABLE (zeCommandListCreateImmediate);
1004+
1005+ if (QueueDescriptorCopy_.ordinal < 0 ) {
1006+ zeStatus = zeCommandListCreateImmediate (
1007+ ZeCtx_, ZeDev_, &QueueDescriptorCopy_, &ZeCmdListImmCopy_);
1008+ CHIPERR_CHECK_LOG_AND_THROW_TABLE (zeCommandListCreateImmediate);
1009+ } else {
1010+ ZeCmdListImmCopy_ = ZeCmdListImm_;
1011+ }
10141012}
10151013
10161014void CHIPDeviceLevel0::initializeQueueGroupProperties () {
@@ -1109,8 +1107,6 @@ ze_command_queue_desc_t CHIPDeviceLevel0::getQueueDesc_(int Priority) {
11091107
11101108ze_command_queue_desc_t
11111109CHIPDeviceLevel0::getNextComputeQueueDesc (int Priority) {
1112-
1113- assert (ComputeQueueGroupOrdinal_ > -1 );
11141110 ze_command_queue_desc_t CommandQueueComputeDesc = getQueueDesc_ (Priority);
11151111 CommandQueueComputeDesc.ordinal = ComputeQueueGroupOrdinal_;
11161112
@@ -1123,14 +1119,15 @@ CHIPDeviceLevel0::getNextComputeQueueDesc(int Priority) {
11231119}
11241120
11251121ze_command_queue_desc_t CHIPDeviceLevel0::getNextCopyQueueDesc (int Priority) {
1126- assert (CopyQueueGroupOrdinal_ > -1 );
11271122 ze_command_queue_desc_t CommandQueueCopyDesc = getQueueDesc_ (Priority);
11281123 CommandQueueCopyDesc.ordinal = CopyQueueGroupOrdinal_;
11291124
11301125 auto MaxQueues = CopyQueueProperties_.numQueues ;
1131- LOCK (NextQueueIndexMtx_); // CHIPDeviceLevel0::NextCopyQueueIndex_
1132- CommandQueueCopyDesc.index = NextCopyQueueIndex_;
1133- NextCopyQueueIndex_ = (NextCopyQueueIndex_ + 1 ) % MaxQueues;
1126+ if (MaxQueues > 0 ) {
1127+ LOCK (NextQueueIndexMtx_); // CHIPDeviceLevel0::NextCopyQueueIndex_
1128+ CommandQueueCopyDesc.index = NextCopyQueueIndex_;
1129+ NextCopyQueueIndex_ = (NextCopyQueueIndex_ + 1 ) % MaxQueues;
1130+ }
11341131
11351132 return CommandQueueCopyDesc;
11361133}
@@ -1222,7 +1219,7 @@ CHIPQueueLevel0::memFillAsyncImpl(void *Dst, size_t Size, const void *Pattern,
12221219 }
12231220
12241221 LOCK (CommandListMtx);
1225- auto CommandList = this ->getCmdListImm ();
1222+ auto CommandList = this ->getCmdListImmCopy ();
12261223 // The application must not call this function from
12271224 // simultaneous threads with the same command list handle.
12281225 // Done via LOCK(CommandListMtx)
@@ -1270,7 +1267,7 @@ CHIPQueueLevel0::memCopy3DAsyncImpl(void *Dst, size_t Dpitch, size_t Dspitch,
12701267 SrcRegion.height = Height;
12711268 SrcRegion.depth = Depth;
12721269 LOCK (CommandListMtx);
1273- auto CommandList = this ->getCmdListImm ();
1270+ auto CommandList = this ->getCmdListImmCopy ();
12741271 // The application must not call this function from
12751272 // simultaneous threads with the same command list handle.
12761273 // Done via LOCK(CommandListMtx)
@@ -1453,7 +1450,7 @@ CHIPQueueLevel0::memCopyAsyncImpl(void *Dst, const void *Src, size_t Size,
14531450 std::shared_ptr<chipstar::Event> MemCopyEvent =
14541451 static_cast <CHIPBackendLevel0 *>(Backend)->createEventShared (ChipCtxZe);
14551452 LOCK (CommandListMtx);
1456- auto CommandList = this ->getCmdListImm ();
1453+ auto CommandList = this ->getCmdListImmCopy ();
14571454 // The application must not call this function from simultaneous threads with
14581455 // the same command list handle
14591456 // Done via LOCK(CommandListMtx)
0 commit comments