From 0844ca0ac89c305b7807f2c03afdcf7b500c4859 Mon Sep 17 00:00:00 2001 From: Mateusz Hoppe Date: Mon, 5 Jun 2023 16:53:29 +0000 Subject: [PATCH] refactor: cleanup getBindlessMode() usage - getGlobalBindlessHeapConfiguration() should be used to choose global alloctor for SSH - remove not needed and incorrect unit tests - remove not needed branches - bindless mode controls bindless compilation only Related-To: NEO-7063 Signed-off-by: Mateusz Hoppe --- level_zero/core/source/cmdlist/cmdlist_hw.inl | 2 +- .../source/cmdlist/cmdlist_hw_immediate.inl | 29 ++- .../cmdqueue/cmdqueue_hw_skl_to_tgllp.inl | 2 +- .../cmdqueue_xe_hp_core_and_later.inl | 36 +--- .../sources/cmdlist/test_cmdlist_1.cpp | 79 ------- .../sources/cmdqueue/test_cmdqueue_1.cpp | 6 +- .../sources/cmdqueue/test_cmdqueue_2.cpp | 2 +- .../sources/cmdqueue/test_cmdqueue_3.cpp | 12 +- .../cmdqueue/test_cmdqueue_debugger.cpp | 123 +++++++---- .../xe_hpg_core/dg2/test_cmdqueue_dg2.cpp | 89 +------- opencl/source/kernel/kernel.cpp | 10 +- .../kernel/kernel_arg_buffer_tests.cpp | 18 +- .../kernel/kernel_image_arg_tests.cpp | 7 +- .../source/command_container/cmdcontainer.cpp | 5 +- .../command_container/command_encoder.inl | 24 +-- .../command_encoder_bdw_and_later.inl | 26 +-- .../command_encoder_xehp_and_later.inl | 5 +- ...cratch_space_controller_xehp_and_later.cpp | 2 +- shared/source/device/root_device.cpp | 2 +- .../source/memory_manager/memory_manager.cpp | 2 +- .../command_container_tests.cpp | 8 +- .../encoders/test_encode_dispatch_kernel.cpp | 200 +----------------- .../unit_test/encoders/test_encode_states.cpp | 12 +- .../helpers/bindless_heaps_helper_tests.cpp | 8 +- ...h_space_controler_xehp_and_later_tests.cpp | 10 +- 25 files changed, 187 insertions(+), 532 deletions(-) diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index 5082362c6a..6603c9843c 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -81,7 +81,7 @@ CommandListCoreFamily::~CommandListCoreFamily() { template void CommandListCoreFamily::postInitComputeSetup() { - if (!NEO::ApiSpecificConfig::getBindlessMode() && !this->stateBaseAddressTracking) { + if (!this->stateBaseAddressTracking) { if (!this->isFlushTaskSubmissionEnabled) { programStateBaseAddress(commandContainer, false); } diff --git a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl index c34deccfb5..4b724fb6f1 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw_immediate.inl @@ -150,25 +150,20 @@ NEO::CompletionStamp CommandListCoreFamilyImmediate::flushRegular NEO::IndirectHeap *dsh = nullptr; NEO::IndirectHeap *ssh = nullptr; - if (!NEO::ApiSpecificConfig::getBindlessMode()) { - if (this->cmdListHeapAddressModel == NEO::HeapAddressModel::GlobalStateless) { - ssh = this->csr->getGlobalStatelessHeap(); - } else if (this->immediateCmdListHeapSharing) { - auto &sshReserveConfig = this->commandContainer.getSurfaceStateHeapReserve(); - if (sshReserveConfig.indirectHeapReservation->getGraphicsAllocation()) { - ssh = sshReserveConfig.indirectHeapReservation; - } - auto &dshReserveConfig = this->commandContainer.getDynamicStateHeapReserve(); - if (this->dynamicHeapRequired && dshReserveConfig.indirectHeapReservation->getGraphicsAllocation()) { - dsh = dshReserveConfig.indirectHeapReservation; - } - } else { - dsh = this->commandContainer.getIndirectHeap(NEO::IndirectHeap::Type::DYNAMIC_STATE); - ssh = this->commandContainer.getIndirectHeap(NEO::IndirectHeap::Type::SURFACE_STATE); + if (this->cmdListHeapAddressModel == NEO::HeapAddressModel::GlobalStateless) { + ssh = this->csr->getGlobalStatelessHeap(); + } else if (this->immediateCmdListHeapSharing) { + auto &sshReserveConfig = this->commandContainer.getSurfaceStateHeapReserve(); + if (sshReserveConfig.indirectHeapReservation->getGraphicsAllocation()) { + ssh = sshReserveConfig.indirectHeapReservation; + } + auto &dshReserveConfig = this->commandContainer.getDynamicStateHeapReserve(); + if (this->dynamicHeapRequired && dshReserveConfig.indirectHeapReservation->getGraphicsAllocation()) { + dsh = dshReserveConfig.indirectHeapReservation; } } else { - dsh = this->device->getNEODevice()->getBindlessHeapsHelper()->getHeap(NEO::BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH); - ssh = this->device->getNEODevice()->getBindlessHeapsHelper()->getHeap(NEO::BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH); + dsh = this->commandContainer.getIndirectHeap(NEO::IndirectHeap::Type::DYNAMIC_STATE); + ssh = this->commandContainer.getIndirectHeap(NEO::IndirectHeap::Type::SURFACE_STATE); } if (this->device->getL0Debugger()) { diff --git a/level_zero/core/source/cmdqueue/cmdqueue_hw_skl_to_tgllp.inl b/level_zero/core/source/cmdqueue/cmdqueue_hw_skl_to_tgllp.inl index 0ce220ccb1..71c786427f 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue_hw_skl_to_tgllp.inl +++ b/level_zero/core/source/cmdqueue/cmdqueue_hw_skl_to_tgllp.inl @@ -44,7 +44,7 @@ void CommandQueueHw::programStateBaseAddress(uint64_t gsba, bool if (streamProperties != nullptr) { sbaProperties = &streamProperties->stateBaseAddress; } else { - useGlobalSshAndDsh = NEO::ApiSpecificConfig::getBindlessMode(); + useGlobalSshAndDsh = NEO::ApiSpecificConfig::getGlobalBindlessHeapConfiguration(); if (useGlobalSshAndDsh) { globalHeapsBase = neoDevice->getBindlessHeapsHelper()->getGlobalHeapsBase(); } diff --git a/level_zero/core/source/cmdqueue/cmdqueue_xe_hp_core_and_later.inl b/level_zero/core/source/cmdqueue/cmdqueue_xe_hp_core_and_later.inl index 02b19f32a6..0be13319d8 100644 --- a/level_zero/core/source/cmdqueue/cmdqueue_xe_hp_core_and_later.inl +++ b/level_zero/core/source/cmdqueue/cmdqueue_xe_hp_core_and_later.inl @@ -28,12 +28,11 @@ void CommandQueueHw::programStateBaseAddress(uint64_t gsba, bool uint32_t rootDeviceIndex = neoDevice->getRootDeviceIndex(); auto csr = this->getCsr(); - bool dispatchCommand = false; bool multiOsContextCapable = device->isImplicitScalingCapable(); bool isRcs = csr->isRcs(); auto isDebuggerActive = neoDevice->isDebuggerActive() || neoDevice->getDebugger() != nullptr; bool setGeneralStateBaseAddress = false; - bool useGlobalHeapsBaseAddress = false; + bool useGlobalSshAndDsh = false; uint64_t globalHeapsBase = 0; uint64_t indirectObjectStateBaseAddress = 0; @@ -45,20 +44,8 @@ void CommandQueueHw::programStateBaseAddress(uint64_t gsba, bool auto l1CachePolicyData = csr->getStoredL1CachePolicy(); if (streamProperties != nullptr) { - dispatchCommand = true; sbaProperties = &streamProperties->stateBaseAddress; - } else { - if (NEO::ApiSpecificConfig::getBindlessMode()) { - globalHeapsBase = neoDevice->getBindlessHeapsHelper()->getGlobalHeapsBase(); - indirectObjectStateBaseAddress = neoDevice->getMemoryManager()->getInternalHeapBaseAddress(rootDeviceIndex, useLocalMemoryForIndirectHeap); - dispatchCommand = true; - setGeneralStateBaseAddress = true; - useGlobalHeapsBaseAddress = true; - } - } - - if (dispatchCommand) { auto gmmHelper = neoDevice->getGmmHelper(); NEO::EncodeWA::addPipeControlBeforeStateBaseAddress(commandStream, neoDevice->getRootDeviceEnvironment(), isRcs, csr->getDcFlushSupport()); @@ -81,7 +68,7 @@ void CommandQueueHw::programStateBaseAddress(uint64_t gsba, bool NEO::MemoryCompressionState::NotApplicable, // memoryCompressionState true, // setInstructionStateBaseAddress setGeneralStateBaseAddress, // setGeneralStateBaseAddress - useGlobalHeapsBaseAddress, // useGlobalHeapsBaseAddress + useGlobalSshAndDsh, // useGlobalHeapsBaseAddress multiOsContextCapable, // isMultiOsContextCapable false, // useGlobalAtomics false, // areMultipleSubDevicesInContext @@ -97,19 +84,11 @@ void CommandQueueHw::programStateBaseAddress(uint64_t gsba, bool commandStream, sbaCmd, true); - if (sbaProperties) { - if (sbaProperties->bindingTablePoolBaseAddress.value != NEO::StreamProperty64::initValue) { - NEO::StateBaseAddressHelper::programBindingTableBaseAddress( - commandStream, - static_cast(sbaProperties->bindingTablePoolBaseAddress.value), - static_cast(sbaProperties->bindingTablePoolSize.value), - gmmHelper); - } - } else { - auto heap = neoDevice->getBindlessHeapsHelper()->getHeap(NEO::BindlessHeapsHelper::GLOBAL_SSH); + if (sbaProperties->bindingTablePoolBaseAddress.value != NEO::StreamProperty64::initValue) { NEO::StateBaseAddressHelper::programBindingTableBaseAddress( commandStream, - *heap, + static_cast(sbaProperties->bindingTablePoolBaseAddress.value), + static_cast(sbaProperties->bindingTablePoolSize.value), gmmHelper); } } @@ -136,9 +115,6 @@ inline size_t CommandQueueHw::estimateStateBaseAddressCmdDispatch template size_t CommandQueueHw::estimateStateBaseAddressCmdSize() { - if (NEO::ApiSpecificConfig::getBindlessMode()) { - return estimateStateBaseAddressCmdDispatchSize(true); - } return 0; } @@ -160,7 +136,7 @@ void CommandQueueHw::handleScratchSpace(NEO::HeapContainer &sshHe scratchController->programHeaps(sshHeaps, offsetIndex, perThreadScratchSpaceSize, perThreadPrivateScratchSize, csr->peekTaskCount(), csr->getOsContext(), gsbaState, frontEndState); } - if (NEO::ApiSpecificConfig::getBindlessMode()) { + if (NEO::ApiSpecificConfig::getGlobalBindlessHeapConfiguration()) { scratchController->programBindlessSurfaceStateForScratch(device->getNEODevice()->getBindlessHeapsHelper(), perThreadScratchSpaceSize, perThreadPrivateScratchSize, csr->peekTaskCount(), csr->getOsContext(), gsbaState, frontEndState, csr); } 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 d1c821b001..fb9800e3de 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 @@ -2201,64 +2201,6 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandListCreate, whenCommandListIsCreatedThenPCAnd EXPECT_EQ(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER), cmdSba->getStatelessDataPortAccessMemoryObjectControlState()); } -HWCMDTEST_F(IGFX_GEN8_CORE, CommandListCreate, whenBindlessModeEnabledWhenCommandListIsCreatedThenStateBaseAddressCmdsIsNotAdded) { - DebugManagerStateRestore dbgRestorer; - DebugManager.flags.UseBindlessMode.set(1); - DebugManager.flags.DispatchCmdlistCmdBufferPrimary.set(0); - - using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; - using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; - - ze_result_t returnValue; - std::unique_ptr commandList(CommandList::create(productFamily, device, NEO::EngineGroupType::RenderCompute, 0u, returnValue)); - auto &commandContainer = commandList->getCmdContainer(); - - ASSERT_NE(nullptr, commandContainer.getCommandStream()); - auto usedSpaceBefore = commandContainer.getCommandStream()->getUsed(); - - auto result = commandList->close(); - ASSERT_EQ(ZE_RESULT_SUCCESS, result); - - auto usedSpaceAfter = commandContainer.getCommandStream()->getUsed(); - ASSERT_GT(usedSpaceAfter, usedSpaceBefore); - - GenCmdList cmdList; - ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( - cmdList, ptrOffset(commandContainer.getCommandStream()->getCpuBase(), 0), usedSpaceAfter)); - - auto itor = find(cmdList.begin(), cmdList.end()); - ASSERT_EQ(cmdList.end(), itor); -} - -HWCMDTEST_F(IGFX_GEN8_CORE, CommandListCreate, whenBindlessModeEnabledWhenCommandListImmediateIsCreatedThenStateBaseAddressCmdsIsNotAdded) { - DebugManagerStateRestore dbgRestorer; - DebugManager.flags.UseBindlessMode.set(1); - using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; - using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; - - ze_command_queue_desc_t desc = {}; - desc.mode = ZE_COMMAND_QUEUE_MODE_ASYNCHRONOUS; - ze_result_t returnValue; - std::unique_ptr commandList(CommandList::createImmediate(productFamily, device, &desc, false, NEO::EngineGroupType::RenderCompute, returnValue)); - auto &commandContainer = commandList->getCmdContainer(); - - ASSERT_NE(nullptr, commandContainer.getCommandStream()); - auto usedSpaceBefore = commandContainer.getCommandStream()->getUsed(); - - auto result = commandList->close(); - ASSERT_EQ(ZE_RESULT_SUCCESS, result); - - auto usedSpaceAfter = commandContainer.getCommandStream()->getUsed(); - ASSERT_GT(usedSpaceAfter, usedSpaceBefore); - - GenCmdList cmdList; - ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( - cmdList, ptrOffset(commandContainer.getCommandStream()->getCpuBase(), 0), usedSpaceAfter)); - - auto itor = find(cmdList.begin(), cmdList.end()); - ASSERT_EQ(cmdList.end(), itor); -} - HWTEST_F(CommandListCreate, givenCommandListWithCopyOnlyWhenCreatedThenStateBaseAddressCmdIsNotProgrammedAndHeapIsNotAllocated) { using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; @@ -2331,27 +2273,6 @@ HWTEST_F(CommandListCreate, whenCommandListIsResetThenContainsStatelessUncachedR EXPECT_FALSE(commandList->getContainsStatelessUncachedResource()); } -HWTEST_F(CommandListCreate, givenBindlessModeEnabledWhenCommandListsResetThenSbaNotReloaded) { - DebugManagerStateRestore dbgRestorer; - DebugManager.flags.UseBindlessMode.set(1); - using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; - ze_result_t returnValue; - std::unique_ptr commandList(CommandList::create(productFamily, - device, - NEO::EngineGroupType::Compute, - 0u, - returnValue)); - EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); - returnValue = commandList->reset(); - auto usedAfter = commandList->getCmdContainer().getCommandStream()->getUsed(); - EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); - GenCmdList cmdList; - ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( - cmdList, ptrOffset(commandList->getCmdContainer().getCommandStream()->getCpuBase(), 0), usedAfter)); - - auto itor = find(cmdList.begin(), cmdList.end()); - ASSERT_EQ(cmdList.end(), itor); -} HWTEST_F(CommandListCreate, givenBindlessModeDisabledWhenCommandListsResetThenSbaReloaded) { DebugManagerStateRestore dbgRestorer; DebugManager.flags.UseBindlessMode.set(0); diff --git a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_1.cpp b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_1.cpp index 0d323b06fd..e415e498e3 100644 --- a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_1.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_1.cpp @@ -1291,9 +1291,9 @@ HWTEST2_F(CommandQueueDestroy, givenCommandQueueAndCommandListWithSshAndPrivateS alignedFree(alloc); } -HWTEST2_F(CommandQueueDestroy, givenCommandQueueAndCommandListWithWhenBindlessEnabledThenHeapContainerIsEmpty, IsAtLeastSkl) { +HWTEST2_F(ExecuteCommandListTests, givenBindlessHelperWhenCommandListIsExecutedOnCommandQueueThenHeapContainerIsEmpty, IsAtLeastSkl) { DebugManagerStateRestore dbgRestorer; - DebugManager.flags.UseBindlessMode.set(1); + DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(1); auto bindlessHeapsHelper = std::make_unique(neoDevice->getMemoryManager(), neoDevice->getNumGenericSubDevices() > 1, neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()); neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(bindlessHeapsHelper.release()); ze_command_queue_desc_t desc = {}; @@ -1310,6 +1310,8 @@ HWTEST2_F(CommandQueueDestroy, givenCommandQueueAndCommandListWithWhenBindlessEn commandQueue->executeCommandLists(1, &commandListHandle, nullptr, false); EXPECT_EQ(commandQueue->mockHeapContainer.size(), 0u); + EXPECT_EQ(commandQueue->heapContainer.size(), 0u); + commandQueue->destroy(); commandList->destroy(); } diff --git a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_2.cpp b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_2.cpp index 1fc5b42d82..385823d5e1 100644 --- a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_2.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_2.cpp @@ -918,7 +918,7 @@ HWTEST2_F(CommandQueueScratchTests, givenCommandQueueWhenHandleScratchSpaceAndHe HWTEST2_F(CommandQueueScratchTests, givenCommandQueueWhenBindlessEnabledThenHandleScratchSpaceCallsProgramBindlessSurfaceStateForScratch, Platforms) { DebugManagerStateRestore restorer; - DebugManager.flags.UseBindlessMode.set(1); + DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(1); class MockScratchSpaceControllerXeHPAndLater : public NEO::ScratchSpaceControllerXeHPAndLater { public: bool programHeapsCalled = false; diff --git a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_3.cpp b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_3.cpp index 93eae8df4c..2ea3fd1873 100644 --- a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_3.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_3.cpp @@ -157,10 +157,10 @@ HWTEST2_F(CommandQueueProgramSBATest, whenProgrammingStateBaseAddressWithStatele } HWTEST2_F(CommandQueueProgramSBATest, - givenBindlessModeEnabledWhenProgrammingStateBaseAddressThenBindlessBaseAddressAndSizeAreSet, IsAtLeastSkl) { + givenGlobalSshWhenProgrammingStateBaseAddressThenBindlessBaseAddressAndSizeAreSet, CommandQueueSBASupport) { using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; DebugManagerStateRestore dbgRestorer; - DebugManager.flags.UseBindlessMode.set(1); + DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(1); auto bindlessHeapsHelper = std::make_unique(neoDevice->getMemoryManager(), neoDevice->getNumGenericSubDevices() > 1, neoDevice->getRootDeviceIndex(), neoDevice->getDeviceBitfield()); MockBindlesHeapsHelper *bindlessHeapsHelperPtr = bindlessHeapsHelper.get(); neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(bindlessHeapsHelper.release()); @@ -1021,18 +1021,14 @@ HWTEST_F(CommandQueueTest, givenCommandQueueWhenPerformMigrationIsTrueAndAllocat commandQueue->destroy(); } -HWTEST2_F(CommandQueueTest, givenBindlessEnabledWhenEstimateStateBaseAddressCmdSizeCalledThenReturnedSizeOfSBAAndPCAnd3DBindingTablePoolPool, IsAtLeastXeHpCore) { +HWTEST2_F(CommandQueueTest, givenBindlessEnabledWhenEstimateStateBaseAddressCmdSizeCalledThenZeroSizeIsReturned, IsAtLeastXeHpCore) { DebugManagerStateRestore restorer; DebugManager.flags.UseBindlessMode.set(1); - using GfxFamily = typename NEO::GfxFamilyMapper::GfxFamily; - using STATE_BASE_ADDRESS = typename GfxFamily::STATE_BASE_ADDRESS; - using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL; - using _3DSTATE_BINDING_TABLE_POOL_ALLOC = typename GfxFamily::_3DSTATE_BINDING_TABLE_POOL_ALLOC; ze_command_queue_desc_t desc = {}; auto csr = std::unique_ptr(neoDevice->createCommandStreamReceiver()); auto commandQueue = std::make_unique>(device, csr.get(), &desc); auto size = commandQueue->estimateStateBaseAddressCmdSize(); - auto expectedSize = sizeof(STATE_BASE_ADDRESS) + sizeof(PIPE_CONTROL) + sizeof(_3DSTATE_BINDING_TABLE_POOL_ALLOC); + auto expectedSize = 0u; EXPECT_EQ(size, expectedSize); } diff --git a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_debugger.cpp b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_debugger.cpp index 5176a2bf73..cd3b171d50 100644 --- a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_debugger.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue_debugger.cpp @@ -14,6 +14,9 @@ #include "level_zero/core/source/cmdqueue/cmdqueue_hw.h" #include "level_zero/core/source/device/device.h" +#include "level_zero/core/test/unit_tests/mocks/mock_cmdlist.h" +#include "level_zero/core/test/unit_tests/mocks/mock_cmdqueue.h" +#include "level_zero/core/test/unit_tests/mocks/mock_kernel.h" #include "level_zero/core/test/unit_tests/sources/debugger/l0_debugger_fixture.h" #include "test_traits_common.h" @@ -22,69 +25,105 @@ namespace L0 { namespace ult { using L0CmdQueueDebuggerTest = Test; -HWTEST2_F(L0CmdQueueDebuggerTest, givenDebuggingEnabledAndRequiredGsbaWhenBindlessModeEnabledThenProgramGsbaWritesToSbaTrackingBuffer, IsAtLeastXeHpCore) { +HWTEST_F(L0CmdQueueDebuggerTest, givenDebuggingEnabledWhenCmdListRequiringSbaProgrammingExecutedThenProgramSbaWritesToSbaTrackingBufferForNonInternalQueues) { DebugManagerStateRestore restorer; - DebugManager.flags.UseBindlessMode.set(1); + DebugManager.flags.EnableStateBaseAddressTracking.set(1); + using MI_STORE_DATA_IMM = typename FamilyType::MI_STORE_DATA_IMM; using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; - neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(), - neoDevice->getNumGenericSubDevices() > 1, - neoDevice->getRootDeviceIndex(), - neoDevice->getDeviceBitfield()); - ze_command_queue_desc_t queueDesc = {}; - ze_result_t returnValue; - auto cmdQ = CommandQueue::create(productFamily, device, neoDevice->getDefaultEngine().commandStreamReceiver, &queueDesc, false, false, false, returnValue); - ASSERT_NE(nullptr, cmdQ); + bool internalQueueMode[] = {false, true}; - auto cmdQHw = static_cast *>(cmdQ); - StackVec buffer(4096); - NEO::LinearStream cmdStream(buffer.begin(), buffer.size()); + for (auto internalQueue : internalQueueMode) { + ze_command_queue_desc_t queueDesc = {}; + ze_result_t returnValue; + auto cmdQ = CommandQueue::create(productFamily, device, neoDevice->getDefaultEngine().commandStreamReceiver, &queueDesc, false, internalQueue, false, returnValue); + ASSERT_NE(nullptr, cmdQ); - auto usedSpaceBefore = cmdStream.getUsed(); + auto commandQueue = whiteboxCast(cmdQ); - cmdQHw->programStateBaseAddress(0u, false, cmdStream, true, nullptr); + Mock kernel; + std::unique_ptr commandList(CommandList::create(NEO::defaultHwInfo->platform.eProductFamily, device, NEO::EngineGroupType::RenderCompute, 0u, returnValue)); + ze_group_count_t groupCount{1, 1, 1}; + NEO::LinearStream &cmdStream = commandQueue->commandStream; - auto usedSpaceAfter = cmdStream.getUsed(); - ASSERT_GT(usedSpaceAfter, usedSpaceBefore); + auto usedSpaceBefore = cmdStream.getUsed(); - GenCmdList cmdList; - ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( - cmdList, ptrOffset(cmdStream.getCpuBase(), 0), usedSpaceAfter)); + CmdListKernelLaunchParams launchParams = {}; + auto result = commandList->appendLaunchKernel(kernel.toHandle(), &groupCount, nullptr, 0, nullptr, launchParams, false); + EXPECT_EQ(ZE_RESULT_SUCCESS, result); + commandList->close(); - auto pcItor = find(cmdList.begin(), cmdList.end()); - ASSERT_NE(cmdList.end(), pcItor); + ze_command_list_handle_t commandListHandle = commandList->toHandle(); + const uint32_t numCommandLists = 1u; - auto sbaItor = find(pcItor, cmdList.end()); - ASSERT_NE(cmdList.end(), sbaItor); - auto cmdSba = genCmdCast(*sbaItor); + result = cmdQ->executeCommandLists(numCommandLists, &commandListHandle, nullptr, true); + ASSERT_EQ(ZE_RESULT_SUCCESS, result); - auto sdiItor = find(sbaItor, cmdList.end()); - ASSERT_NE(cmdList.end(), sdiItor); - auto cmdSdi = genCmdCast(*sdiItor); + auto usedSpaceAfter = cmdStream.getUsed(); + ASSERT_GT(usedSpaceAfter, usedSpaceBefore); - auto gmmHelper = neoDevice->getGmmHelper(); - uint64_t gsbaGpuVa = gmmHelper->canonize(cmdSba->getGeneralStateBaseAddress()); + GenCmdList cmdList; + ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( + cmdList, ptrOffset(cmdStream.getCpuBase(), 0), usedSpaceAfter)); - EXPECT_EQ(static_cast(gsbaGpuVa & 0x0000FFFFFFFFULL), cmdSdi->getDataDword0()); - EXPECT_EQ(static_cast(gsbaGpuVa >> 32), cmdSdi->getDataDword1()); + auto pcItor = find(cmdList.begin(), cmdList.end()); + ASSERT_NE(cmdList.end(), pcItor); - auto expectedGpuVa = gmmHelper->decanonize(device->getL0Debugger()->getSbaTrackingGpuVa()) + offsetof(NEO::SbaTrackedAddresses, generalStateBaseAddress); - EXPECT_EQ(expectedGpuVa, cmdSdi->getAddress()); - cmdQ->destroy(); + auto sbaItor = find(pcItor, cmdList.end()); + ASSERT_NE(cmdList.end(), sbaItor); + auto cmdSba = genCmdCast(*sbaItor); + + auto sdiItor = find(sbaItor, cmdList.end()); + + if (!internalQueue) { + ASSERT_NE(cmdList.end(), sdiItor); + auto cmdSdi = genCmdCast(*sdiItor); + + auto gmmHelper = neoDevice->getGmmHelper(); + + std::vector baseAddresses; + baseAddresses.push_back(gmmHelper->canonize(cmdSba->getGeneralStateBaseAddress())); + baseAddresses.push_back(gmmHelper->canonize(cmdSba->getSurfaceStateBaseAddress())); + baseAddresses.push_back(gmmHelper->canonize(cmdSba->getDynamicStateBaseAddress())); + baseAddresses.push_back(gmmHelper->canonize(cmdSba->getInstructionBaseAddress())); + + std::vector offsets; + offsets.push_back(offsetof(NEO::SbaTrackedAddresses, generalStateBaseAddress)); + offsets.push_back(offsetof(NEO::SbaTrackedAddresses, surfaceStateBaseAddress)); + offsets.push_back(offsetof(NEO::SbaTrackedAddresses, dynamicStateBaseAddress)); + offsets.push_back(offsetof(NEO::SbaTrackedAddresses, instructionBaseAddress)); + + bool addressFound = false; + for (size_t i = 0; i < baseAddresses.size(); i++) { + + if (baseAddresses[i] != 0) { + EXPECT_EQ(static_cast(baseAddresses[i] & 0x0000FFFFFFFFULL), cmdSdi->getDataDword0()); + EXPECT_EQ(static_cast(baseAddresses[i] >> 32), cmdSdi->getDataDword1()); + + auto expectedGpuVa = gmmHelper->decanonize(device->getL0Debugger()->getSbaTrackingGpuVa()) + offsets[i]; + EXPECT_EQ(expectedGpuVa, cmdSdi->getAddress()); + addressFound = true; + break; + } + } + EXPECT_TRUE(addressFound); + } else { + EXPECT_EQ(cmdList.end(), sdiItor); + } + cmdQ->destroy(); + + neoDevice->getDefaultEngine().commandStreamReceiver->getStreamProperties().stateBaseAddress.resetState(); + } } -HWTEST2_F(L0CmdQueueDebuggerTest, givenDebuggingEnabledAndRequiredGsbaWhenInternalCommandQueueThenProgramGsbaDoesNotWritesToSbaTrackingBuffer, IsAtLeastXeHpCore) { - DebugManagerStateRestore restorer; - DebugManager.flags.UseBindlessMode.set(1); +using IsBetweenGen9AndGen12lp = IsWithinGfxCore; +HWTEST2_F(L0CmdQueueDebuggerTest, givenDebuggingEnabledAndRequiredGsbaWhenInternalCommandQueueThenProgramGsbaDoesNotWritesToSbaTrackingBuffer, IsBetweenGen9AndGen12lp) { using MI_STORE_DATA_IMM = typename FamilyType::MI_STORE_DATA_IMM; using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; - neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(), - neoDevice->getNumGenericSubDevices() > 1, - neoDevice->getRootDeviceIndex(), - neoDevice->getDeviceBitfield()); + ze_command_queue_desc_t queueDesc = {}; ze_result_t returnValue; auto cmdQ = CommandQueue::create(productFamily, device, neoDevice->getDefaultEngine().commandStreamReceiver, &queueDesc, false, true, false, returnValue); diff --git a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_cmdqueue_dg2.cpp b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_cmdqueue_dg2.cpp index c99f940e84..0bb6430392 100644 --- a/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_cmdqueue_dg2.cpp +++ b/level_zero/core/test/unit_tests/xe_hpg_core/dg2/test_cmdqueue_dg2.cpp @@ -18,102 +18,17 @@ namespace L0 { namespace ult { using CommandQueueTestDG2 = Test; -HWTEST2_F(CommandQueueTestDG2, givenBindlessEnabledWhenEstimateStateBaseAddressCmdSizeCalledOnDG2ThenReturnedSizeOfSBAAndPCAnd3DBindingTablePoolPool, IsDG2) { +HWTEST2_F(CommandQueueTestDG2, givenBindlessEnabledWhenEstimateStateBaseAddressCmdSizeCalledOnDG2ThenReturnedSizeIsZero, IsDG2) { DebugManagerStateRestore restorer; DebugManager.flags.UseBindlessMode.set(1); - using GfxFamily = typename NEO::GfxFamilyMapper::GfxFamily; - using STATE_BASE_ADDRESS = typename GfxFamily::STATE_BASE_ADDRESS; - using PIPE_CONTROL = typename GfxFamily::PIPE_CONTROL; - using _3DSTATE_BINDING_TABLE_POOL_ALLOC = typename GfxFamily::_3DSTATE_BINDING_TABLE_POOL_ALLOC; ze_command_queue_desc_t desc = {}; auto csr = std::unique_ptr(neoDevice->createCommandStreamReceiver()); auto commandQueue = std::make_unique>(device, csr.get(), &desc); auto size = commandQueue->estimateStateBaseAddressCmdSize(); - auto expectedSize = sizeof(STATE_BASE_ADDRESS) + sizeof(PIPE_CONTROL) + sizeof(_3DSTATE_BINDING_TABLE_POOL_ALLOC); - - auto &productHelper = neoDevice->getProductHelper(); - auto &hwInfo = neoDevice->getHardwareInfo(); - - if (productHelper.isAdditionalStateBaseAddressWARequired(hwInfo)) { - expectedSize += sizeof(STATE_BASE_ADDRESS); - } + auto expectedSize = 0u; EXPECT_EQ(size, expectedSize); } -HWTEST2_F(CommandQueueTestDG2, givenBindlessEnabledWhenProgramStateBaseAddressCalledOnDG2ThenProgramCorrectL1CachePolicy, IsDG2) { - DebugManagerStateRestore restorer; - DebugManager.flags.UseBindlessMode.set(1); - - neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(), - neoDevice->getNumGenericSubDevices() > 1, - neoDevice->getRootDeviceIndex(), - neoDevice->getDeviceBitfield()); - - using GfxFamily = typename NEO::GfxFamilyMapper::GfxFamily; - using STATE_BASE_ADDRESS = typename GfxFamily::STATE_BASE_ADDRESS; - ze_command_queue_desc_t desc = {}; - auto &csr = neoDevice->getGpgpuCommandStreamReceiver(); - auto commandQueue = std::make_unique>(device, &csr, &desc); - void *linearStreamBuffer = alignedMalloc(4096, 0x1000); - { - NEO::LinearStream cmdStream(linearStreamBuffer, 4096); - auto usedSpaceBefore = cmdStream.getUsed(); - commandQueue->programStateBaseAddress(0, false, cmdStream, false, nullptr); - auto usedSpaceAfter = cmdStream.getUsed(); - ASSERT_GT(usedSpaceAfter, usedSpaceBefore); - - GenCmdList cmdList; - ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( - cmdList, ptrOffset(cmdStream.getCpuBase(), 0), usedSpaceAfter)); - - auto sbaItor = find(cmdList.begin(), cmdList.end()); - ASSERT_NE(cmdList.end(), sbaItor); - auto cmdSba = genCmdCast(*sbaItor); - - EXPECT_EQ(STATE_BASE_ADDRESS::L1_CACHE_POLICY_WB, cmdSba->getL1CachePolicyL1CacheControl()); - } - { - const_cast(device->getDeviceInfo()).debuggerActive = true; - NEO::LinearStream cmdStream(linearStreamBuffer, 4096); - auto usedSpaceBefore = cmdStream.getUsed(); - commandQueue->programStateBaseAddress(0, false, cmdStream, false, nullptr); - auto usedSpaceAfter = cmdStream.getUsed(); - ASSERT_GT(usedSpaceAfter, usedSpaceBefore); - - GenCmdList cmdList; - ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( - cmdList, ptrOffset(cmdStream.getCpuBase(), 0), usedSpaceAfter)); - - auto sbaItor = find(cmdList.begin(), cmdList.end()); - ASSERT_NE(cmdList.end(), sbaItor); - auto cmdSba = genCmdCast(*sbaItor); - - EXPECT_EQ(STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, cmdSba->getL1CachePolicyL1CacheControl()); - } - { - auto debugger = MockDebuggerL0Hw::allocate(neoDevice); - neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[0]->debugger.reset(debugger); - const_cast(device->getDeviceInfo()).debuggerActive = false; - NEO::LinearStream cmdStream(linearStreamBuffer, 4096); - auto usedSpaceBefore = cmdStream.getUsed(); - commandQueue->programStateBaseAddress(0, false, cmdStream, false, nullptr); - auto usedSpaceAfter = cmdStream.getUsed(); - ASSERT_GT(usedSpaceAfter, usedSpaceBefore); - - GenCmdList cmdList; - ASSERT_TRUE(FamilyType::PARSE::parseCommandBuffer( - cmdList, ptrOffset(cmdStream.getCpuBase(), 0), usedSpaceAfter)); - - auto sbaItor = find(cmdList.begin(), cmdList.end()); - ASSERT_NE(cmdList.end(), sbaItor); - auto cmdSba = genCmdCast(*sbaItor); - - EXPECT_EQ(STATE_BASE_ADDRESS::L1_CACHE_POLICY_WBP, cmdSba->getL1CachePolicyL1CacheControl()); - } - - alignedFree(linearStreamBuffer); -} - } // namespace ult } // namespace L0 diff --git a/opencl/source/kernel/kernel.cpp b/opencl/source/kernel/kernel.cpp index ebba305c4d..7bc0b982e9 100644 --- a/opencl/source/kernel/kernel.cpp +++ b/opencl/source/kernel/kernel.cpp @@ -1537,7 +1537,11 @@ cl_int Kernel::setArgBuffer(uint32_t argIndex, disableL3, isAuxTranslationKernel, arg.isReadOnly(), pClDevice->getDevice(), kernelInfo.kernelDescriptor.kernelAttributes.flags.useGlobalAtomics, areMultipleSubDevicesInContext()); } else if (isValidOffset(argAsPtr.bindless)) { - buffer->setArgStateful(patchBindlessSurfaceState(graphicsAllocation, argAsPtr.bindless), forceNonAuxMode, + auto &gfxCoreHelper = getDevice().getGfxCoreHelper(); + auto surfaceStateSize = gfxCoreHelper.getRenderSurfaceStateSize(); + auto surfaceState = ptrOffset(getSurfaceStateHeap(), surfaceStateSize * argIndex); + + buffer->setArgStateful(surfaceState, forceNonAuxMode, disableL3, isAuxTranslationKernel, arg.isReadOnly(), pClDevice->getDevice(), kernelInfo.kernelDescriptor.kernelAttributes.flags.useGlobalAtomics, areMultipleSubDevicesInContext()); } @@ -1651,7 +1655,9 @@ cl_int Kernel::setArgImageWithMipLevel(uint32_t argIndex, void *surfaceState = nullptr; if (isValidOffset(argAsImg.bindless)) { - surfaceState = patchBindlessSurfaceState(pImage->getGraphicsAllocation(rootDeviceIndex), argAsImg.bindless); + auto &gfxCoreHelper = getDevice().getGfxCoreHelper(); + auto surfaceStateSize = gfxCoreHelper.getRenderSurfaceStateSize(); + surfaceState = ptrOffset(getSurfaceStateHeap(), surfaceStateSize * argIndex); } else { DEBUG_BREAK_IF(isUndefinedOffset(argAsImg.bindful)); surfaceState = ptrOffset(getSurfaceStateHeap(), argAsImg.bindful); diff --git a/opencl/test/unit_test/kernel/kernel_arg_buffer_tests.cpp b/opencl/test/unit_test/kernel/kernel_arg_buffer_tests.cpp index 608213eccf..9c9dd91fd2 100644 --- a/opencl/test/unit_test/kernel/kernel_arg_buffer_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_arg_buffer_tests.cpp @@ -777,7 +777,7 @@ class KernelArgBufferFixtureBindless : public KernelArgBufferFixture { typedef Test KernelArgBufferTestBindless; -HWTEST_F(KernelArgBufferTestBindless, givenUsedBindlessBuffersWhenPatchingSurfaceStateOffsetsThenCorrectOffsetIsPatchedInCrossThreadData) { +HWTEST_F(KernelArgBufferTestBindless, givenUsedBindlessBuffersWhenSettingKernelArgThenOffsetInCrossThreadDataIsNotPatched) { using DataPortBindlessSurfaceExtendedMessageDescriptor = typename FamilyType::DataPortBindlessSurfaceExtendedMessageDescriptor; auto patchLocation = reinterpret_cast(ptrOffset(pKernel->getCrossThreadData(), bindlessOffset)); *patchLocation = 0xdead; @@ -785,6 +785,22 @@ HWTEST_F(KernelArgBufferTestBindless, givenUsedBindlessBuffersWhenPatchingSurfac cl_mem memObj = pBuffer; retVal = pKernel->setArg(0, sizeof(memObj), &memObj); + EXPECT_EQ(0xdeadu, *patchLocation); +} + +HWTEST_F(KernelArgBufferTestBindless, givenBindlessBuffersWhenPatchBindlessOffsetCalledThenBindlessOffsetToSurfaceStateWrittenInCrossThreadData) { + + pClDevice->getExecutionEnvironment()->rootDeviceEnvironments[pClDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pClDevice->getMemoryManager(), + pClDevice->getNumGenericSubDevices() > 1, + pClDevice->getRootDeviceIndex(), + pClDevice->getDeviceBitfield()); + + using DataPortBindlessSurfaceExtendedMessageDescriptor = typename FamilyType::DataPortBindlessSurfaceExtendedMessageDescriptor; + auto patchLocation = reinterpret_cast(ptrOffset(pKernel->getCrossThreadData(), bindlessOffset)); + *patchLocation = 0xdead; + + pKernel->patchBindlessSurfaceState(pBuffer->getGraphicsAllocation(pClDevice->getRootDeviceIndex()), bindlessOffset); + EXPECT_NE(0xdeadu, *patchLocation); } diff --git a/opencl/test/unit_test/kernel/kernel_image_arg_tests.cpp b/opencl/test/unit_test/kernel/kernel_image_arg_tests.cpp index 542889792b..e8d40dd8f9 100644 --- a/opencl/test/unit_test/kernel/kernel_image_arg_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_image_arg_tests.cpp @@ -357,6 +357,7 @@ TEST_F(KernelImageArgTest, givenNoCacheFlushImageWhenSettingAsArgThenExpectAlloc class KernelImageArgTestBindless : public KernelImageArgTest { public: void SetUp() override { + DebugManager.flags.UseBindlessMode.set(1); DebugManager.flags.UseBindlessMode.set(1); KernelImageArgTest::SetUp(); @@ -368,10 +369,10 @@ class KernelImageArgTestBindless : public KernelImageArgTest { KernelImageArgTest::TearDown(); } DebugManagerStateRestore restorer; - const CrossThreadDataOffset bindlessOffset = 0x10; + const CrossThreadDataOffset bindlessOffset = 0x0; }; -HWTEST_F(KernelImageArgTestBindless, givenUsedBindlessImagesWhenPatchingSurfaceStateOffsetsThenCorrectOffsetIsPatchedInCrossThreadData) { +HWTEST_F(KernelImageArgTestBindless, givenUsedBindlessImagesWhenSettingKernelArgThenOffsetInCrossThreadDataIsNotPatched) { using DataPortBindlessSurfaceExtendedMessageDescriptor = typename FamilyType::DataPortBindlessSurfaceExtendedMessageDescriptor; auto patchLocation = reinterpret_cast(ptrOffset(pKernel->getCrossThreadData(), bindlessOffset)); *patchLocation = 0xdead; @@ -379,5 +380,5 @@ HWTEST_F(KernelImageArgTestBindless, givenUsedBindlessImagesWhenPatchingSurfaceS cl_mem memObj = image.get(); pKernel->setArg(0, sizeof(memObj), &memObj); - EXPECT_NE(0xdeadu, *patchLocation); + EXPECT_EQ(0xdeadu, *patchLocation); } \ No newline at end of file diff --git a/shared/source/command_container/cmdcontainer.cpp b/shared/source/command_container/cmdcontainer.cpp index ff5c3406c5..c87ba06f11 100644 --- a/shared/source/command_container/cmdcontainer.cpp +++ b/shared/source/command_container/cmdcontainer.cpp @@ -12,6 +12,7 @@ #include "shared/source/command_stream/linear_stream.h" #include "shared/source/device/device.h" #include "shared/source/helpers/api_specific_config.h" +#include "shared/source/helpers/bindless_heaps_helper.h" #include "shared/source/helpers/debug_helpers.h" #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/helpers/heap_helper.h" @@ -120,10 +121,12 @@ CommandContainer::ErrorCode CommandContainer::initialize(Device *device, Allocat } size_t heapSize = getHeapSize(heapType); + allocationIndirectHeaps[i] = heapHelper->getHeapAllocation(i, heapSize, defaultHeapAllocationAlignment, device->getRootDeviceIndex()); + if (!allocationIndirectHeaps[i]) { return ErrorCode::OUT_OF_DEVICE_MEMORY; } @@ -557,7 +560,7 @@ bool CommandContainer::skipHeapAllocationCreation(HeapType heapType) { } const auto &hardwareInfo = this->device->getHardwareInfo(); - bool skipCreation = NEO::ApiSpecificConfig::getBindlessMode() || + bool skipCreation = (NEO::ApiSpecificConfig::getGlobalBindlessHeapConfiguration() && IndirectHeap::Type::SURFACE_STATE == heapType) || this->immediateCmdListSharedHeap(heapType) || (!hardwareInfo.capabilityTable.supportsImages && IndirectHeap::Type::DYNAMIC_STATE == heapType) || (this->heapAddressModel != HeapAddressModel::PrivateHeaps); diff --git a/shared/source/command_container/command_encoder.inl b/shared/source/command_container/command_encoder.inl index 407f3be37b..1c5f92afe4 100644 --- a/shared/source/command_container/command_encoder.inl +++ b/shared/source/command_container/command_encoder.inl @@ -54,7 +54,7 @@ uint32_t EncodeStates::copySamplerState(IndirectHeap *dsh, dsh->align(EncodeStates::alignIndirectStatePointer); uint32_t borderColorOffsetInDsh = 0; - if (!ApiSpecificConfig::getBindlessMode()) { + if (!ApiSpecificConfig::getGlobalBindlessHeapConfiguration()) { borderColorOffsetInDsh = static_cast(dsh->getUsed()); auto borderColor = dsh->getSpace(borderColorSize); @@ -544,21 +544,17 @@ template void *EncodeDispatchKernel::getInterfaceDescriptor(CommandContainer &container, IndirectHeap *childDsh, uint32_t &iddOffset) { if (container.nextIddInBlockRef() == container.getNumIddPerBlock()) { - if (ApiSpecificConfig::getBindlessMode()) { - container.getDevice()->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH)->align(EncodeStates::alignInterfaceDescriptorData); - container.setIddBlock(container.getDevice()->getBindlessHeapsHelper()->getSpaceInHeap(sizeof(INTERFACE_DESCRIPTOR_DATA) * container.getNumIddPerBlock(), BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH)); + + void *heapPointer = nullptr; + size_t heapSize = sizeof(INTERFACE_DESCRIPTOR_DATA) * container.getNumIddPerBlock(); + if (childDsh != nullptr) { + childDsh->align(EncodeStates::alignInterfaceDescriptorData); + heapPointer = childDsh->getSpace(heapSize); } else { - void *heapPointer = nullptr; - size_t heapSize = sizeof(INTERFACE_DESCRIPTOR_DATA) * container.getNumIddPerBlock(); - if (childDsh != nullptr) { - childDsh->align(EncodeStates::alignInterfaceDescriptorData); - heapPointer = childDsh->getSpace(heapSize); - } else { - container.getIndirectHeap(HeapType::DYNAMIC_STATE)->align(EncodeStates::alignInterfaceDescriptorData); - heapPointer = container.getHeapSpaceAllowGrow(HeapType::DYNAMIC_STATE, heapSize); - } - container.setIddBlock(heapPointer); + container.getIndirectHeap(HeapType::DYNAMIC_STATE)->align(EncodeStates::alignInterfaceDescriptorData); + heapPointer = container.getHeapSpaceAllowGrow(HeapType::DYNAMIC_STATE, heapSize); } + container.setIddBlock(heapPointer); container.nextIddInBlockRef() = 0; } diff --git a/shared/source/command_container/command_encoder_bdw_and_later.inl b/shared/source/command_container/command_encoder_bdw_and_later.inl index 5c1339aa72..05a132c0ff 100644 --- a/shared/source/command_container/command_encoder_bdw_and_later.inl +++ b/shared/source/command_container/command_encoder_bdw_and_later.inl @@ -124,14 +124,10 @@ void EncodeDispatchKernel::encode(CommandContainer &container, EncodeDis if (kernelDescriptor.payloadMappings.samplerTable.numSamplers > 0) { auto dsHeap = args.dynamicStateHeap; if (dsHeap == nullptr) { - if (!ApiSpecificConfig::getBindlessMode()) { - dsHeap = container.getIndirectHeap(HeapType::DYNAMIC_STATE); - auto dshSizeRequired = NEO::EncodeDispatchKernel::getSizeRequiredDsh(kernelDescriptor, container.getNumIddPerBlock()); - if (dsHeap->getAvailableSpace() <= dshSizeRequired) { - dsHeap = container.getHeapWithRequiredSizeAndAlignment(HeapType::DYNAMIC_STATE, dsHeap->getMaxAvailableSpace(), NEO::EncodeDispatchKernel::getDefaultDshAlignment()); - } - } else { - dsHeap = args.device->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::GLOBAL_DSH); + dsHeap = container.getIndirectHeap(HeapType::DYNAMIC_STATE); + auto dshSizeRequired = NEO::EncodeDispatchKernel::getSizeRequiredDsh(kernelDescriptor, container.getNumIddPerBlock()); + if (dsHeap->getAvailableSpace() <= dshSizeRequired) { + dsHeap = container.getHeapWithRequiredSizeAndAlignment(HeapType::DYNAMIC_STATE, dsHeap->getMaxAvailableSpace(), NEO::EncodeDispatchKernel::getDefaultDshAlignment()); } } UNRECOVERABLE_IF(!dsHeap); @@ -259,10 +255,6 @@ void EncodeDispatchKernel::encode(CommandContainer &container, EncodeDis cmd.setPredicateEnable(args.isPredicate); - if (ApiSpecificConfig::getBindlessMode()) { - container.getResidencyContainer().push_back(args.device->getBindlessHeapsHelper()->getHeap(NEO::BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH)->getGraphicsAllocation()); - } - auto threadGroupCount = cmd.getThreadGroupIdXDimension() * cmd.getThreadGroupIdYDimension() * cmd.getThreadGroupIdZDimension(); EncodeDispatchKernel::adjustInterfaceDescriptorData(idd, *args.device, hwInfo, threadGroupCount, kernelDescriptor.kernelAttributes.numGrfRequired, cmd); @@ -304,11 +296,7 @@ void EncodeMediaInterfaceDescriptorLoad::encode(CommandContainer &contai if (childDsh != nullptr) { heapBase = childDsh->getCpuBase(); } else { - if (ApiSpecificConfig::getBindlessMode()) { - heapBase = container.getDevice()->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::GLOBAL_DSH)->getGraphicsAllocation()->getUnderlyingBuffer(); - } else { - heapBase = container.getIndirectHeap(HeapType::DYNAMIC_STATE)->getCpuBase(); - } + heapBase = container.getIndirectHeap(HeapType::DYNAMIC_STATE)->getCpuBase(); } auto mediaStateFlush = container.getCommandStream()->getSpaceForCmd(); @@ -316,10 +304,6 @@ void EncodeMediaInterfaceDescriptorLoad::encode(CommandContainer &contai auto iddOffset = static_cast(ptrDiff(container.getIddBlock(), heapBase)); - iddOffset += ApiSpecificConfig::getBindlessMode() ? static_cast(container.getDevice()->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::GLOBAL_DSH)->getGraphicsAllocation()->getGpuAddress() - - container.getDevice()->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::GLOBAL_DSH)->getGraphicsAllocation()->getGpuBaseAddress()) - : 0; - MEDIA_INTERFACE_DESCRIPTOR_LOAD cmd = Family::cmdInitMediaInterfaceDescriptorLoad; cmd.setInterfaceDescriptorDataStartAddress(iddOffset); cmd.setInterfaceDescriptorTotalLength(sizeof(INTERFACE_DESCRIPTOR_DATA) * container.getNumIddPerBlock()); diff --git a/shared/source/command_container/command_encoder_xehp_and_later.inl b/shared/source/command_container/command_encoder_xehp_and_later.inl index 5e7a880c9d..cc25773c03 100644 --- a/shared/source/command_container/command_encoder_xehp_and_later.inl +++ b/shared/source/command_container/command_encoder_xehp_and_later.inl @@ -144,7 +144,7 @@ void EncodeDispatchKernel::encode(CommandContainer &container, EncodeDis if (kernelDescriptor.payloadMappings.samplerTable.numSamplers > 0) { auto dsHeap = args.dynamicStateHeap; if (dsHeap == nullptr) { - dsHeap = ApiSpecificConfig::getBindlessMode() ? args.device->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::GLOBAL_DSH) : container.getIndirectHeap(HeapType::DYNAMIC_STATE); + dsHeap = container.getIndirectHeap(HeapType::DYNAMIC_STATE); } UNRECOVERABLE_IF(!dsHeap); @@ -154,9 +154,6 @@ void EncodeDispatchKernel::encode(CommandContainer &container, EncodeDis kernelDescriptor.payloadMappings.samplerTable.numSamplers, kernelDescriptor.payloadMappings.samplerTable.borderColor, args.dispatchInterface->getDynamicStateHeapData(), args.device->getBindlessHeapsHelper(), rootDeviceEnvironment); - if (ApiSpecificConfig::getBindlessMode()) { - container.getResidencyContainer().push_back(args.device->getBindlessHeapsHelper()->getHeap(NEO::BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH)->getGraphicsAllocation()); - } } idd.setSamplerStatePointer(samplerStateOffset); diff --git a/shared/source/command_stream/scratch_space_controller_xehp_and_later.cpp b/shared/source/command_stream/scratch_space_controller_xehp_and_later.cpp index 255359893a..e6b6a5fd9f 100644 --- a/shared/source/command_stream/scratch_space_controller_xehp_and_later.cpp +++ b/shared/source/command_stream/scratch_space_controller_xehp_and_later.cpp @@ -110,7 +110,7 @@ uint64_t ScratchSpaceControllerXeHPAndLater::calculateNewGSH() { uint64_t ScratchSpaceControllerXeHPAndLater::getScratchPatchAddress() { uint64_t scratchAddress = 0u; if (scratchAllocation || privateScratchAllocation) { - if (ApiSpecificConfig::getBindlessMode()) { + if (ApiSpecificConfig::getGlobalBindlessHeapConfiguration()) { scratchAddress = bindlessSS.surfaceStateOffset; } else { scratchAddress = static_cast(getOffsetToSurfaceState(slotId + sshOffset)); diff --git a/shared/source/device/root_device.cpp b/shared/source/device/root_device.cpp index 1d6feef10d..1a489f2f81 100644 --- a/shared/source/device/root_device.cpp +++ b/shared/source/device/root_device.cpp @@ -38,7 +38,7 @@ Device *RootDevice::getRootDevice() const { void RootDevice::createBindlessHeapsHelper() { - if (ApiSpecificConfig::getBindlessMode()) { + if (ApiSpecificConfig::getGlobalBindlessHeapConfiguration()) { this->executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->createBindlessHeapsHelper(getMemoryManager(), getNumGenericSubDevices() > 1, rootDeviceIndex, getDeviceBitfield()); } } diff --git a/shared/source/memory_manager/memory_manager.cpp b/shared/source/memory_manager/memory_manager.cpp index 8dfef911db..db69c0e844 100644 --- a/shared/source/memory_manager/memory_manager.cpp +++ b/shared/source/memory_manager/memory_manager.cpp @@ -244,7 +244,7 @@ void MemoryManager::freeGraphicsMemory(GraphicsAllocation *gfxAllocation, bool i if (!gfxAllocation) { return; } - if (ApiSpecificConfig::getBindlessMode() && executionEnvironment.rootDeviceEnvironments[gfxAllocation->getRootDeviceIndex()]->getBindlessHeapsHelper() != nullptr) { + if (ApiSpecificConfig::getGlobalBindlessHeapConfiguration() && executionEnvironment.rootDeviceEnvironments[gfxAllocation->getRootDeviceIndex()]->getBindlessHeapsHelper() != nullptr) { executionEnvironment.rootDeviceEnvironments[gfxAllocation->getRootDeviceIndex()]->getBindlessHeapsHelper()->placeSSAllocationInReuseVectorOnFreeMemory(gfxAllocation); } const bool hasFragments = gfxAllocation->fragmentsStorage.fragmentCount != 0; 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 0f34d4c333..06d8dc1d5f 100644 --- a/shared/test/unit_test/command_container/command_container_tests.cpp +++ b/shared/test/unit_test/command_container/command_container_tests.cpp @@ -1454,9 +1454,11 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsWit allocList.freeAllGraphicsAllocations(pDevice); } -TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsWithBindlessModeEnabledThenOnlyOneHeapFilled) { +TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsWithGlobalSshEnabledThenTwoHeapsFilled) { DebugManagerStateRestore dbgRestore; DebugManager.flags.SetAmountOfReusableAllocations.set(1); + DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(true); + auto csr = pDevice->getDefaultEngine().commandStreamReceiver; auto cmdContainer = std::make_unique(); AllocationsList allocList; @@ -1467,10 +1469,10 @@ TEST_F(CommandContainerTest, givenCmdContainerWhenFillReusableAllocationListsWit EXPECT_TRUE(reusableHeapsList.peekIsEmpty()); - DebugManager.flags.UseBindlessMode.set(true); cmdContainer->fillReusableAllocationLists(); EXPECT_FALSE(reusableHeapsList.peekIsEmpty()); - EXPECT_EQ(reusableHeapsList.peekHead()->countThisAndAllConnected(), 1u); + auto expectedHeapCount = hardwareInfo.capabilityTable.supportsImages ? 2u : 1u; + EXPECT_EQ(reusableHeapsList.peekHead()->countThisAndAllConnected(), expectedHeapCount); cmdContainer.reset(); allocList.freeAllGraphicsAllocations(pDevice); diff --git a/shared/test/unit_test/encoders/test_encode_dispatch_kernel.cpp b/shared/test/unit_test/encoders/test_encode_dispatch_kernel.cpp index 3b2bf7678e..d6f0e1af14 100644 --- a/shared/test/unit_test/encoders/test_encode_dispatch_kernel.cpp +++ b/shared/test/unit_test/encoders/test_encode_dispatch_kernel.cpp @@ -1290,6 +1290,7 @@ HWTEST_F(BindlessCommandEncodeStatesContainerTest, givenBindlessKernelAndBindles using WALKER = typename FamilyType::WALKER_TYPE; DebugManagerStateRestore dbgRestorer; DebugManager.flags.UseBindlessMode.set(1); + DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(1); auto commandContainer = std::make_unique(); commandContainer->initialize(pDevice, nullptr, HeapSize::defaultHeapSize, true, false); commandContainer->setDirtyStateForAllHeaps(false); @@ -1300,8 +1301,6 @@ HWTEST_F(BindlessCommandEncodeStatesContainerTest, givenBindlessKernelAndBindles pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); uint32_t numBindingTable = 1; - BINDING_TABLE_STATE bindingTableState = FamilyType::cmdInitBindingTableState; - uint32_t dims[] = {1, 1, 1}; std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); @@ -1309,10 +1308,6 @@ HWTEST_F(BindlessCommandEncodeStatesContainerTest, givenBindlessKernelAndBindles dispatchInterface->kernelDescriptor.payloadMappings.bindingTable.tableOffset = 0U; dispatchInterface->kernelDescriptor.kernelAttributes.bufferAddressingMode = KernelDescriptor::BindlessAndStateless; - const uint8_t *sshData = reinterpret_cast(&bindingTableState); - dispatchInterface->getSurfaceStateHeapDataResult = const_cast(sshData); - dispatchInterface->getSurfaceStateHeapDataSizeResult = static_cast(sizeof(BINDING_TABLE_STATE)); - bool requiresUncachedMocs = false; EXPECT_EQ(commandContainer->getIndirectHeap(HeapType::SURFACE_STATE), nullptr); EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs); @@ -1322,47 +1317,7 @@ HWTEST_F(BindlessCommandEncodeStatesContainerTest, givenBindlessKernelAndBindles EXPECT_EQ(commandContainer->getIndirectHeap(HeapType::SURFACE_STATE), nullptr); } -HWTEST2_F(BindlessCommandEncodeStatesContainerTest, givenBindlessKernelAndBindlessModeEnabledWhenEncodingKernelThenCmdContainerResidencyContainsGlobalDSH, IsAtMostGen12lp) { - using BINDING_TABLE_STATE = typename FamilyType::BINDING_TABLE_STATE; - using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA; - using WALKER = typename FamilyType::WALKER_TYPE; - DebugManagerStateRestore dbgRestorer; - DebugManager.flags.UseBindlessMode.set(1); - auto commandContainer = std::make_unique(); - commandContainer->initialize(pDevice, nullptr, HeapSize::defaultHeapSize, true, false); - commandContainer->setDirtyStateForAllHeaps(false); - commandContainer->l1CachePolicyDataRef() = &l1CachePolicyData; - pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), - pDevice->getNumGenericSubDevices() > 1, - pDevice->getRootDeviceIndex(), - pDevice->getDeviceBitfield()); - uint32_t numBindingTable = 1; - BINDING_TABLE_STATE bindingTableState = FamilyType::cmdInitBindingTableState; - - uint32_t dims[] = {1, 1, 1}; - std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); - - dispatchInterface->kernelDescriptor.payloadMappings.bindingTable.numEntries = numBindingTable; - dispatchInterface->kernelDescriptor.payloadMappings.bindingTable.tableOffset = 0U; - dispatchInterface->kernelDescriptor.kernelAttributes.bufferAddressingMode = KernelDescriptor::BindlessAndStateless; - - const uint8_t *sshData = reinterpret_cast(&bindingTableState); - dispatchInterface->getSurfaceStateHeapDataResult = const_cast(sshData); - dispatchInterface->getSurfaceStateHeapDataSizeResult = static_cast(sizeof(BINDING_TABLE_STATE)); - - bool requiresUncachedMocs = false; - EXPECT_EQ(commandContainer->getIndirectHeap(HeapType::SURFACE_STATE), nullptr); - EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs); - - EncodeDispatchKernel::encode(*commandContainer.get(), dispatchArgs, nullptr); - - auto globalDSHIterator = std::find(commandContainer->getResidencyContainer().begin(), commandContainer->getResidencyContainer().end(), - pDevice->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::GLOBAL_DSH)->getGraphicsAllocation()); - - EXPECT_NE(commandContainer->getResidencyContainer().end(), globalDSHIterator); -} - -HWTEST_F(BindlessCommandEncodeStatesContainerTest, givenBindfulKernelWhenBindlessModeEnabledThenCmdContainerHaveSsh) { +HWTEST_F(BindlessCommandEncodeStatesContainerTest, givenBindfulKernelWhenBindlessModeEnabledThenCmdContainerHasSsh) { using BINDING_TABLE_STATE = typename FamilyType::BINDING_TABLE_STATE; using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA; using WALKER = typename FamilyType::WALKER_TYPE; @@ -1391,7 +1346,7 @@ HWTEST_F(BindlessCommandEncodeStatesContainerTest, givenBindfulKernelWhenBindles dispatchInterface->getSurfaceStateHeapDataSizeResult = static_cast(sizeof(BINDING_TABLE_STATE)); bool requiresUncachedMocs = false; - EXPECT_EQ(commandContainer->getIndirectHeap(HeapType::SURFACE_STATE), nullptr); + EXPECT_NE(commandContainer->getIndirectHeap(HeapType::SURFACE_STATE), nullptr); EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs); EncodeDispatchKernel::encode(*commandContainer.get(), dispatchArgs, nullptr); @@ -1399,155 +1354,6 @@ HWTEST_F(BindlessCommandEncodeStatesContainerTest, givenBindfulKernelWhenBindles EXPECT_NE(commandContainer->getIndirectHeap(HeapType::SURFACE_STATE), nullptr); } -HWTEST_F(BindlessCommandEncodeStatesContainerTest, givenBindlessModeEnabledWhenDispatchingTwoBindfulKernelsThenItuseTheSameSsh) { - using BINDING_TABLE_STATE = typename FamilyType::BINDING_TABLE_STATE; - using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA; - using WALKER = typename FamilyType::WALKER_TYPE; - DebugManagerStateRestore dbgRestorer; - DebugManager.flags.UseBindlessMode.set(1); - auto commandContainer = std::make_unique(); - commandContainer->initialize(pDevice, nullptr, HeapSize::defaultHeapSize, true, false); - commandContainer->setDirtyStateForAllHeaps(false); - commandContainer->l1CachePolicyDataRef() = &l1CachePolicyData; - pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), - pDevice->getNumGenericSubDevices() > 1, - pDevice->getRootDeviceIndex(), - pDevice->getDeviceBitfield()); - uint32_t numBindingTable = 1; - BINDING_TABLE_STATE bindingTableState = FamilyType::cmdInitBindingTableState; - - uint32_t dims[] = {1, 1, 1}; - std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); - - dispatchInterface->kernelDescriptor.payloadMappings.bindingTable.numEntries = numBindingTable; - dispatchInterface->kernelDescriptor.payloadMappings.bindingTable.tableOffset = 0U; - dispatchInterface->kernelDescriptor.kernelAttributes.bufferAddressingMode = KernelDescriptor::BindfulAndStateless; - - const uint8_t *sshData = reinterpret_cast(&bindingTableState); - dispatchInterface->getSurfaceStateHeapDataResult = const_cast(sshData); - dispatchInterface->getSurfaceStateHeapDataSizeResult = static_cast(sizeof(BINDING_TABLE_STATE)); - - bool requiresUncachedMocs = false; - EXPECT_EQ(commandContainer->getIndirectHeap(HeapType::SURFACE_STATE), nullptr); - EncodeDispatchKernelArgs dispatchArgs = createDefaultDispatchKernelArgs(pDevice, dispatchInterface.get(), dims, requiresUncachedMocs); - - EncodeDispatchKernel::encode(*commandContainer.get(), dispatchArgs, nullptr); - - auto sshBefore = commandContainer->getIndirectHeap(HeapType::SURFACE_STATE); - EncodeDispatchKernel::encode(*commandContainer.get(), dispatchArgs, nullptr); - EncodeDispatchKernel::encode(*commandContainer.get(), dispatchArgs, nullptr); - auto sshAfter = commandContainer->getIndirectHeap(HeapType::SURFACE_STATE); - EncodeDispatchKernel::encode(*commandContainer.get(), dispatchArgs, nullptr); - EXPECT_EQ(sshBefore, sshAfter); -} - -HWTEST_F(BindlessCommandEncodeStatesTest, givenGlobalBindlessHeapsWhenDispatchingKernelWithSamplerThenGlobalDshInResidencyContainer) { - bool deviceUsesDsh = pDevice->getHardwareInfo().capabilityTable.supportsImages; - if (!deviceUsesDsh) { - GTEST_SKIP(); - } - DebugManagerStateRestore restorer; - DebugManager.flags.UseBindlessMode.set(1); - cmdContainer->initialize(pDevice, nullptr, HeapSize::defaultHeapSize, true, false); - cmdContainer->setDirtyStateForAllHeaps(false); - using SAMPLER_BORDER_COLOR_STATE = typename FamilyType::SAMPLER_BORDER_COLOR_STATE; - using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA; - uint32_t numSamplers = 1; - SAMPLER_BORDER_COLOR_STATE samplerState; - samplerState.init(); - pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), - pDevice->getNumGenericSubDevices() > 1, - pDevice->getRootDeviceIndex(), - pDevice->getDeviceBitfield()); - - uint32_t dims[] = {2, 1, 1}; - std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); - - dispatchInterface->kernelDescriptor.payloadMappings.samplerTable.numSamplers = numSamplers; - dispatchInterface->kernelDescriptor.payloadMappings.samplerTable.tableOffset = 0U; - dispatchInterface->kernelDescriptor.payloadMappings.samplerTable.borderColor = 0U; - const uint8_t *dshData = reinterpret_cast(&samplerState); - dispatchInterface->getDynamicStateHeapDataResult = const_cast(dshData); - - bool requiresUncachedMocs = false; - EncodeDispatchKernelArgs dispatchArgs{ - 0, - pDevice, - dispatchInterface.get(), - nullptr, - nullptr, - dims, - nullptr, - NEO::PreemptionMode::Disabled, - 0, - 0, - false, - false, - false, - requiresUncachedMocs, - false, - false, - false, - false, - false, - false}; - - EncodeDispatchKernel::encode(*cmdContainer.get(), dispatchArgs, nullptr); - - EXPECT_NE(std::find(cmdContainer->getResidencyContainer().begin(), cmdContainer->getResidencyContainer().end(), pDevice->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::GLOBAL_DSH)->getGraphicsAllocation()), cmdContainer->getResidencyContainer().end()); -} - -HWTEST_F(BindlessCommandEncodeStatesTest, givenBindlessModeDisabledelWithSamplerThenGlobalDshIsNotResidnecyContainer) { - DebugManagerStateRestore restorer; - DebugManager.flags.UseBindlessMode.set(0); - cmdContainer->initialize(pDevice, nullptr, HeapSize::defaultHeapSize, true, false); - using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE; - using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA; - uint32_t numSamplers = 1; - SAMPLER_STATE samplerState; - memset(&samplerState, 2, sizeof(SAMPLER_STATE)); - pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), - pDevice->getNumGenericSubDevices() > 1, - pDevice->getRootDeviceIndex(), - pDevice->getDeviceBitfield()); - - uint32_t dims[] = {2, 1, 1}; - std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); - - dispatchInterface->kernelDescriptor.payloadMappings.samplerTable.numSamplers = numSamplers; - dispatchInterface->kernelDescriptor.payloadMappings.samplerTable.tableOffset = 0U; - dispatchInterface->kernelDescriptor.payloadMappings.samplerTable.borderColor = 0U; - const uint8_t *dshData = reinterpret_cast(&samplerState); - dispatchInterface->getDynamicStateHeapDataResult = const_cast(dshData); - - bool requiresUncachedMocs = false; - EncodeDispatchKernelArgs dispatchArgs{ - 0, - pDevice, - dispatchInterface.get(), - nullptr, - nullptr, - dims, - nullptr, - NEO::PreemptionMode::Disabled, - 0, - 0, - false, - false, - false, - requiresUncachedMocs, - false, - false, - false, - false, - false, - false}; - - EncodeDispatchKernel::encode(*cmdContainer.get(), dispatchArgs, nullptr); - - EXPECT_EQ(std::find(cmdContainer->getResidencyContainer().begin(), cmdContainer->getResidencyContainer().end(), pDevice->getBindlessHeapsHelper()->getHeap(BindlessHeapsHelper::GLOBAL_DSH)->getGraphicsAllocation()), cmdContainer->getResidencyContainer().end()); -} - HWTEST_F(CommandEncodeStatesTest, givenKernelInfoWhenGettingRequiredDshSpaceThenReturnCorrectValues) { using INTERFACE_DESCRIPTOR_DATA = typename FamilyType::INTERFACE_DESCRIPTOR_DATA; using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE; diff --git a/shared/test/unit_test/encoders/test_encode_states.cpp b/shared/test/unit_test/encoders/test_encode_states.cpp index 3a9f99b7aa..02b034cfa0 100644 --- a/shared/test/unit_test/encoders/test_encode_states.cpp +++ b/shared/test/unit_test/encoders/test_encode_states.cpp @@ -74,7 +74,7 @@ using BindlessCommandEncodeStatesTest = Test HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorWithoutAlphaThenBorderColorPtrReturned) { using SAMPLER_BORDER_COLOR_STATE = typename FamilyType::SAMPLER_BORDER_COLOR_STATE; DebugManagerStateRestore restorer; - DebugManager.flags.UseBindlessMode.set(1); + DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(1); using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE; uint32_t numSamplers = 1; pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), @@ -96,7 +96,7 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorWit HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorWithAlphaThenBorderColorPtrOffseted) { using SAMPLER_BORDER_COLOR_STATE = typename FamilyType::SAMPLER_BORDER_COLOR_STATE; DebugManagerStateRestore restorer; - DebugManager.flags.UseBindlessMode.set(1); + DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(1); using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE; uint32_t numSamplers = 1; pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), @@ -119,7 +119,7 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorWit HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsRedChanelIsNotZeroThenExceptionThrown) { using SAMPLER_BORDER_COLOR_STATE = typename FamilyType::SAMPLER_BORDER_COLOR_STATE; DebugManagerStateRestore restorer; - DebugManager.flags.UseBindlessMode.set(1); + DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(1); using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE; uint32_t numSamplers = 1; pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), @@ -138,7 +138,7 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsRe HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsGreenChanelIsNotZeroThenExceptionThrown) { using SAMPLER_BORDER_COLOR_STATE = typename FamilyType::SAMPLER_BORDER_COLOR_STATE; DebugManagerStateRestore restorer; - DebugManager.flags.UseBindlessMode.set(1); + DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(1); using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE; uint32_t numSamplers = 1; pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), @@ -157,7 +157,7 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsGr HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsBlueChanelIsNotZeroThenExceptionThrown) { using SAMPLER_BORDER_COLOR_STATE = typename FamilyType::SAMPLER_BORDER_COLOR_STATE; DebugManagerStateRestore restorer; - DebugManager.flags.UseBindlessMode.set(1); + DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(1); using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE; uint32_t numSamplers = 1; pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), @@ -175,7 +175,7 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsBl HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsAlphaChanelIsNotZeroOrOneThenExceptionThrown) { using SAMPLER_BORDER_COLOR_STATE = typename FamilyType::SAMPLER_BORDER_COLOR_STATE; DebugManagerStateRestore restorer; - DebugManager.flags.UseBindlessMode.set(1); + DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(1); using SAMPLER_STATE = typename FamilyType::SAMPLER_STATE; uint32_t numSamplers = 1; pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), diff --git a/shared/test/unit_test/helpers/bindless_heaps_helper_tests.cpp b/shared/test/unit_test/helpers/bindless_heaps_helper_tests.cpp index d92bafcbe8..f45bbd971b 100644 --- a/shared/test/unit_test/helpers/bindless_heaps_helper_tests.cpp +++ b/shared/test/unit_test/helpers/bindless_heaps_helper_tests.cpp @@ -18,16 +18,16 @@ using namespace NEO; -TEST(BindlessHeapsHelper, givenBindlessModeFlagEnabledWhenCreatingRootDevicesThenBindlesHeapHelperCreated) { +TEST(BindlessHeapsHelper, givenExternalAllocatorFlagEnabledWhenCreatingRootDevicesThenBindlesHeapHelperCreated) { DebugManagerStateRestore dbgRestorer; - DebugManager.flags.UseBindlessMode.set(1); + DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(1); std::unique_ptr deviceFactory(new UltDeviceFactory(1, 1)); EXPECT_NE(deviceFactory->rootDevices[0]->getBindlessHeapsHelper(), nullptr); } -TEST(BindlessHeapsHelper, givenBindlessModeFlagDisabledWhenCreatingRootDevicesThenBindlesHeapHelperCreated) { +TEST(BindlessHeapsHelper, givenExternalAllocatorFlagDisabledWhenCreatingRootDevicesThenBindlesHeapHelperIsNotCreated) { DebugManagerStateRestore dbgRestorer; - DebugManager.flags.UseBindlessMode.set(0); + DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(0); std::unique_ptr deviceFactory(new UltDeviceFactory(1, 1)); EXPECT_EQ(deviceFactory->rootDevices[0]->getBindlessHeapsHelper(), nullptr); } diff --git a/shared/test/unit_test/scratch_space_controler/scratch_space_controler_xehp_and_later_tests.cpp b/shared/test/unit_test/scratch_space_controler/scratch_space_controler_xehp_and_later_tests.cpp index e745f7edde..a8cdc0c5ee 100644 --- a/shared/test/unit_test/scratch_space_controler/scratch_space_controler_xehp_and_later_tests.cpp +++ b/shared/test/unit_test/scratch_space_controler/scratch_space_controler_xehp_and_later_tests.cpp @@ -53,7 +53,7 @@ using ScratchComtrolerTests = Test; HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenBindlessModeOnWhenGetPatchedOffsetCalledThenBindlessOffsetReturned) { DebugManagerStateRestore restorer; - DebugManager.flags.UseBindlessMode.set(1); + DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(1); MockCsrHw2 csr(*pDevice->getExecutionEnvironment(), 0, pDevice->getDeviceBitfield()); csr.initializeTagAllocation(); csr.setupContext(*pDevice->getDefaultEngine().osContext); @@ -69,7 +69,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenBindlessModeOnWhenGetPa HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenDirtyScratchAllocationOnWhenWhenProgramBindlessHeapThenProgramSurfaceStateAtPtrCalled) { DebugManagerStateRestore restorer; - DebugManager.flags.UseBindlessMode.set(1); + DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(1); MockCommandStreamReceiver csr(*pDevice->getExecutionEnvironment(), 0, pDevice->getDeviceBitfield()); csr.initializeTagAllocation(); csr.setupContext(*pDevice->getDefaultEngine().osContext); @@ -89,7 +89,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenDirtyScratchAllocationO HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenNotDirtyScratchAllocationOnWhenWhenProgramBindlessHeapThenProgramSurfaceStateAtPtrWasNotCalled) { DebugManagerStateRestore restorer; - DebugManager.flags.UseBindlessMode.set(1); + DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(1); MockCommandStreamReceiver csr(*pDevice->getExecutionEnvironment(), 0, pDevice->getDeviceBitfield()); csr.initializeTagAllocation(); csr.setupContext(*pDevice->getDefaultEngine().osContext); @@ -110,7 +110,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenNotDirtyScratchAllocati } HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenPrivateScratchEnabledWhenWhenProgramBindlessHeapSurfaceThenSSHasDoubleSize) { DebugManagerStateRestore restorer; - DebugManager.flags.UseBindlessMode.set(1); + DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(1); DebugManager.flags.EnablePrivateScratchSlot1.set(1); MockCsrHw2 csr(*pDevice->getExecutionEnvironment(), 0, pDevice->getDeviceBitfield()); csr.initializeTagAllocation(); @@ -132,7 +132,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenPrivateScratchEnabledWh HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenPrivateScratchDisabledWhenWhenProgramBindlessHeapSurfaceThenSSHasSingleSize) { DebugManagerStateRestore restorer; - DebugManager.flags.UseBindlessMode.set(1); + DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(1); DebugManager.flags.EnablePrivateScratchSlot1.set(0); MockCsrHw2 csr(*pDevice->getExecutionEnvironment(), 0, pDevice->getDeviceBitfield()); csr.initializeTagAllocation();