fix: hang during appendMemory

Fixed command buffer size estimation in appendMemoryCopy code path.

Related-To: NEO-8293

Signed-off-by: Zhang, Winston <winston.zhang@intel.com>
This commit is contained in:
Zhang, Winston 2023-11-01 19:20:40 +00:00 committed by Compute-Runtime-Automation
parent 43841fd2ef
commit 6d4f79b71b
2 changed files with 24 additions and 1 deletions

View File

@ -551,7 +551,8 @@ ze_result_t CommandListCoreFamilyImmediate<gfxCoreFamily>::appendMemoryCopy(
auto estimatedSize = commonImmediateCommandSize;
if (isCopyOnly()) {
auto nBlits = static_cast<size_t>(std::ceil(size / static_cast<double>(BlitterConstants::maxBlitWidth * BlitterConstants::maxBlitHeight)));
auto nBlits = size / (NEO::BlitCommandsHelper<GfxFamily>::getMaxBlitWidth(this->device->getNEODevice()->getRootDeviceEnvironment()) *
NEO::BlitCommandsHelper<GfxFamily>::getMaxBlitHeight(this->device->getNEODevice()->getRootDeviceEnvironment(), true));
auto sizePerBlit = sizeof(typename GfxFamily::XY_COPY_BLT) + NEO::BlitCommandsHelper<GfxFamily>::estimatePostBlitCommandSize(this->device->getNEODevice()->getRootDeviceEnvironment());
estimatedSize += nBlits * sizePerBlit;
}

View File

@ -607,6 +607,28 @@ HWTEST2_F(AppendMemoryCopy, givenSyncModeImmediateCommandListWhenAppendingMemory
commandList->csr->getInternalAllocationStorage()->getTemporaryAllocations().freeAllGraphicsAllocations(device->getNEODevice());
}
HWTEST2_F(AppendMemoryCopy, givenImmediateCommandListWhenAppendingMemoryCopyThenNBlitsIsSuccessfullyCalculated, IsAtLeastSkl) {
Mock<CommandQueue> cmdQueue;
void *srcPtr = reinterpret_cast<void *>(0x1234);
void *dstPtr = reinterpret_cast<void *>(0x2345);
auto commandList = std::make_unique<WhiteBox<L0::CommandListCoreFamilyImmediate<gfxCoreFamily>>>();
ASSERT_NE(nullptr, commandList);
commandList->device = device;
commandList->cmdQImmediate = &cmdQueue;
commandList->cmdListType = CommandList::CommandListType::TYPE_IMMEDIATE;
commandList->csr = device->getNEODevice()->getDefaultEngine().commandStreamReceiver;
ze_result_t ret = commandList->initialize(device, NEO::EngineGroupType::Copy, 0u);
ASSERT_EQ(ZE_RESULT_SUCCESS, ret);
auto result = commandList->appendMemoryCopy(dstPtr, srcPtr, 8, nullptr, 0, nullptr, false, false);
EXPECT_TRUE(commandList->isCopyOnly());
ASSERT_EQ(ZE_RESULT_SUCCESS, result);
commandList->cmdQImmediate = nullptr;
commandList->csr->getInternalAllocationStorage()->getTemporaryAllocations().freeAllGraphicsAllocations(device->getNEODevice());
}
HWTEST2_F(AppendMemoryCopy, givenCommandListAndHostPointersWhenMemoryCopyCalledThenPipeControlWithDcFlushAdded, IsAtLeastSkl) {
using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;