diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp index a19c34a135..442b9a83c6 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_1.cpp @@ -1082,6 +1082,32 @@ HWTEST2_F(CommandListCreate, GivenGpuHangOnExecutingCommandListsWhenCreatingImme commandList->cmdQImmediate = oldCommandQueue; } +TEST_F(CommandListCreate, givenImmediateCommandListWhenThereIsNoEnoughSpaceForImmediateCommandThenNextCommandBufferIsUsed) { + ze_command_queue_desc_t desc = {}; + desc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS; + ze_result_t returnValue; + std::unique_ptr commandList(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::RenderCompute, returnValue)); + ASSERT_NE(nullptr, commandList); + + commandList->isFlushTaskSubmissionEnabled = true; + + EXPECT_EQ(device, commandList->device); + EXPECT_EQ(CommandList::CommandListType::TYPE_IMMEDIATE, commandList->cmdListType); + EXPECT_NE(nullptr, commandList->cmdQImmediate); + + void *srcPtr = reinterpret_cast(0x1234); + void *dstPtr = reinterpret_cast(0x2345); + + // reduce available cmd buffer size, so next command can't fit in 1st and we need to use 2nd cmd buffer + size_t useSize = commandList->commandContainer.getCommandStream()->getMaxAvailableSpace() - maxImmediateCommandSize + 1; + commandList->commandContainer.getCommandStream()->getSpace(useSize); + EXPECT_EQ(1U, commandList->commandContainer.getCmdBufferAllocations().size()); + + auto result = commandList->appendMemoryCopy(dstPtr, srcPtr, 8, nullptr, 0, nullptr); + ASSERT_EQ(ZE_RESULT_SUCCESS, result); + EXPECT_EQ(2U, commandList->commandContainer.getCmdBufferAllocations().size()); +} + HWTEST2_F(CommandListCreate, GivenGpuHangOnSynchronizingWhenCreatingImmediateCommandListAndWaitingOnEventsThenDeviceLostIsReturned, IsSKL) { ze_command_queue_desc_t desc = {}; desc.mode = ZE_COMMAND_QUEUE_MODE_SYNCHRONOUS; diff --git a/shared/source/command_container/cmdcontainer.cpp b/shared/source/command_container/cmdcontainer.cpp index d9f66adf5f..59881cc4fd 100644 --- a/shared/source/command_container/cmdcontainer.cpp +++ b/shared/source/command_container/cmdcontainer.cpp @@ -236,7 +236,6 @@ IndirectHeap *CommandContainer::getHeapWithRequiredSizeAndAlignment(HeapType hea void CommandContainer::handleCmdBufferAllocations(size_t startIndex) { for (size_t i = startIndex; i < cmdBufferAllocations.size(); i++) { if (this->reusableAllocationList) { - this->device->getMemoryManager()->handleFenceCompletion(cmdBufferAllocations[i]); reusableAllocationList->pushFrontOne(*cmdBufferAllocations[i]); } else { this->device->getMemoryManager()->freeGraphicsMemory(cmdBufferAllocations[i]); diff --git a/shared/source/command_container/cmdcontainer.h b/shared/source/command_container/cmdcontainer.h index 9200431bbb..69097a6397 100644 --- a/shared/source/command_container/cmdcontainer.h +++ b/shared/source/command_container/cmdcontainer.h @@ -35,7 +35,7 @@ enum class ErrorCode { class CommandContainer : public NonCopyableOrMovableClass { public: - static constexpr size_t defaultListCmdBufferSize = MemoryConstants::kiloByte * 256; + static constexpr size_t defaultListCmdBufferSize = 1u * MemoryConstants ::megaByte; static constexpr size_t cmdBufferReservedSize = MemoryConstants::cacheLineSize + CSRequirements::csOverfetchSize; static constexpr size_t totalCmdBufferSize = defaultListCmdBufferSize + cmdBufferReservedSize; diff --git a/shared/test/unit_test/command_container/command_container_tests.cpp b/shared/test/unit_test/command_container/command_container_tests.cpp index 1e50020392..31812d4659 100644 --- a/shared/test/unit_test/command_container/command_container_tests.cpp +++ b/shared/test/unit_test/command_container/command_container_tests.cpp @@ -219,7 +219,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWithAllocsListWhenAllocateAndReset auto cmdBuffer1 = cmdBufferAllocs[1]; cmdContainer->reset(); - EXPECT_EQ(memoryManager->handleFenceCompletionCalled, 1u); + EXPECT_EQ(memoryManager->handleFenceCompletionCalled, 0u); EXPECT_EQ(cmdBufferAllocs.size(), 1u); EXPECT_EQ(cmdBufferAllocs[0], cmdBuffer0); EXPECT_FALSE(allocList.peekIsEmpty()); @@ -231,7 +231,7 @@ TEST_F(CommandContainerTest, givenCmdContainerWithAllocsListWhenAllocateAndReset EXPECT_TRUE(allocList.peekIsEmpty()); cmdContainer.reset(); - EXPECT_EQ(memoryManager->handleFenceCompletionCalled, 3u); + EXPECT_EQ(memoryManager->handleFenceCompletionCalled, 0u); EXPECT_FALSE(allocList.peekIsEmpty()); allocList.freeAllGraphicsAllocations(pDevice); }