From 02e2a13c841a07b8509a214d244c5f323f924b3f Mon Sep 17 00:00:00 2001 From: Katarzyna Cencelewska Date: Thu, 9 May 2024 13:38:31 +0000 Subject: [PATCH] refactor: command container tests Signed-off-by: Katarzyna Cencelewska --- .../unit_tests/sources/cmdlist/test_cmdlist_4.cpp | 5 ++++- .../command_container/command_container_tests.cpp | 15 +++++++++------ .../fixtures/command_container_fixture.h | 1 + 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_4.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_4.cpp index a480c9c622..d6b74c6c1a 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_4.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_4.cpp @@ -1335,7 +1335,10 @@ HWTEST2_F(CommandListCreate, givenStateBaseAddressTrackingStateWhenCommandListCr auto &commandContainer = commandList->getCmdContainer(); auto sshSize = commandContainer.getIndirectHeap(NEO::IndirectHeapType::surfaceState)->getMaxAvailableSpace(); - EXPECT_EQ(NEO::HeapSize::defaultHeapSize, sshSize); + auto &gfxCoreHelper = device->getGfxCoreHelper(); + auto &productHelper = device->getProductHelper(); + auto expectedSshSize = gfxCoreHelper.getDefaultSshSize(productHelper); + EXPECT_EQ(expectedSshSize, sshSize); } { debugManager.flags.EnableStateBaseAddressTracking.set(1); 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 6febcd8d3c..2aa08731cf 100644 --- a/shared/test/unit_test/command_container/command_container_tests.cpp +++ b/shared/test/unit_test/command_container/command_container_tests.cpp @@ -1011,7 +1011,7 @@ HWTEST_F(CommandContainerTest, givenCmdContainerWhenReuseExistingCmdBufferWithAl allocList.freeAllGraphicsAllocations(pDevice); } -TEST_F(CommandContainerTest, GivenCmdContainerWhenContainerIsInitializedThenSurfaceStateIndirectHeapSizeIsCorrect) { +HWTEST_F(CommandContainerTest, GivenCmdContainerWhenContainerIsInitializedThenSurfaceStateIndirectHeapSizeIsCorrect) { MyMockCommandContainer cmdContainer; cmdContainer.initialize(pDevice, nullptr, HeapSize::defaultHeapSize, true, false); auto size = cmdContainer.allocationIndirectHeaps[IndirectHeap::Type::surfaceState]->getUnderlyingBufferSize(); @@ -1634,11 +1634,11 @@ TEST_F(CommandContainerTest, givenCmdContainerAndCsrWhenGetHeapWithRequiredSizeA cmdContainer->fillReusableAllocationLists(); auto &reusableHeapsList = reinterpret_cast(cmdContainer->getHeapHelper())->storageForReuse->getAllocationsForReuse(); - auto baseAlloc = cmdContainer->getIndirectHeapAllocation(HeapType::indirectObject); - auto reusableAlloc = reusableHeapsList.peekHead(); + auto baseAlloc = cmdContainer->getIndirectHeapAllocation(HeapType::surfaceState); + auto reusableAlloc = reusableHeapsList.peekTail(); - cmdContainer->getIndirectHeap(HeapType::indirectObject)->getSpace(cmdContainer->getIndirectHeap(HeapType::indirectObject)->getMaxAvailableSpace()); - auto heap = cmdContainer->getHeapWithRequiredSizeAndAlignment(HeapType::indirectObject, 1024, 1024); + cmdContainer->getIndirectHeap(HeapType::surfaceState)->getSpace(cmdContainer->getIndirectHeap(HeapType::surfaceState)->getMaxAvailableSpace()); + auto heap = cmdContainer->getHeapWithRequiredSizeAndAlignment(HeapType::surfaceState, 1024, 1024); EXPECT_EQ(heap->getGraphicsAllocation(), reusableAlloc); EXPECT_TRUE(reusableHeapsList.peekContains(*baseAlloc)); @@ -1722,10 +1722,13 @@ TEST_F(CommandContainerTest, givenCmdContainerSetToSbaTrackingWhenStateHeapsCons TEST_F(CommandContainerTest, givenCmdContainerSetToSbaTrackingWhenContainerIsInitializedThenSurfaceHeapDefaultValueIsUsed) { constexpr size_t sshDefaultSize = 2 * HeapSize::defaultHeapSize; + auto &productHelper = pDevice->getProductHelper(); + auto &gfxCoreHelper = pDevice->getGfxCoreHelper(); + auto expectedSshSize = gfxCoreHelper.getDefaultSshSize(productHelper); auto cmdContainer = std::make_unique(); cmdContainer->initialize(pDevice, nullptr, sshDefaultSize, true, false); - EXPECT_EQ(HeapSize::defaultHeapSize, cmdContainer->defaultSshSize); + EXPECT_EQ(expectedSshSize, cmdContainer->defaultSshSize); cmdContainer = std::make_unique(); cmdContainer->setStateBaseAddressTracking(true); diff --git a/shared/test/unit_test/fixtures/command_container_fixture.h b/shared/test/unit_test/fixtures/command_container_fixture.h index e51f925804..40e9a15f0b 100644 --- a/shared/test/unit_test/fixtures/command_container_fixture.h +++ b/shared/test/unit_test/fixtures/command_container_fixture.h @@ -19,6 +19,7 @@ class CommandEncodeStatesFixture : public DeviceFixture { public: class MyMockCommandContainer : public CommandContainer { public: + using CommandContainer::allocationIndirectHeaps; using CommandContainer::dirtyHeaps; using CommandContainer::indirectHeaps;