From cbb112ef6dc73e5deba5e5d611b877eed28c409b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Zwoli=C5=84ski?= Date: Tue, 16 Jul 2024 16:32:50 +0000 Subject: [PATCH] fix: adjust tests to enabled global allocator 3/n MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related-To: NEO-7063 Signed-off-by: Fabian ZwoliƄski --- .../source/cmdlist/cmdlist_hw_immediate.inl | 17 ++++--- .../unit_tests/fixtures/cmdlist_fixture.cpp | 4 ++ .../unit_tests/fixtures/device_fixture.cpp | 14 +++++- .../sources/cmdlist/test_cmdlist_4.cpp | 3 ++ .../test_cmdlist_append_launch_kernel_1.cpp | 3 ++ .../cmdlist/test_cmdlist_xehp_and_later.cpp | 45 ++++++++++++++----- .../sources/context/test_context.cpp | 4 ++ .../test_l0_debugger_sba_tracking.cpp | 3 ++ .../xe_hpg_core/test_cmdlist_xe_hpg_core.cpp | 4 ++ 9 files changed, 78 insertions(+), 19 deletions(-) diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl index cf34bf2056..516b3b4522 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl @@ -199,10 +199,12 @@ void CommandListCoreFamilyImmediate::handleHeapsAndResidencyForIm } } ssh = this->commandContainer.getIndirectHeap(NEO::IndirectHeap::Type::surfaceState); - csr->makeResident(*ssh->getGraphicsAllocation()); - if constexpr (streamStatesSupported) { - this->requiredStreamState.stateBaseAddress.setPropertiesBindingTableSurfaceState(ssh->getHeapGpuBase(), ssh->getHeapSizeInPages(), - ssh->getHeapGpuBase(), ssh->getHeapSizeInPages()); + if (ssh) { + csr->makeResident(*ssh->getGraphicsAllocation()); + if constexpr (streamStatesSupported) { + this->requiredStreamState.stateBaseAddress.setPropertiesBindingTableSurfaceState(ssh->getHeapGpuBase(), ssh->getHeapSizeInPages(), + ssh->getHeapGpuBase(), ssh->getHeapSizeInPages()); + } } } @@ -214,9 +216,10 @@ void CommandListCoreFamilyImmediate::handleHeapsAndResidencyForIm } } - UNRECOVERABLE_IF(ssh == nullptr); - sshCpuBaseAddress = ssh->getCpuBase(); - handleDebugSurfaceStateUpdate(ssh); + if (ssh) { + sshCpuBaseAddress = ssh->getCpuBase(); + handleDebugSurfaceStateUpdate(ssh); + } csr->setRequiredScratchSizes(this->getCommandListPerThreadScratchSize(0u), this->getCommandListPerThreadScratchSize(1u)); } diff --git a/level_zero/core/test/unit_tests/fixtures/cmdlist_fixture.cpp b/level_zero/core/test/unit_tests/fixtures/cmdlist_fixture.cpp index 5443069131..14f71eb262 100644 --- a/level_zero/core/test/unit_tests/fixtures/cmdlist_fixture.cpp +++ b/level_zero/core/test/unit_tests/fixtures/cmdlist_fixture.cpp @@ -220,6 +220,10 @@ void CommandListGlobalHeapsFixtureInit::setUp() { } void CommandListGlobalHeapsFixtureInit::setUpParams(int32_t globalHeapMode) { + if (globalHeapMode == static_cast(NEO::HeapAddressModel::globalStateless)) { + debugManager.flags.UseExternalAllocatorForSshAndDsh.set(0); + } + debugManager.flags.SelectCmdListHeapAddressModel.set(globalHeapMode); debugManager.flags.UseImmediateFlushTask.set(0); CommandListStateBaseAddressFixture::setUp(); diff --git a/level_zero/core/test/unit_tests/fixtures/device_fixture.cpp b/level_zero/core/test/unit_tests/fixtures/device_fixture.cpp index f499327cde..6f18a830e3 100644 --- a/level_zero/core/test/unit_tests/fixtures/device_fixture.cpp +++ b/level_zero/core/test/unit_tests/fixtures/device_fixture.cpp @@ -102,8 +102,10 @@ void MultiDeviceFixture::setUp() { debugManager.flags.CreateMultipleRootDevices.set(numRootDevices); debugManager.flags.CreateMultipleSubDevices.set(numSubDevices); auto executionEnvironment = new NEO::ExecutionEnvironment; - executionEnvironment->prepareRootDeviceEnvironments(1u); - executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique(); + executionEnvironment->prepareRootDeviceEnvironments(numRootDevices); + for (size_t i = 0; i < numRootDevices; ++i) { + executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = std::make_unique(); + } auto devices = NEO::DeviceFactory::createDevices(*executionEnvironment); driverHandle = std::make_unique>(); ze_result_t res = driverHandle->initialize(std::move(devices)); @@ -124,6 +126,10 @@ void MultiDeviceFixtureHierarchy::setUp() { debugManager.flags.CreateMultipleRootDevices.set(numRootDevices); debugManager.flags.CreateMultipleSubDevices.set(numSubDevices); auto executionEnvironment = new NEO::ExecutionEnvironment; + executionEnvironment->prepareRootDeviceEnvironments(numRootDevices); + for (size_t i = 0; i < numRootDevices; ++i) { + executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = std::make_unique(); + } executionEnvironment->setExposeSubDevicesAsDevices(exposeSubDevices); auto devices = NEO::DeviceFactory::createDevices(*executionEnvironment); driverHandle = std::make_unique>(); @@ -141,6 +147,10 @@ void MultiDeviceFixtureCombinedHierarchy::setUp() { debugManager.flags.CreateMultipleRootDevices.set(numRootDevices); debugManager.flags.CreateMultipleSubDevices.set(numSubDevices); auto executionEnvironment = new NEO::ExecutionEnvironment; + executionEnvironment->prepareRootDeviceEnvironments(numRootDevices); + for (size_t i = 0; i < numRootDevices; ++i) { + executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = std::make_unique(); + } executionEnvironment->setExposeSubDevicesAsDevices(exposeSubDevices); executionEnvironment->setCombinedDeviceHierarchy(combinedHierarchy); auto devices = NEO::DeviceFactory::createDevices(*executionEnvironment); 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 93fbea7109..9d3dad4ac7 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 @@ -1324,6 +1324,9 @@ HWTEST2_F(HostPointerManagerCommandListTest, givenDebugModeToRegisterAllHostPoin HWTEST2_F(CommandListCreate, givenStateBaseAddressTrackingStateWhenCommandListCreatedThenPlatformSurfaceHeapSizeUsed, IsAtLeastSkl) { DebugManagerStateRestore restorer; + debugManager.flags.UseExternalAllocatorForSshAndDsh.set(0); + neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(); + debugManager.flags.SelectCmdListHeapAddressModel.set(0); ze_result_t returnValue; diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_1.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_1.cpp index 13e80d3a1d..1e76a65e99 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_1.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_append_launch_kernel_1.cpp @@ -7,6 +7,7 @@ #include "shared/source/command_container/command_encoder.h" #include "shared/source/helpers/api_specific_config.h" +#include "shared/source/helpers/bindless_heaps_helper.h" #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/helpers/preamble.h" #include "shared/source/helpers/register_offsets.h" @@ -830,6 +831,8 @@ HWTEST_F(CommandListAppendLaunchKernel, givenKernelWithPrintfAndEventAppendedToI HWTEST_F(CommandListAppendLaunchKernel, WhenAppendingMultipleTimesThenSshIsNotDepletedButReallocated) { DebugManagerStateRestore dbgRestorer; debugManager.flags.UseBindlessMode.set(0); + debugManager.flags.UseExternalAllocatorForSshAndDsh.set(0); + neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(); createKernel(); ze_result_t returnValue; diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_xehp_and_later.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_xehp_and_later.cpp index c042750c9b..704b917e44 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_xehp_and_later.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_xehp_and_later.cpp @@ -45,6 +45,8 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandListTests, whenCommandListIsCreatedThenPCAnd using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; + auto bindlessHeapsHelper = device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[device->getNEODevice()->getRootDeviceIndex()]->bindlessHeapsHelper.get(); + ze_result_t returnValue; std::unique_ptr commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::compute, 0u, returnValue, false)); auto &commandContainer = commandList->getCmdContainer(); @@ -80,16 +82,26 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandListTests, whenCommandListIsCreatedThenPCAnd auto dsh = commandContainer.getIndirectHeap(NEO::HeapType::dynamicState); EXPECT_TRUE(cmdSba->getDynamicStateBaseAddressModifyEnable()); EXPECT_TRUE(cmdSba->getDynamicStateBufferSizeModifyEnable()); - EXPECT_EQ(dsh->getHeapGpuBase(), cmdSba->getDynamicStateBaseAddress()); - EXPECT_EQ(dsh->getHeapSizeInPages(), cmdSba->getDynamicStateBufferSize()); + if (bindlessHeapsHelper) { + EXPECT_EQ(bindlessHeapsHelper->getGlobalHeapsBase(), cmdSba->getDynamicStateBaseAddress()); + EXPECT_EQ(MemoryConstants::sizeOf4GBinPageEntities, cmdSba->getDynamicStateBufferSize()); + } else { + EXPECT_EQ(dsh->getHeapGpuBase(), cmdSba->getDynamicStateBaseAddress()); + EXPECT_EQ(dsh->getHeapSizeInPages(), cmdSba->getDynamicStateBufferSize()); + } } else { EXPECT_FALSE(cmdSba->getDynamicStateBaseAddressModifyEnable()); EXPECT_FALSE(cmdSba->getDynamicStateBufferSizeModifyEnable()); } - auto ssh = commandContainer.getIndirectHeap(NEO::HeapType::surfaceState); - EXPECT_TRUE(cmdSba->getSurfaceStateBaseAddressModifyEnable()); - EXPECT_EQ(ssh->getHeapGpuBase(), cmdSba->getSurfaceStateBaseAddress()); + if (bindlessHeapsHelper) { + EXPECT_TRUE(cmdSba->getBindlessSurfaceStateBaseAddressModifyEnable()); + EXPECT_EQ(bindlessHeapsHelper->getGlobalHeapsBase(), cmdSba->getBindlessSurfaceStateBaseAddress()); + } else { + auto ssh = commandContainer.getIndirectHeap(NEO::HeapType::surfaceState); + EXPECT_TRUE(cmdSba->getSurfaceStateBaseAddressModifyEnable()); + EXPECT_EQ(ssh->getHeapGpuBase(), cmdSba->getSurfaceStateBaseAddress()); + } EXPECT_EQ(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST), cmdSba->getStatelessDataPortAccessMemoryObjectControlState()); @@ -107,6 +119,8 @@ HWTEST2_F(CommandListTests, whenCommandListIsCreatedAndProgramExtendedPipeContro debugManager.flags.DispatchCmdlistCmdBufferPrimary.set(0); debugManager.flags.SelectCmdListHeapAddressModel.set(0); + auto bindlessHeapsHelper = device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[device->getNEODevice()->getRootDeviceIndex()]->bindlessHeapsHelper.get(); + ze_result_t returnValue; std::unique_ptr commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::compute, 0u, returnValue, false)); auto &commandContainer = commandList->getCmdContainer(); @@ -152,15 +166,26 @@ HWTEST2_F(CommandListTests, whenCommandListIsCreatedAndProgramExtendedPipeContro auto dsh = commandContainer.getIndirectHeap(NEO::HeapType::dynamicState); EXPECT_TRUE(cmdSba->getDynamicStateBaseAddressModifyEnable()); EXPECT_TRUE(cmdSba->getDynamicStateBufferSizeModifyEnable()); - EXPECT_EQ(dsh->getHeapGpuBase(), cmdSba->getDynamicStateBaseAddress()); - EXPECT_EQ(dsh->getHeapSizeInPages(), cmdSba->getDynamicStateBufferSize()); + if (bindlessHeapsHelper) { + EXPECT_EQ(bindlessHeapsHelper->getGlobalHeapsBase(), cmdSba->getDynamicStateBaseAddress()); + EXPECT_EQ(MemoryConstants::sizeOf4GBinPageEntities, cmdSba->getDynamicStateBufferSize()); + } else { + EXPECT_EQ(dsh->getHeapGpuBase(), cmdSba->getDynamicStateBaseAddress()); + EXPECT_EQ(dsh->getHeapSizeInPages(), cmdSba->getDynamicStateBufferSize()); + } } else { EXPECT_FALSE(cmdSba->getDynamicStateBaseAddressModifyEnable()); EXPECT_FALSE(cmdSba->getDynamicStateBufferSizeModifyEnable()); } - auto ssh = commandContainer.getIndirectHeap(NEO::HeapType::surfaceState); - EXPECT_TRUE(cmdSba->getSurfaceStateBaseAddressModifyEnable()); - EXPECT_EQ(ssh->getHeapGpuBase(), cmdSba->getSurfaceStateBaseAddress()); + + if (bindlessHeapsHelper) { + EXPECT_TRUE(cmdSba->getBindlessSurfaceStateBaseAddressModifyEnable()); + EXPECT_EQ(bindlessHeapsHelper->getGlobalHeapsBase(), cmdSba->getBindlessSurfaceStateBaseAddress()); + } else { + auto ssh = commandContainer.getIndirectHeap(NEO::HeapType::surfaceState); + EXPECT_TRUE(cmdSba->getSurfaceStateBaseAddressModifyEnable()); + EXPECT_EQ(ssh->getHeapGpuBase(), cmdSba->getSurfaceStateBaseAddress()); + } EXPECT_EQ(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST), cmdSba->getStatelessDataPortAccessMemoryObjectControlState()); diff --git a/level_zero/core/test/unit_tests/sources/context/test_context.cpp b/level_zero/core/test/unit_tests/sources/context/test_context.cpp index 4c7647c6c3..e8f78c5f5f 100644 --- a/level_zero/core/test/unit_tests/sources/context/test_context.cpp +++ b/level_zero/core/test/unit_tests/sources/context/test_context.cpp @@ -384,6 +384,10 @@ struct ContextHostAllocTests : public ::testing::Test { debugManager.flags.CreateMultipleRootDevices.set(numRootDevices); auto executionEnvironment = new NEO::ExecutionEnvironment; + executionEnvironment->prepareRootDeviceEnvironments(numRootDevices); + for (size_t i = 0; i < numRootDevices; ++i) { + executionEnvironment->rootDeviceEnvironments[i]->memoryOperationsInterface = std::make_unique(); + } auto devices = NEO::DeviceFactory::createDevices(*executionEnvironment); driverHandle = std::make_unique(); ze_result_t res = driverHandle->initialize(std::move(devices)); diff --git a/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_sba_tracking.cpp b/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_sba_tracking.cpp index ccdf4fa7bb..9b17d698a8 100644 --- a/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_sba_tracking.cpp +++ b/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_sba_tracking.cpp @@ -6,6 +6,7 @@ */ #include "shared/source/gen_common/reg_configs_common.h" +#include "shared/source/helpers/bindless_heaps_helper.h" #include "shared/source/helpers/register_offsets.h" #include "shared/source/indirect_heap/indirect_heap.h" #include "shared/test/common/cmd_parse/gen_cmd_parse.h" @@ -285,6 +286,8 @@ HWTEST2_F(L0DebuggerTest, givenDebuggingEnabledWhenNonCopyCommandListIsInititali debugManager.flags.EnableStateBaseAddressTracking.set(0); debugManager.flags.DispatchCmdlistCmdBufferPrimary.set(0); debugManager.flags.SelectCmdListHeapAddressModel.set(0); + debugManager.flags.UseExternalAllocatorForSshAndDsh.set(0); + neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(); size_t usedSpaceBefore = 0; ze_result_t returnValue; diff --git a/level_zero/core/test/unit_tests/xe_hpg_core/test_cmdlist_xe_hpg_core.cpp b/level_zero/core/test/unit_tests/xe_hpg_core/test_cmdlist_xe_hpg_core.cpp index a3c84fca10..9da26fd5b6 100644 --- a/level_zero/core/test/unit_tests/xe_hpg_core/test_cmdlist_xe_hpg_core.cpp +++ b/level_zero/core/test/unit_tests/xe_hpg_core/test_cmdlist_xe_hpg_core.cpp @@ -6,6 +6,7 @@ */ #include "shared/source/gmm_helper/gmm_helper.h" +#include "shared/source/helpers/bindless_heaps_helper.h" #include "shared/source/helpers/l3_range.h" #include "shared/source/helpers/register_offsets.h" #include "shared/source/helpers/state_base_address.h" @@ -35,6 +36,9 @@ HWTEST2_F(CommandListCreate, WhenCreatingCommandListThenBindingTablePoolAllocAdd debugManager.flags.EnableStateBaseAddressTracking.set(0); debugManager.flags.DispatchCmdlistCmdBufferPrimary.set(0); + debugManager.flags.UseExternalAllocatorForSshAndDsh.set(0); + device->getNEODevice()->getExecutionEnvironment()->rootDeviceEnvironments[device->getNEODevice()->getRootDeviceIndex()]->bindlessHeapsHelper.reset(); + ze_result_t returnValue; std::unique_ptr commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::compute, 0u, returnValue, false)); auto &commandContainer = commandList->getCmdContainer();