From 22725e584082bcf99b9c52fab88dbc7a5c32292a Mon Sep 17 00:00:00 2001 From: Maciej Plewka Date: Tue, 5 Oct 2021 10:30:14 +0000 Subject: [PATCH] Pass device bit field to create bindless heaps allocations Signed-off-by: Maciej Plewka --- .../sources/cmdqueue/test_cmdqueue.cpp | 6 +-- .../unit_tests/sources/kernel/test_kernel.cpp | 12 ++++-- .../unit_test/device/sub_device_tests.cpp | 2 +- shared/source/device/root_device.cpp | 2 +- .../root_device_environment.cpp | 4 +- .../root_device_environment.h | 2 +- .../source/helpers/bindless_heaps_helper.cpp | 4 +- shared/source/helpers/bindless_heaps_helper.h | 3 +- .../helpers/bindless_heaps_helper_tests.cpp | 37 +++++++++++-------- .../common/mocks/mock_bindless_heaps_helper.h | 2 +- .../encoders/test_encode_dispatch_kernel.cpp | 15 +++++--- .../unit_test/encoders/test_encode_states.cpp | 19 ++++++---- ...h_space_controler_xehp_and_later_tests.cpp | 8 ++-- 13 files changed, 69 insertions(+), 47 deletions(-) diff --git a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue.cpp b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue.cpp index 289690471f..8abd288767 100644 --- a/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdqueue/test_cmdqueue.cpp @@ -446,7 +446,7 @@ HWTEST2_F(CommandQueueProgramSBATest, using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; DebugManagerStateRestore dbgRestorer; DebugManager.flags.UseBindlessMode.set(1); - auto bindlessHeapsHelper = std::make_unique(neoDevice->getMemoryManager(), neoDevice->getNumGenericSubDevices() > 1, neoDevice->getRootDeviceIndex()); + 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()); NEO::MockGraphicsAllocation baseAllocation; @@ -485,7 +485,7 @@ HWTEST2_F(CommandQueueProgramSBATest, using STATE_BASE_ADDRESS = typename FamilyType::STATE_BASE_ADDRESS; DebugManagerStateRestore dbgRestorer; DebugManager.flags.UseBindlessMode.set(0); - auto bindlessHeapsHelper = std::make_unique(neoDevice->getMemoryManager(), neoDevice->getNumGenericSubDevices() > 1, neoDevice->getRootDeviceIndex()); + 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()); NEO::MockGraphicsAllocation baseAllocation; @@ -1010,7 +1010,7 @@ HWTEST2_F(CommandQueueDestroy, givenCommandQueueAndCommandListWithSshAndScratchW HWTEST2_F(CommandQueueDestroy, givenCommandQueueAndCommandListWithWhenBindlessEnabledThenHeapContainerIsEmpty, CommandQueueExecuteTestSupport) { DebugManagerStateRestore dbgRestorer; DebugManager.flags.UseBindlessMode.set(1); - auto bindlessHeapsHelper = std::make_unique(neoDevice->getMemoryManager(), neoDevice->getNumGenericSubDevices() > 1, neoDevice->getRootDeviceIndex()); + 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 = {}; NEO::CommandStreamReceiver *csr; diff --git a/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp b/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp index 18bf64f8e8..eac606e7b8 100644 --- a/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp +++ b/level_zero/core/test/unit_tests/sources/kernel/test_kernel.cpp @@ -1408,7 +1408,8 @@ TEST_F(KernelImpPatchBindlessTest, GivenKernelImpWhenPatchBindlessOffsetCalledTh neoDevice->incRefInternal(); neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(), neoDevice->getNumGenericSubDevices() > 1, - neoDevice->getRootDeviceIndex()); + neoDevice->getRootDeviceIndex(), + neoDevice->getDeviceBitfield()); Mock mockModule(&mockDevice, nullptr); kernel.module = &mockModule; NEO::MockGraphicsAllocation alloc; @@ -1441,7 +1442,8 @@ HWTEST2_F(KernelImpPatchBindlessTest, GivenKernelImpWhenSetSurfaceStateBindlessT neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(), neoDevice->getNumGenericSubDevices() > 1, - neoDevice->getRootDeviceIndex()); + neoDevice->getRootDeviceIndex(), + neoDevice->getDeviceBitfield()); auto &hwHelper = NEO::HwHelper::get(device->getHwInfo().platform.eRenderCoreFamily); size_t size = hwHelper.getRenderSurfaceStateSize(); @@ -1475,7 +1477,8 @@ HWTEST2_F(KernelImpPatchBindlessTest, GivenKernelImpWhenSetSurfaceStateBindfulTh neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(), neoDevice->getNumGenericSubDevices() > 1, - neoDevice->getRootDeviceIndex()); + neoDevice->getRootDeviceIndex(), + neoDevice->getDeviceBitfield()); auto &hwHelper = NEO::HwHelper::get(device->getHwInfo().platform.eRenderCoreFamily); size_t size = hwHelper.getRenderSurfaceStateSize(); @@ -1750,7 +1753,8 @@ HWTEST2_F(SetKernelArg, givenImageAndBindlessKernelWhenSetArgImageThenCopySurfac neoDevice->getExecutionEnvironment()->rootDeviceEnvironments[neoDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(neoDevice->getMemoryManager(), neoDevice->getNumGenericSubDevices() > 1, - neoDevice->getRootDeviceIndex()); + neoDevice->getRootDeviceIndex(), + neoDevice->getDeviceBitfield()); auto &imageArg = const_cast(kernel->kernelImmData->getDescriptor().payloadMappings.explicitArgs[3].template as()); auto &addressingMode = kernel->kernelImmData->getDescriptor().kernelAttributes.imageAddressingMode; const_cast(addressingMode) = NEO::KernelDescriptor::Bindless; diff --git a/opencl/test/unit_test/device/sub_device_tests.cpp b/opencl/test/unit_test/device/sub_device_tests.cpp index ae73a61bc0..4619387e82 100644 --- a/opencl/test/unit_test/device/sub_device_tests.cpp +++ b/opencl/test/unit_test/device/sub_device_tests.cpp @@ -890,6 +890,6 @@ TEST(SubDevicesTest, givenCreateMultipleSubDevicesFlagSetWhenBindlessHeapHelperC VariableBackup mockDeviceFlagBackup(&MockDevice::createSingleDevice, false); auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(defaultHwInfo.get())); - device->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->createBindlessHeapsHelper(device->getMemoryManager(), device->getNumGenericSubDevices() > 1, device->getRootDeviceIndex()); + device->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]->createBindlessHeapsHelper(device->getMemoryManager(), device->getNumGenericSubDevices() > 1, device->getRootDeviceIndex(), device->getDeviceBitfield()); EXPECT_EQ(device->getBindlessHeapsHelper(), device->subdevices.at(0)->getBindlessHeapsHelper()); } diff --git a/shared/source/device/root_device.cpp b/shared/source/device/root_device.cpp index 46e0f7fa3a..e4bb881b46 100644 --- a/shared/source/device/root_device.cpp +++ b/shared/source/device/root_device.cpp @@ -39,7 +39,7 @@ Device *RootDevice::getRootDevice() const { void RootDevice::createBindlessHeapsHelper() { if (ApiSpecificConfig::getBindlessConfiguration()) { - this->executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->createBindlessHeapsHelper(getMemoryManager(), getNumGenericSubDevices() > 1, rootDeviceIndex); + this->executionEnvironment->rootDeviceEnvironments[getRootDeviceIndex()]->createBindlessHeapsHelper(getMemoryManager(), getNumGenericSubDevices() > 1, rootDeviceIndex, getDeviceBitfield()); } } diff --git a/shared/source/execution_environment/root_device_environment.cpp b/shared/source/execution_environment/root_device_environment.cpp index 6e779bdc36..229e3b33d4 100644 --- a/shared/source/execution_environment/root_device_environment.cpp +++ b/shared/source/execution_environment/root_device_environment.cpp @@ -102,8 +102,8 @@ BindlessHeapsHelper *RootDeviceEnvironment::getBindlessHeapsHelper() const { return bindlessHeapsHelper.get(); } -void RootDeviceEnvironment::createBindlessHeapsHelper(MemoryManager *memoryManager, bool availableDevices, uint32_t rootDeviceIndex) { - bindlessHeapsHelper = std::make_unique(memoryManager, availableDevices, rootDeviceIndex); +void RootDeviceEnvironment::createBindlessHeapsHelper(MemoryManager *memoryManager, bool availableDevices, uint32_t rootDeviceIndex, DeviceBitfield deviceBitfield) { + bindlessHeapsHelper = std::make_unique(memoryManager, availableDevices, rootDeviceIndex, deviceBitfield); } CompilerInterface *RootDeviceEnvironment::getCompilerInterface() { diff --git a/shared/source/execution_environment/root_device_environment.h b/shared/source/execution_environment/root_device_environment.h index e6de8c8169..aac6292528 100644 --- a/shared/source/execution_environment/root_device_environment.h +++ b/shared/source/execution_environment/root_device_environment.h @@ -60,7 +60,7 @@ struct RootDeviceEnvironment { MOCKABLE_VIRTUAL CompilerInterface *getCompilerInterface(); BuiltIns *getBuiltIns(); BindlessHeapsHelper *getBindlessHeapsHelper() const; - void createBindlessHeapsHelper(MemoryManager *memoryManager, bool availableDevices, uint32_t rootDeviceIndex); + void createBindlessHeapsHelper(MemoryManager *memoryManager, bool availableDevices, uint32_t rootDeviceIndex, DeviceBitfield deviceBitfield); std::unique_ptr sipKernels[static_cast(SipKernelType::COUNT)]; std::unique_ptr gmmHelper; diff --git a/shared/source/helpers/bindless_heaps_helper.cpp b/shared/source/helpers/bindless_heaps_helper.cpp index 187e30f014..8b99906d67 100644 --- a/shared/source/helpers/bindless_heaps_helper.cpp +++ b/shared/source/helpers/bindless_heaps_helper.cpp @@ -17,7 +17,7 @@ constexpr size_t globalSshAllocationSize = 4 * MemoryConstants::pageSize64k; constexpr size_t borderColorAlphaOffset = alignUp(4 * sizeof(float), MemoryConstants::cacheLineSize); using BindlesHeapType = BindlessHeapsHelper::BindlesHeapType; -BindlessHeapsHelper::BindlessHeapsHelper(MemoryManager *memManager, bool isMultiOsContextCapable, const uint32_t rootDeviceIndex) : memManager(memManager), isMultiOsContextCapable(isMultiOsContextCapable), rootDeviceIndex(rootDeviceIndex) { +BindlessHeapsHelper::BindlessHeapsHelper(MemoryManager *memManager, bool isMultiOsContextCapable, const uint32_t rootDeviceIndex, DeviceBitfield deviceBitfield) : memManager(memManager), isMultiOsContextCapable(isMultiOsContextCapable), rootDeviceIndex(rootDeviceIndex), deviceBitfield(deviceBitfield) { for (auto heapType = 0; heapType < BindlesHeapType::NUM_HEAP_TYPES; heapType++) { auto allocInFrontWindow = heapType != BindlesHeapType::GLOBAL_DSH; auto heapAllocation = getHeapAllocation(MemoryConstants::pageSize64k, MemoryConstants::pageSize64k, allocInFrontWindow); @@ -44,7 +44,7 @@ BindlessHeapsHelper::~BindlessHeapsHelper() { GraphicsAllocation *BindlessHeapsHelper::getHeapAllocation(size_t heapSize, size_t alignment, bool allocInFrontWindow) { auto allocationType = GraphicsAllocation::AllocationType::LINEAR_STREAM; - NEO::AllocationProperties properties{rootDeviceIndex, true, heapSize, allocationType, isMultiOsContextCapable, false}; + NEO::AllocationProperties properties{rootDeviceIndex, true, heapSize, allocationType, isMultiOsContextCapable, deviceBitfield}; properties.flags.use32BitFrontWindow = allocInFrontWindow; properties.alignment = alignment; diff --git a/shared/source/helpers/bindless_heaps_helper.h b/shared/source/helpers/bindless_heaps_helper.h index f171d8ae11..06c0500b51 100644 --- a/shared/source/helpers/bindless_heaps_helper.h +++ b/shared/source/helpers/bindless_heaps_helper.h @@ -37,7 +37,7 @@ class BindlessHeapsHelper { SCRATCH_SSH, NUM_HEAP_TYPES }; - BindlessHeapsHelper(MemoryManager *memManager, bool isMultiOsContextCapable, const uint32_t rootDeviceIndex); + BindlessHeapsHelper(MemoryManager *memManager, bool isMultiOsContextCapable, const uint32_t rootDeviceIndex, DeviceBitfield deviceBitfield); ~BindlessHeapsHelper(); GraphicsAllocation *getHeapAllocation(size_t heapSize, size_t alignment, bool allocInFrontWindow); @@ -60,5 +60,6 @@ class BindlessHeapsHelper { std::vector> surfaceStateInHeapVectorReuse; std::unordered_map> surfaceStateInHeapAllocationMap; std::mutex mtx; + DeviceBitfield deviceBitfield; }; } // namespace NEO \ No newline at end of file diff --git a/shared/test/common/helpers/bindless_heaps_helper_tests.cpp b/shared/test/common/helpers/bindless_heaps_helper_tests.cpp index 9714f5d27f..5cfd3d08ae 100644 --- a/shared/test/common/helpers/bindless_heaps_helper_tests.cpp +++ b/shared/test/common/helpers/bindless_heaps_helper_tests.cpp @@ -34,13 +34,13 @@ TEST(BindlessHeapsHelper, givenBindlessModeFlagDisabledWhenCreatingRootDevicesTh using BindlessHeapsHelperTests = Test; TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenItsCreatedThenSpecialSshAllocatedAtHeapBegining) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); auto specialSshAllocation = bindlessHeapHelper->specialSsh->getGraphicsAllocation(); EXPECT_EQ(specialSshAllocation->getGpuAddress(), specialSshAllocation->getGpuBaseAddress()); } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapThenHeapUsedSpaceGrow) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); auto usedBefore = bindlessHeapHelper->globalSsh->getUsed(); MockGraphicsAllocation alloc; @@ -51,7 +51,7 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapThen } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapThenMemoryAtReturnedOffsetIsCorrect) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); MockGraphicsAllocation alloc; size_t size = 0x40; @@ -62,7 +62,7 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapThen } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapTwiceForTheSameAllocationThenTheSameOffsetReturned) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); MockGraphicsAllocation alloc; size_t size = 0x40; @@ -73,7 +73,7 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapTwic } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapTwiceForDifferentAllocationThenDifferentOffsetsReturned) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); MockGraphicsAllocation alloc1; MockGraphicsAllocation alloc2; @@ -87,7 +87,7 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInHeapTwic } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocatingMoreSsThenNewHeapAllocationCreated) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); size_t ssSize = 0x40; auto ssCount = bindlessHeapHelper->globalSsh->getAvailableSpace() / ssSize; auto graphicsAllocations = std::make_unique(ssCount); @@ -104,27 +104,27 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocatingMoreSsThen } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenCreatedThenAllocationsHaveTheSameBaseAddress) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); for (auto allocation : bindlessHeapHelper->ssHeapsAllocations) { EXPECT_EQ(allocation->getGpuBaseAddress(), bindlessHeapHelper->getGlobalHeapsBase()); } } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenGetDefaultBorderColorOffsetCalledThenCorrectOffsetReturned) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); auto expectedOffset = bindlessHeapHelper->borderColorStates->getGpuAddress() - bindlessHeapHelper->borderColorStates->getGpuBaseAddress(); EXPECT_EQ(bindlessHeapHelper->getDefaultBorderColorOffset(), expectedOffset); } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenGetAlphaBorderColorOffsetCalledThenCorrectOffsetReturned) { auto borderColorSize = 0x40; - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); auto expectedOffset = bindlessHeapHelper->borderColorStates->getGpuAddress() - bindlessHeapHelper->borderColorStates->getGpuBaseAddress() + borderColorSize; EXPECT_EQ(bindlessHeapHelper->getAlphaBorderColorOffset(), expectedOffset); } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInSpecialHeapThenOffsetLessThanFrontWindowSize) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); MockGraphicsAllocation alloc; size_t size = 0x40; auto ssInHeapInfo = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::SPECIAL_SSH); @@ -132,7 +132,7 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInSpecialH EXPECT_LT(ssInHeapInfo.surfaceStateOffset, frontWindowSize); } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInGlobalHeapThenOffsetLessThanFrontWindowSize) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); MockGraphicsAllocation alloc; size_t size = 0x40; auto ssInHeapInfo = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_SSH); @@ -141,7 +141,7 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInGlobalHe } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInScratchHeapThenOffsetLessThanFrontWindowSize) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); MockGraphicsAllocation alloc; size_t size = 0x40; auto ssInHeapInfo = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::SCRATCH_SSH); @@ -150,7 +150,7 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInScratchH } TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInGlobalDshThenOffsetGreaterOrEqualFrontWindowSize) { - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); MockGraphicsAllocation alloc; size_t size = 0x40; auto ssInHeapInfo = bindlessHeapHelper->allocateSSInHeap(size, &alloc, BindlessHeapsHelper::BindlesHeapType::GLOBAL_DSH); @@ -161,7 +161,7 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenAllocateSsInGlobalDs TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenFreeGraphicsMemoryIsCalledThenSSinHeapInfoShouldBePlacedInReuseVector) { DebugManagerStateRestore dbgRestorer; DebugManager.flags.UseBindlessMode.set(1); - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); MockBindlesHeapsHelper *bindlessHeapHelperPtr = bindlessHeapHelper.get(); pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(bindlessHeapHelper.release()); MockGraphicsAllocation *alloc = new MockGraphicsAllocation; @@ -177,7 +177,7 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperWhenFreeGraphicsMemoryIs TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperPreviousAllocationThenItShouldBeReused) { DebugManagerStateRestore dbgRestorer; DebugManager.flags.UseBindlessMode.set(1); - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); MockBindlesHeapsHelper *bindlessHeapHelperPtr = bindlessHeapHelper.get(); pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->bindlessHeapsHelper.reset(bindlessHeapHelper.release()); MockGraphicsAllocation *alloc = new MockGraphicsAllocation; @@ -191,4 +191,11 @@ TEST_F(BindlessHeapsHelperTests, givenBindlessHeapHelperPreviousAllocationThenIt EXPECT_EQ(ssInHeapInfo.surfaceStateOffset, reusedSSinHeapInfo.surfaceStateOffset); EXPECT_EQ(ssInHeapInfo.ssPtr, reusedSSinHeapInfo.ssPtr); memManager->freeGraphicsMemory(alloc2); +} +TEST_F(BindlessHeapsHelperTests, givenDeviceWhenBindlessHeapHelperInitializedThenCorrectDeviceBitFieldIsUsed) { + DebugManagerStateRestore dbgRestorer; + DebugManager.flags.UseBindlessMode.set(1); + DeviceBitfield devBitfield = 7; + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), devBitfield); + EXPECT_EQ(reinterpret_cast(pDevice->getMemoryManager())->recentlyPassedDeviceBitfield, devBitfield); } \ No newline at end of file diff --git a/shared/test/common/mocks/mock_bindless_heaps_helper.h b/shared/test/common/mocks/mock_bindless_heaps_helper.h index 339cfb6338..732b7ddaed 100644 --- a/shared/test/common/mocks/mock_bindless_heaps_helper.h +++ b/shared/test/common/mocks/mock_bindless_heaps_helper.h @@ -12,7 +12,7 @@ using namespace NEO; class MockBindlesHeapsHelper : public BindlessHeapsHelper { public: using BaseClass = BindlessHeapsHelper; - MockBindlesHeapsHelper(MemoryManager *memManager, bool isMultiOsContextCapable, const uint32_t rootDeviceIndex) : BaseClass(memManager, isMultiOsContextCapable, rootDeviceIndex) { + MockBindlesHeapsHelper(MemoryManager *memManager, bool isMultiOsContextCapable, const uint32_t rootDeviceIndex, DeviceBitfield deviceBitfield) : BaseClass(memManager, isMultiOsContextCapable, rootDeviceIndex, deviceBitfield) { globalSsh = surfaceStateHeaps[BindlesHeapType::GLOBAL_SSH].get(); specialSsh = surfaceStateHeaps[BindlesHeapType::SPECIAL_SSH].get(); scratchSsh = surfaceStateHeaps[BindlesHeapType::SPECIAL_SSH].get(); 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 a3f11f134d..a8326e2b31 100644 --- a/shared/test/unit_test/encoders/test_encode_dispatch_kernel.cpp +++ b/shared/test/unit_test/encoders/test_encode_dispatch_kernel.cpp @@ -1158,7 +1158,8 @@ HWTEST_F(BindlessCommandEncodeStatesTesttt, givenBindlessKernelWhenBindlessModeE commandContainer->setDirtyStateForAllHeaps(false); pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, - pDevice->getRootDeviceIndex()); + pDevice->getRootDeviceIndex(), + pDevice->getDeviceBitfield()); uint32_t numBindingTable = 1; BINDING_TABLE_STATE bindingTableState = FamilyType::cmdInitBindingTableState; @@ -1195,7 +1196,8 @@ HWTEST_F(BindlessCommandEncodeStatesTesttt, givenBindfulKernelWhenBindlessModeEn commandContainer->setDirtyStateForAllHeaps(false); pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, - pDevice->getRootDeviceIndex()); + pDevice->getRootDeviceIndex(), + pDevice->getDeviceBitfield()); uint32_t numBindingTable = 1; BINDING_TABLE_STATE bindingTableState = FamilyType::cmdInitBindingTableState; @@ -1232,7 +1234,8 @@ HWTEST_F(BindlessCommandEncodeStatesTesttt, givenBindlessModeEnabledWhenDispatch commandContainer->setDirtyStateForAllHeaps(false); pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, - pDevice->getRootDeviceIndex()); + pDevice->getRootDeviceIndex(), + pDevice->getDeviceBitfield()); uint32_t numBindingTable = 1; BINDING_TABLE_STATE bindingTableState = FamilyType::cmdInitBindingTableState; @@ -1282,7 +1285,8 @@ HWTEST_F(BindlessCommandEncodeStatesTest, givenGlobalBindlessHeapsWhenDispatchin samplerState.init(); pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, - pDevice->getRootDeviceIndex()); + pDevice->getRootDeviceIndex(), + pDevice->getDeviceBitfield()); uint32_t dims[] = {2, 1, 1}; std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); @@ -1315,7 +1319,8 @@ HWTEST_F(BindlessCommandEncodeStatesTest, givenBindlessModeDisabledelWithSampler memset(&samplerState, 2, sizeof(SAMPLER_STATE)); pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, - pDevice->getRootDeviceIndex()); + pDevice->getRootDeviceIndex(), + pDevice->getDeviceBitfield()); uint32_t dims[] = {2, 1, 1}; std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); diff --git a/shared/test/unit_test/encoders/test_encode_states.cpp b/shared/test/unit_test/encoders/test_encode_states.cpp index 6327a90cab..5e6378b250 100644 --- a/shared/test/unit_test/encoders/test_encode_states.cpp +++ b/shared/test/unit_test/encoders/test_encode_states.cpp @@ -63,7 +63,8 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorWit uint32_t numSamplers = 1; pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, - pDevice->getRootDeviceIndex()); + pDevice->getRootDeviceIndex(), + pDevice->getDeviceBitfield()); uint32_t borderColorSize = 0x40; SAMPLER_BORDER_COLOR_STATE samplerState; @@ -84,7 +85,8 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorWit uint32_t numSamplers = 1; pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, - pDevice->getRootDeviceIndex()); + pDevice->getRootDeviceIndex(), + pDevice->getDeviceBitfield()); uint32_t borderColorSize = 0x40; SAMPLER_BORDER_COLOR_STATE samplerState; @@ -106,7 +108,8 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsRe uint32_t numSamplers = 1; pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, - pDevice->getRootDeviceIndex()); + pDevice->getRootDeviceIndex(), + pDevice->getDeviceBitfield()); uint32_t borderColorSize = 0x40; SAMPLER_BORDER_COLOR_STATE samplerState; @@ -124,7 +127,8 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsGr uint32_t numSamplers = 1; pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, - pDevice->getRootDeviceIndex()); + pDevice->getRootDeviceIndex(), + pDevice->getDeviceBitfield()); uint32_t borderColorSize = 0x40; SAMPLER_BORDER_COLOR_STATE samplerState; @@ -142,8 +146,8 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsBl uint32_t numSamplers = 1; pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, - pDevice->getRootDeviceIndex()); - + pDevice->getRootDeviceIndex(), + pDevice->getDeviceBitfield()); uint32_t borderColorSize = 0x40; SAMPLER_BORDER_COLOR_STATE samplerState; samplerState.init(); @@ -160,7 +164,8 @@ HWTEST_F(BindlessCommandEncodeStatesTest, GivenBindlessEnabledWhenBorderColorsAl uint32_t numSamplers = 1; pDevice->getExecutionEnvironment()->rootDeviceEnvironments[pDevice->getRootDeviceIndex()]->createBindlessHeapsHelper(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, - pDevice->getRootDeviceIndex()); + pDevice->getRootDeviceIndex(), + pDevice->getDeviceBitfield()); uint32_t borderColorSize = 0x40; SAMPLER_BORDER_COLOR_STATE samplerState; 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 b1c632e22a..d5330df5cb 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 @@ -77,7 +77,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenDirtyScratchAllocationO std::unique_ptr scratchController = std::make_unique(pDevice->getRootDeviceIndex(), *execEnv, *csr.getInternalAllocationStorage()); - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); bool gsbaStateDirty = false; bool frontEndStateDirty = false; scratchController->scratchDirty = true; @@ -97,7 +97,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenNotDirtyScratchAllocati std::unique_ptr scratchController = std::make_unique(pDevice->getRootDeviceIndex(), *execEnv, *csr.getInternalAllocationStorage()); - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); bool gsbaStateDirty = false; bool frontEndStateDirty = false; scratchController->scratchDirty = false; @@ -119,7 +119,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenPrivateScratchEnabledWh std::unique_ptr scratchController = std::make_unique(pDevice->getRootDeviceIndex(), *execEnv, *csr.getInternalAllocationStorage()); - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); bool gsbaStateDirty = false; bool frontEndStateDirty = false; scratchController->scratchDirty = true; @@ -141,7 +141,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, ScratchComtrolerTests, givenPrivateScratchDisabledW std::unique_ptr scratchController = std::make_unique(pDevice->getRootDeviceIndex(), *execEnv, *csr.getInternalAllocationStorage()); - auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex()); + auto bindlessHeapHelper = std::make_unique(pDevice->getMemoryManager(), pDevice->getNumGenericSubDevices() > 1, pDevice->getRootDeviceIndex(), pDevice->getDeviceBitfield()); bool gsbaStateDirty = false; bool frontEndStateDirty = false; scratchController->scratchDirty = true;