diff --git a/opencl/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp b/opencl/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp index 5768caf64e..2553590a28 100644 --- a/opencl/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp +++ b/opencl/test/unit_test/memory_manager/memory_manager_allocate_in_preferred_pool_tests.cpp @@ -1128,6 +1128,8 @@ static const AllocationType allocationHaveToBeForcedTo48Bit[] = { AllocationType::SHARED_RESOURCE_COPY, AllocationType::SURFACE_STATE_HEAP, AllocationType::TIMESTAMP_PACKET_TAG_BUFFER, + AllocationType::RING_BUFFER, + AllocationType::SEMAPHORE_BUFFER, }; static const AllocationType allocationHaveNotToBeForcedTo48Bit[] = { @@ -1150,8 +1152,6 @@ static const AllocationType allocationHaveNotToBeForcedTo48Bit[] = { AllocationType::TAG_BUFFER, AllocationType::GLOBAL_FENCE, AllocationType::WRITE_COMBINED, - AllocationType::RING_BUFFER, - AllocationType::SEMAPHORE_BUFFER, AllocationType::DEBUG_CONTEXT_SAVE_AREA, }; diff --git a/opencl/test/unit_test/xe_hpc_core/excludes_ocl_xe_hpc_core.cpp b/opencl/test/unit_test/xe_hpc_core/excludes_ocl_xe_hpc_core.cpp index f690094ac7..bdb87f619f 100644 --- a/opencl/test/unit_test/xe_hpc_core/excludes_ocl_xe_hpc_core.cpp +++ b/opencl/test/unit_test/xe_hpc_core/excludes_ocl_xe_hpc_core.cpp @@ -58,3 +58,5 @@ HWTEST_EXCLUDE_PRODUCT(EnqueueReadBufferStatefulTest, WhenReadingBufferStatefulT HWTEST_EXCLUDE_PRODUCT(EnqueueWriteBufferRectStatefulTest, WhenWritingBufferRectStatefulThenSuccessIsReturned, IGFX_XE_HPC_CORE); HWTEST_EXCLUDE_PRODUCT(CommandStreamReceiverFlushTaskTests, givenOverrideThreadArbitrationPolicyDebugVariableSetWhenFlushingThenRequestRequiredMode, IGFX_XE_HPC_CORE); HWTEST_EXCLUDE_PRODUCT(XeHPAndLaterAubCommandStreamReceiverWithoutFixtureTests, GivenCopyHostPtrAndHostNoAccessAndReadOnlyFlagsWhenAllocatingBufferThenAllocationIsCopiedToEveryTile, IGFX_XE_HPC_CORE); +HWTEST_EXCLUDE_PRODUCT(GetAllocationDataTestHw, givenRingBufferAllocationWhenGetAllocationDataIsCalledThenItHasProperFieldsSet, IGFX_XE_HPC_CORE); +HWTEST_EXCLUDE_PRODUCT(GetAllocationDataTestHw, givenSemaphoreBufferAllocationWhenGetAllocationDataIsCalledThenItHasProperFieldsSet, IGFX_XE_HPC_CORE); diff --git a/shared/source/debug_settings/debug_variables_base.inl b/shared/source/debug_settings/debug_variables_base.inl index df9e7ad870..13342d1f18 100644 --- a/shared/source/debug_settings/debug_variables_base.inl +++ b/shared/source/debug_settings/debug_variables_base.inl @@ -283,7 +283,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionNewResourceTlbFlush, -1, "-1: dr DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionDisableMonitorFence, -1, "Disable dispatching monitor fence commands") DECLARE_DEBUG_VARIABLE(int32_t, EnableDirectSubmissionController, -1, "Enable direct submission terminating after given timeout, -1: default, 0: disabled, 1: enabled") DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionControllerTimeout, -1, "Set direct submission controller timeout, -1: default 5 ms, >=0: timeout in ms") -DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionForceLocalMemoryStorageMode, -1, "Force first memory bank storage for command/ring/semaphore buffer, -1: default - for multiOsContextCapable engine, 0: disabled, 1: for multiOsContextCapable engine, 2: for all engines") +DECLARE_DEBUG_VARIABLE(int32_t, DirectSubmissionForceLocalMemoryStorageMode, -1, "Force local memory storage for command/ring/semaphore buffer, -1: default - for all engines, 0: disabled, 1: for multiOsContextCapable engine, 2: for all engines") /* IMPLICIT SCALING */ DECLARE_DEBUG_VARIABLE(int32_t, EnableWalkerPartition, -1, "-1: default, 0: disable, 1: enable, Enables Walker Partitioning via WPARID.") diff --git a/shared/source/memory_manager/definitions/storage_info.cpp b/shared/source/memory_manager/definitions/storage_info.cpp index 032a2bfb72..d815966c14 100644 --- a/shared/source/memory_manager/definitions/storage_info.cpp +++ b/shared/source/memory_manager/definitions/storage_info.cpp @@ -154,13 +154,13 @@ StorageInfo MemoryManager::createStorageInfoFromProperties(const AllocationPrope break; } - bool forceLocalMemoryForDirectSubmission = properties.flags.multiOsContextCapable; + bool forceLocalMemoryForDirectSubmission = true; switch (DebugManager.flags.DirectSubmissionForceLocalMemoryStorageMode.get()) { case 0: forceLocalMemoryForDirectSubmission = false; break; - case 2: - forceLocalMemoryForDirectSubmission = true; + case 1: + forceLocalMemoryForDirectSubmission = properties.flags.multiOsContextCapable; break; default: break; @@ -170,11 +170,13 @@ StorageInfo MemoryManager::createStorageInfoFromProperties(const AllocationPrope if (properties.allocationType == AllocationType::COMMAND_BUFFER || properties.allocationType == AllocationType::RING_BUFFER || properties.allocationType == AllocationType::SEMAPHORE_BUFFER) { - storageInfo.memoryBanks = {}; - for (auto bank = 0u; bank < deviceCount; bank++) { - if (allTilesValue.test(bank)) { - storageInfo.memoryBanks.set(bank); - break; + if (properties.flags.multiOsContextCapable) { + storageInfo.memoryBanks = {}; + for (auto bank = 0u; bank < deviceCount; bank++) { + if (allTilesValue.test(bank)) { + storageInfo.memoryBanks.set(bank); + break; + } } } UNRECOVERABLE_IF(storageInfo.memoryBanks.none()); diff --git a/shared/source/memory_manager/memory_manager.cpp b/shared/source/memory_manager/memory_manager.cpp index 2d0aa14b7d..28c14ac152 100644 --- a/shared/source/memory_manager/memory_manager.cpp +++ b/shared/source/memory_manager/memory_manager.cpp @@ -407,6 +407,8 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo case AllocationType::TIMESTAMP_PACKET_TAG_BUFFER: case AllocationType::DEBUG_MODULE_AREA: case AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER: + case AllocationType::RING_BUFFER: + case AllocationType::SEMAPHORE_BUFFER: allocationData.flags.resource48Bit = true; break; default: diff --git a/shared/source/xe_hpc_core/hw_helper_xe_hpc_core.cpp b/shared/source/xe_hpc_core/hw_helper_xe_hpc_core.cpp index 3db19f25a9..6690587e14 100644 --- a/shared/source/xe_hpc_core/hw_helper_xe_hpc_core.cpp +++ b/shared/source/xe_hpc_core/hw_helper_xe_hpc_core.cpp @@ -239,13 +239,13 @@ void HwHelperHw::setExtraAllocationData(AllocationData &allocationData, allocationData.flags.useSystemMemory = false; } - bool forceLocalMemoryForDirectSubmission = properties.flags.multiOsContextCapable; + bool forceLocalMemoryForDirectSubmission = true; switch (DebugManager.flags.DirectSubmissionForceLocalMemoryStorageMode.get()) { case 0: forceLocalMemoryForDirectSubmission = false; break; - case 2: - forceLocalMemoryForDirectSubmission = true; + case 1: + forceLocalMemoryForDirectSubmission = properties.flags.multiOsContextCapable; break; default: break; @@ -257,7 +257,6 @@ void HwHelperHw::setExtraAllocationData(AllocationData &allocationData, properties.allocationType == AllocationType::SEMAPHORE_BUFFER) { allocationData.flags.useSystemMemory = false; allocationData.flags.requiresCpuAccess = true; - allocationData.flags.resource48Bit = true; } } diff --git a/shared/test/unit_test/memory_manager/memory_manager_allocate_in_device_pool_tests.cpp b/shared/test/unit_test/memory_manager/memory_manager_allocate_in_device_pool_tests.cpp index 1d26ffc433..fb215bff63 100644 --- a/shared/test/unit_test/memory_manager/memory_manager_allocate_in_device_pool_tests.cpp +++ b/shared/test/unit_test/memory_manager/memory_manager_allocate_in_device_pool_tests.cpp @@ -725,7 +725,6 @@ HWTEST2_F(MemoryManagerDirectSubmissionImplicitScalingTest, givenDirectSubmissio } else { if (allocationType != AllocationType::COMMAND_BUFFER) { EXPECT_NE(firstTileMask, allocation->storageInfo.getMemoryBanks()); - EXPECT_NE(firstTileMask, allocation->storageInfo.getMemoryBanks()); } } memoryManager->freeGraphicsMemory(allocation); @@ -749,4 +748,22 @@ HWTEST2_F(MemoryManagerDirectSubmissionImplicitScalingTest, givenDirectSubmissio memoryManager->freeGraphicsMemory(allocation); } } -} \ No newline at end of file +} + +HWTEST2_F(MemoryManagerDirectSubmissionImplicitScalingTest, givenDirectSubmissionForceLocalMemoryStorageDefaultModeWhenAllocatingMemoryForCommandOrRingOrSemaphoreBufferThenFirstBankIsSelected, IsXeHpcCore) { + DebugManager.flags.DirectSubmissionForceLocalMemoryStorageMode.set(-1); + for (auto &multiTile : ::testing::Bool()) { + for (auto &allocationType : {AllocationType::COMMAND_BUFFER, AllocationType::RING_BUFFER, AllocationType::SEMAPHORE_BUFFER}) { + allocationProperties->allocationType = allocationType; + allocationProperties->flags.multiOsContextCapable = multiTile; + auto allocation = memoryManager->allocateGraphicsMemoryInPreferredPool(*allocationProperties, nullptr); + + EXPECT_NE(nullptr, allocation); + + EXPECT_EQ(MemoryPool::LocalMemory, allocation->getMemoryPool()); + EXPECT_EQ(firstTileMask, allocation->storageInfo.getMemoryBanks()); + + memoryManager->freeGraphicsMemory(allocation); + } + } +} diff --git a/shared/test/unit_test/memory_manager/storage_info_tests.cpp b/shared/test/unit_test/memory_manager/storage_info_tests.cpp index 203def3cf1..f392d9da77 100644 --- a/shared/test/unit_test/memory_manager/storage_info_tests.cpp +++ b/shared/test/unit_test/memory_manager/storage_info_tests.cpp @@ -596,11 +596,12 @@ TEST_F(MultiDeviceStorageInfoTest, givenDirectSubmissionForceLocalMemoryStorageE } } -TEST_F(MultiDeviceStorageInfoTest, givenDirectSubmissionForceLocalMemoryStorageEnabledForAllEnginesWhenCreatingStorageInfoForCommandRingOrSemaphoreBufferThenFirstBankIsSelected) { +TEST_F(MultiDeviceStorageInfoTest, givenDirectSubmissionForceLocalMemoryStorageEnabledForAllEnginesWhenCreatingStorageInfoForCommandRingOrSemaphoreBufferThenFirstBankIsSelectedOnlyForMultiTile) { DebugManagerStateRestore restorer; DebugManager.flags.DirectSubmissionForceLocalMemoryStorageMode.set(2); constexpr uint32_t firstAvailableTileMask = 2u; + constexpr uint32_t leastOccupiedTileMask = 4u; memoryManager->internalLocalMemoryUsageBankSelector[mockRootDeviceIndex]->reserveOnBanks(firstAvailableTileMask, MemoryConstants::pageSize2Mb); EXPECT_NE(1u, memoryManager->internalLocalMemoryUsageBankSelector[mockRootDeviceIndex]->getLeastOccupiedBank(allTilesMask)); @@ -616,7 +617,11 @@ TEST_F(MultiDeviceStorageInfoTest, givenDirectSubmissionForceLocalMemoryStorageE AllocationProperties properties{mockRootDeviceIndex, false, numDevices * MemoryConstants::pageSize64k, allocationType, false, affinityMaskHelper.getGenericSubDevicesMask()}; properties.flags.multiOsContextCapable = multiTile; auto storageInfo = memoryManager->createStorageInfoFromProperties(properties); - EXPECT_EQ(DeviceBitfield{firstAvailableTileMask}, storageInfo.memoryBanks); + if (multiTile) { + EXPECT_EQ(DeviceBitfield{firstAvailableTileMask}, storageInfo.memoryBanks); + } else { + EXPECT_EQ(DeviceBitfield{leastOccupiedTileMask}, storageInfo.memoryBanks); + } } } -} \ No newline at end of file +}