diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl index 17d37b832d..9d55c5d3fa 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl @@ -687,7 +687,7 @@ ze_result_t CommandListCoreFamilyImmediate::appendMemoryCopy( return subCmdList->CommandListCoreFamily::appendMemoryCopy(dstptrParam, srcptrParam, sizeParam, hSignalEventParam, 0u, nullptr, memoryCopyParams); }; - ret = static_cast(this->device)->bcsSplit->appendSplitCall(this, dstptr, srcptr, size, hSignalEvent, numWaitEvents, phWaitEvents, true, memoryCopyParams.relaxedOrderingDispatch, direction, splitCall); + ret = static_cast(this->device)->bcsSplit->appendSplitCall(this, dstptr, srcptr, size, hSignalEvent, numWaitEvents, phWaitEvents, true, memoryCopyParams.relaxedOrderingDispatch, direction, estimatedSize, splitCall); } else if (this->isValidForStagingTransfer(dstptr, srcptr, size, numWaitEvents > 0)) { return this->appendStagingMemoryCopy(dstptr, srcptr, size, hSignalEvent, memoryCopyParams); } else { @@ -749,7 +749,7 @@ ze_result_t CommandListCoreFamilyImmediate::appendMemoryCopyRegio hSignalEventParam, 0u, nullptr, memoryCopyParams); }; - ret = static_cast(this->device)->bcsSplit->appendSplitCall(this, dstRegion->originX, srcRegion->originX, dstRegion->width, hSignalEvent, numWaitEvents, phWaitEvents, true, memoryCopyParams.relaxedOrderingDispatch, direction, splitCall); + ret = static_cast(this->device)->bcsSplit->appendSplitCall(this, dstRegion->originX, srcRegion->originX, dstRegion->width, hSignalEvent, numWaitEvents, phWaitEvents, true, memoryCopyParams.relaxedOrderingDispatch, direction, estimatedSize, splitCall); } else { ret = CommandListCoreFamily::appendMemoryCopyRegion(dstPtr, dstRegion, dstPitch, dstSlicePitch, srcPtr, srcRegion, srcPitch, srcSlicePitch, @@ -822,7 +822,7 @@ ze_result_t CommandListCoreFamilyImmediate::appendPageFaultCopy(N return subCmdList->CommandListCoreFamily::appendSignalEvent(hSignalEventParam, false); }; - ret = static_cast(this->device)->bcsSplit->appendSplitCall(this, dstAddress, srcAddress, size, nullptr, 0u, nullptr, false, relaxedOrdering, direction, splitCall); + ret = static_cast(this->device)->bcsSplit->appendSplitCall(this, dstAddress, srcAddress, size, nullptr, 0u, nullptr, false, relaxedOrdering, direction, commonImmediateCommandSize, splitCall); } else { ret = CommandListCoreFamily::appendPageFaultCopy(dstAllocation, srcAllocation, size, flushHost); } diff --git a/level_zero/core/source/device/bcs_split.h b/level_zero/core/source/device/bcs_split.h index 987a98f36e..ac365be76e 100644 --- a/level_zero/core/source/device/bcs_split.h +++ b/level_zero/core/source/device/bcs_split.h @@ -76,6 +76,7 @@ struct BcsSplit { bool performMigration, bool hasRelaxedOrderingDependencies, NEO::TransferDirection direction, + size_t estimatedCmdBufferSize, std::function *, T, K, size_t, ze_event_handle_t)> appendCall) { ze_result_t result = ZE_RESULT_SUCCESS; @@ -109,6 +110,8 @@ struct BcsSplit { for (size_t i = 0; i < cmdListsForSplit.size(); i++) { auto subCmdList = static_cast *>(cmdListsForSplit[i]); + subCmdList->checkAvailableSpace(numWaitEvents, hasRelaxedOrderingDependencies, estimatedCmdBufferSize, false); + if (barrierRequired) { auto barrierEventHandle = this->events.barrier[markerEventIndex]->toHandle(); subCmdList->addEventsToCmdList(1u, &barrierEventHandle, nullptr, hasRelaxedOrderingDependencies, false, true, false, false); diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_blit.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_blit.cpp index 5343913f6a..d56d657a19 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_blit.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_blit.cpp @@ -1261,6 +1261,31 @@ HWTEST2_F(AggregatedBcsSplitTests, givenMarkerEventWhenCheckingCompletionThenRes context->freeMem(ptr); } +HWTEST2_F(AggregatedBcsSplitTests, givenFullCmdBufferWhenAppendCalledThenAllocateNewBuffer, IsAtLeastXeHpcCore) { + auto ptr = allocHostMem(); + + auto cmdListHw = static_cast> *>(cmdList.get()); + + cmdListHw->appendMemoryCopy(ptr, ptr, copySize, nullptr, 0, nullptr, copyParams); + + std::vector cmdBuffers; + + for (auto cmdList : bcsSplit->cmdLists) { + auto cmdStream = cmdList->getCmdContainer().getCommandStream(); + cmdStream->getSpace(cmdStream->getAvailableSpace()); + cmdBuffers.push_back(cmdStream->getCpuBase()); + } + + cmdListHw->appendMemoryCopy(ptr, ptr, copySize, nullptr, 0, nullptr, copyParams); + + for (size_t i = 0; i < bcsSplit->cmdLists.size(); i++) { + auto cmdStream = bcsSplit->cmdLists[i]->getCmdContainer().getCommandStream(); + EXPECT_NE(cmdBuffers[i], cmdStream->getCpuBase()); + } + + context->freeMem(ptr); +} + struct MultiRootAggregatedBcsSplitTests : public AggregatedBcsSplitTests { void SetUp() override { expectedNumRootDevices = 2;