diff --git a/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp b/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp index 98da3b0a53..dde8258285 100644 --- a/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp +++ b/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp @@ -840,12 +840,11 @@ TEST(GmmTest, givenHwInfoWhenDeviceIsCreatedThenSetThisHwInfoToGmmHelper) { TEST(GmmTest, givenAllocationTypeWhenGettingUsageTypeThenReturnCorrectValue) { MockExecutionEnvironment mockExecutionEnvironment{}; const auto &productHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); - for (uint32_t i = 0; i < static_cast(AllocationType::COUNT); i++) { auto allocationType = static_cast(i); for (auto forceUncached : {true, false}) { - auto usage = CacheSettingsHelper::getGmmUsageType(allocationType, forceUncached, *defaultHwInfo); + auto usage = CacheSettingsHelper::getGmmUsageType(allocationType, forceUncached, productHelper); auto expectedUsage = GMM_RESOURCE_USAGE_UNKNOWN; switch (allocationType) { @@ -880,11 +879,13 @@ TEST(GmmTest, givenAllocationTypeWhenGettingUsageTypeThenReturnCorrectValue) { TEST(GmmTest, givenForceAllResourcesUncachedFlagSetWhenGettingUsageTypeThenReturnUncached) { DebugManagerStateRestore restore; DebugManager.flags.ForceAllResourcesUncached.set(true); + MockExecutionEnvironment mockExecutionEnvironment{}; + const auto &productHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); for (uint32_t i = 0; i < static_cast(AllocationType::COUNT); i++) { auto allocationType = static_cast(i); - auto usage = CacheSettingsHelper::getGmmUsageType(allocationType, false, *defaultHwInfo); + auto usage = CacheSettingsHelper::getGmmUsageType(allocationType, false, productHelper); auto expectedUsage = GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED; if (allocationType == AllocationType::PREEMPTION) { @@ -920,44 +921,52 @@ TEST(GmmTest, givenUsageTypeWhenAskingIfUncachableThenReturnCorrectValue) { TEST(GmmTest, givenInternalHeapOrLinearStreamWhenDebugFlagIsSetThenReturnUncachedType) { DebugManagerStateRestore restore; DebugManager.flags.DisableCachingForHeaps.set(true); + MockExecutionEnvironment mockExecutionEnvironment{}; + const auto &productHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); - auto usage = CacheSettingsHelper::getGmmUsageType(AllocationType::INTERNAL_HEAP, false, *defaultHwInfo); + auto usage = CacheSettingsHelper::getGmmUsageType(AllocationType::INTERNAL_HEAP, false, productHelper); EXPECT_EQ(GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER_CACHELINE_MISALIGNED, usage); - usage = CacheSettingsHelper::getGmmUsageType(AllocationType::LINEAR_STREAM, false, *defaultHwInfo); + usage = CacheSettingsHelper::getGmmUsageType(AllocationType::LINEAR_STREAM, false, productHelper); EXPECT_EQ(GMM_RESOURCE_USAGE_OCL_SYSTEM_MEMORY_BUFFER_CACHELINE_MISALIGNED, usage); } TEST(GmmTest, givenConstSurfaceWhenDebugFlagIsSetThenReturnUncachedType) { DebugManagerStateRestore restore; DebugManager.flags.ForceL1Caching.set(false); + MockExecutionEnvironment mockExecutionEnvironment{}; + const auto &productHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); EXPECT_EQ(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED, - CacheSettingsHelper::getGmmUsageType(AllocationType::CONSTANT_SURFACE, false, *defaultHwInfo)); + CacheSettingsHelper::getGmmUsageType(AllocationType::CONSTANT_SURFACE, false, productHelper)); } TEST(GmmTest, givenUncachedDebugFlagMaskSetWhenAskingForUsageTypeThenReturnUncached) { DebugManagerStateRestore restore; + MockExecutionEnvironment mockExecutionEnvironment{}; + const auto &productHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); + constexpr int64_t bufferMask = 1 << (static_cast(AllocationType::BUFFER) - 1); constexpr int64_t imageMask = 1 << (static_cast(AllocationType::IMAGE) - 1); DebugManager.flags.ForceUncachedGmmUsageType.set(bufferMask | imageMask); EXPECT_EQ(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED, - CacheSettingsHelper::getGmmUsageType(AllocationType::BUFFER, false, *defaultHwInfo)); + CacheSettingsHelper::getGmmUsageType(AllocationType::BUFFER, false, productHelper)); EXPECT_EQ(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED, - CacheSettingsHelper::getGmmUsageType(AllocationType::IMAGE, false, *defaultHwInfo)); + CacheSettingsHelper::getGmmUsageType(AllocationType::IMAGE, false, productHelper)); EXPECT_NE(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED, - CacheSettingsHelper::getGmmUsageType(AllocationType::BUFFER_HOST_MEMORY, false, *defaultHwInfo)); + CacheSettingsHelper::getGmmUsageType(AllocationType::BUFFER_HOST_MEMORY, false, productHelper)); } TEST(GmmTest, givenAllocationForStatefulAccessWhenDebugFlagIsSetThenReturnUncachedType) { DebugManagerStateRestore restore; DebugManager.flags.DisableCachingForStatefulBufferAccess.set(true); - + MockExecutionEnvironment mockExecutionEnvironment{}; + const auto &productHelper = mockExecutionEnvironment.rootDeviceEnvironments[0]->getHelper(); for (auto allocType : {AllocationType::BUFFER, AllocationType::BUFFER_HOST_MEMORY, AllocationType::EXTERNAL_HOST_PTR, @@ -970,7 +979,7 @@ TEST(GmmTest, givenAllocationForStatefulAccessWhenDebugFlagIsSetThenReturnUncach AllocationType::SVM_ZERO_COPY, AllocationType::UNIFIED_SHARED_MEMORY}) { - EXPECT_EQ(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED, CacheSettingsHelper::getGmmUsageType(allocType, false, *defaultHwInfo)); + EXPECT_EQ(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED, CacheSettingsHelper::getGmmUsageType(allocType, false, productHelper)); } } diff --git a/shared/source/gmm_helper/cache_settings_helper.cpp b/shared/source/gmm_helper/cache_settings_helper.cpp index a5b270ac4f..42c6ff23b7 100644 --- a/shared/source/gmm_helper/cache_settings_helper.cpp +++ b/shared/source/gmm_helper/cache_settings_helper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Intel Corporation + * Copyright (C) 2022-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -14,7 +14,7 @@ namespace NEO { -GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getGmmUsageType(AllocationType allocationType, bool forceUncached, const HardwareInfo &hwInfo) { +GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getGmmUsageType(AllocationType allocationType, bool forceUncached, const ProductHelper &productHelper) { if (DebugManager.flags.ForceUncachedGmmUsageType.get()) { if ((1llu << (static_cast(allocationType) - 1)) & DebugManager.flags.ForceUncachedGmmUsageType.get()) { forceUncached = true; @@ -24,12 +24,11 @@ GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getGmmUsageType(AllocationType if (forceUncached || DebugManager.flags.ForceAllResourcesUncached.get()) { return getDefaultUsageTypeWithCachingDisabled(allocationType); } else { - return getDefaultUsageTypeWithCachingEnabled(allocationType, hwInfo); + return getDefaultUsageTypeWithCachingEnabled(allocationType, productHelper); } } -GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCachingEnabled(AllocationType allocationType, const HardwareInfo &hwInfo) { - const auto productHelper = ProductHelper::get(hwInfo.platform.eProductFamily); +GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCachingEnabled(AllocationType allocationType, const ProductHelper &productHelper) { switch (allocationType) { case AllocationType::IMAGE: @@ -62,7 +61,7 @@ GMM_RESOURCE_USAGE_TYPE_ENUM CacheSettingsHelper::getDefaultUsageTypeWithCaching return GMM_RESOURCE_USAGE_OCL_BUFFER; case AllocationType::GPU_TIMESTAMP_DEVICE_BUFFER: case AllocationType::TIMESTAMP_PACKET_TAG_BUFFER: - if (productHelper->isDcFlushAllowed()) { + if (productHelper.isDcFlushAllowed()) { return getDefaultUsageTypeWithCachingDisabled(allocationType); } return GMM_RESOURCE_USAGE_OCL_BUFFER; diff --git a/shared/source/gmm_helper/cache_settings_helper.h b/shared/source/gmm_helper/cache_settings_helper.h index 6f9c3803f1..f64f2e9b15 100644 --- a/shared/source/gmm_helper/cache_settings_helper.h +++ b/shared/source/gmm_helper/cache_settings_helper.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 Intel Corporation + * Copyright (C) 2022-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -15,9 +15,10 @@ inline constexpr uint32_t unknownMocs = GMM_RESOURCE_USAGE_UNKNOWN; namespace NEO { enum class AllocationType; struct HardwareInfo; +class ProductHelper; struct CacheSettingsHelper { - static GMM_RESOURCE_USAGE_TYPE_ENUM getGmmUsageType(AllocationType allocationType, bool forceUncached, const HardwareInfo &hwInfo); + static GMM_RESOURCE_USAGE_TYPE_ENUM getGmmUsageType(AllocationType allocationType, bool forceUncached, const ProductHelper &productHelper); static constexpr bool isUncachedType(GMM_RESOURCE_USAGE_TYPE_ENUM gmmResourceUsageType) { return ((gmmResourceUsageType == GMM_RESOURCE_USAGE_OCL_BUFFER_CSR_UC) || @@ -26,7 +27,7 @@ struct CacheSettingsHelper { } protected: - static GMM_RESOURCE_USAGE_TYPE_ENUM getDefaultUsageTypeWithCachingEnabled(AllocationType allocationType, const HardwareInfo &hwInfo); + static GMM_RESOURCE_USAGE_TYPE_ENUM getDefaultUsageTypeWithCachingEnabled(AllocationType allocationType, const ProductHelper &productHelper); static GMM_RESOURCE_USAGE_TYPE_ENUM getDefaultUsageTypeWithCachingDisabled(AllocationType allocationType); }; } // namespace NEO \ No newline at end of file diff --git a/shared/source/gmm_helper/gmm.cpp b/shared/source/gmm_helper/gmm.cpp index 013b5975b1..b1d656ffba 100644 --- a/shared/source/gmm_helper/gmm.cpp +++ b/shared/source/gmm_helper/gmm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2022 Intel Corporation + * Copyright (C) 2018-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -118,10 +118,10 @@ void Gmm::setupImageResourceParams(ImageInfo &imgInfo, bool preferCompressed) { resourceParams.Flags.Info.Linear = imgInfo.linearStorage; auto &gfxCoreHelper = gmmHelper->getRootDeviceEnvironment().getHelper(); - + auto &productHelper = gmmHelper->getRootDeviceEnvironment().getHelper(); resourceParams.NoGfxMemory = 1; // dont allocate, only query for params - resourceParams.Usage = CacheSettingsHelper::getGmmUsageType(AllocationType::IMAGE, false, *gmmHelper->getHardwareInfo()); + resourceParams.Usage = CacheSettingsHelper::getGmmUsageType(AllocationType::IMAGE, false, productHelper); resourceParams.Format = imgInfo.surfaceFormat->GMMSurfaceFormat; resourceParams.Flags.Gpu.Texture = 1; diff --git a/shared/source/helpers/state_base_address_base.inl b/shared/source/helpers/state_base_address_base.inl index 3e0820b52e..14d937a983 100644 --- a/shared/source/helpers/state_base_address_base.inl +++ b/shared/source/helpers/state_base_address_base.inl @@ -1,11 +1,12 @@ /* - * Copyright (C) 2019-2022 Intel Corporation + * Copyright (C) 2019-2023 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "shared/source/command_stream/memory_compression_state.h" +#include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/gmm_helper/cache_settings_helper.h" #include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/helpers/cache_policy.h" @@ -74,7 +75,8 @@ void StateBaseAddressHelper::programStateBaseAddress( args.stateBaseAddressCmd->setInstructionBufferSizeModifyEnable(true); args.stateBaseAddressCmd->setInstructionBufferSize(MemoryConstants::sizeOf4GBinPageEntities); - auto resourceUsage = CacheSettingsHelper::getGmmUsageType(AllocationType::INTERNAL_HEAP, DebugManager.flags.DisableCachingForHeaps.get(), *args.gmmHelper->getHardwareInfo()); + auto &productHelper = args.gmmHelper->getRootDeviceEnvironment().template getHelper(); + auto resourceUsage = CacheSettingsHelper::getGmmUsageType(AllocationType::INTERNAL_HEAP, DebugManager.flags.DisableCachingForHeaps.get(), productHelper); args.stateBaseAddressCmd->setInstructionMemoryObjectControlState(args.gmmHelper->getMOCS(resourceUsage)); } diff --git a/shared/source/helpers/state_base_address_xehp_and_later.inl b/shared/source/helpers/state_base_address_xehp_and_later.inl index 108d5b9875..847076c588 100644 --- a/shared/source/helpers/state_base_address_xehp_and_later.inl +++ b/shared/source/helpers/state_base_address_xehp_and_later.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2022 Intel Corporation + * Copyright (C) 2021-2023 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -44,7 +44,9 @@ void StateBaseAddressHelper::appendStateBaseAddressParameters( args.stateBaseAddressCmd->setBindlessSamplerStateBaseAddressModifyEnable(true); - auto heapResourceUsage = CacheSettingsHelper::getGmmUsageType(AllocationType::INTERNAL_HEAP, DebugManager.flags.DisableCachingForHeaps.get(), *args.gmmHelper->getHardwareInfo()); + auto &productHelper = args.gmmHelper->getRootDeviceEnvironment().template getHelper(); + + auto heapResourceUsage = CacheSettingsHelper::getGmmUsageType(AllocationType::INTERNAL_HEAP, DebugManager.flags.DisableCachingForHeaps.get(), productHelper); auto heapMocsValue = args.gmmHelper->getMOCS(heapResourceUsage); args.stateBaseAddressCmd->setSurfaceStateMemoryObjectControlState(heapMocsValue); diff --git a/shared/source/memory_manager/os_agnostic_memory_manager.cpp b/shared/source/memory_manager/os_agnostic_memory_manager.cpp index fee0ab34fb..b45cd3c21e 100644 --- a/shared/source/memory_manager/os_agnostic_memory_manager.cpp +++ b/shared/source/memory_manager/os_agnostic_memory_manager.cpp @@ -115,11 +115,12 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryWithAlignment auto &gfxCoreHelper = rootDeviceEnvironment.getHelper(); if (gfxCoreHelper.compressedBuffersSupported(*pHwInfo) && allocationData.flags.preferCompressed) { + auto &productHelper = rootDeviceEnvironment.getHelper(); auto gmm = std::make_unique(rootDeviceEnvironment.getGmmHelper(), allocationData.hostPtr, sizeAligned, alignment, - CacheSettingsHelper::getGmmUsageType(memoryAllocation->getAllocationType(), !!allocationData.flags.uncacheable, *pHwInfo), + CacheSettingsHelper::getGmmUsageType(memoryAllocation->getAllocationType(), !!allocationData.flags.uncacheable, productHelper), true, allocationData.storageInfo, true); @@ -170,11 +171,12 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory64kb(const Al if (memoryAllocation) { static_cast(memoryAllocation)->overrideMemoryPool(MemoryPool::System64KBPages); if (memoryAllocation->getDefaultGmm() == nullptr) { + auto &productHelper = rootDeviceEnvironment.getHelper(); auto gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), allocationData.hostPtr, allocationDataAlign.size, allocationDataAlign.alignment, - CacheSettingsHelper::getGmmUsageType(memoryAllocation->getAllocationType(), !!allocationData.flags.uncacheable, *hwInfo), + CacheSettingsHelper::getGmmUsageType(memoryAllocation->getAllocationType(), !!allocationData.flags.uncacheable, productHelper), allocationData.flags.preferCompressed, allocationData.storageInfo, true); memoryAllocation->setDefaultGmm(gmm.release()); @@ -391,13 +393,12 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocatePhysicalLocalDeviceMemory(c std::unique_ptr gmm; size_t sizeAligned64k = 0; sizeAligned64k = alignUp(allocationData.size, MemoryConstants::pageSize64k); - - auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo(); + auto &productHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHelper(); gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), nullptr, sizeAligned64k, MemoryConstants::pageSize64k, - CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable, *hwInfo), + CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable, productHelper), allocationData.flags.preferCompressed, allocationData.storageInfo, true); @@ -424,10 +425,10 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocatePhysicalLocalDeviceMemory(c GraphicsAllocation *OsAgnosticMemoryManager::allocatePhysicalDeviceMemory(const AllocationData &allocationData, AllocationStatus &status) { status = AllocationStatus::Error; - auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo(); + auto &productHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHelper(); auto gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), allocationData.hostPtr, - allocationData.size, 0u, CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable, *hwInfo), + allocationData.size, 0u, CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable, productHelper), allocationData.flags.preferCompressed, allocationData.storageInfo, true); GraphicsAllocation *alloc = nullptr; @@ -447,10 +448,10 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocatePhysicalDeviceMemory(const } GraphicsAllocation *OsAgnosticMemoryManager::allocateMemoryByKMD(const AllocationData &allocationData) { - auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo(); + auto &productHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHelper(); auto gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), allocationData.hostPtr, - allocationData.size, 0u, CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable, *hwInfo), + allocationData.size, 0u, CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable, productHelper), allocationData.flags.preferCompressed, allocationData.storageInfo, true); GraphicsAllocation *alloc = nullptr; @@ -596,12 +597,13 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryInDevicePool( sizeAligned64k = alignUp(allocationData.size, MemoryConstants::pageSize64k); if (DebugManager.flags.RenderCompressedBuffersEnabled.get() && allocationData.flags.preferCompressed) { - auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo(); + auto &productHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHelper(); + gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), allocationData.hostPtr, sizeAligned64k, MemoryConstants::pageSize64k, - CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable, *hwInfo), + CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable, productHelper), true, allocationData.storageInfo, true); diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index 494a1695cd..a695c6e72e 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -571,11 +571,12 @@ bool DrmMemoryManager::mapPhysicalToVirtualMemory(GraphicsAllocation *physicalAl } GraphicsAllocation *DrmMemoryManager::allocatePhysicalDeviceMemory(const AllocationData &allocationData, AllocationStatus &status) { - auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo(); StorageInfo systemMemoryStorageInfo = {}; + auto &productHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHelper(); + auto gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), nullptr, - allocationData.size, 0u, CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable, *hwInfo), false, systemMemoryStorageInfo, true); + allocationData.size, 0u, CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable, productHelper), false, systemMemoryStorageInfo, true); size_t bufferSize = allocationData.size; GemCreate create{}; @@ -600,11 +601,11 @@ GraphicsAllocation *DrmMemoryManager::allocatePhysicalDeviceMemory(const Allocat } GraphicsAllocation *DrmMemoryManager::allocateMemoryByKMD(const AllocationData &allocationData) { - auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo(); + auto &productHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHelper(); StorageInfo systemMemoryStorageInfo = {}; auto gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), allocationData.hostPtr, - allocationData.size, 0u, CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable, *hwInfo), false, systemMemoryStorageInfo, true); + allocationData.size, 0u, CacheSettingsHelper::getGmmUsageType(allocationData.type, allocationData.flags.uncacheable, productHelper), false, systemMemoryStorageInfo, true); size_t bufferSize = allocationData.size; uint64_t gpuRange = acquireGpuRange(bufferSize, allocationData.rootDeviceIndex, HeapIndex::HEAP_STANDARD64KB); @@ -836,8 +837,8 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromMultipleShared totalSize, MemoryPool::LocalMemory); drmAllocation->storageInfo = allocationData.storageInfo; - auto gmmHelper = executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex]->getGmmHelper(); + auto &productHelper = gmmHelper->getRootDeviceEnvironment().getHelper(); for (i = 0u; i < handles.size(); i++) { auto bo = bos[i]; StorageInfo limitedStorageInfo = allocationData.storageInfo; @@ -846,7 +847,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromMultipleShared nullptr, bo->peekSize(), 0u, - CacheSettingsHelper::getGmmUsageType(drmAllocation->getAllocationType(), false, *gmmHelper->getHardwareInfo()), + CacheSettingsHelper::getGmmUsageType(drmAllocation->getAllocationType(), false, productHelper), false, allocationData.storageInfo, true); @@ -1441,11 +1442,12 @@ void createColouredGmms(GmmHelper *gmmHelper, DrmAllocation &allocation, const S remainingSize -= currentSize; StorageInfo limitedStorageInfo = storageInfo; limitedStorageInfo.memoryBanks &= (1u << (handleId % banksCnt)); + auto &productHelper = gmmHelper->getRootDeviceEnvironment().getHelper(); auto gmm = new Gmm(gmmHelper, nullptr, currentSize, 0u, - CacheSettingsHelper::getGmmUsageType(allocation.getAllocationType(), false, *gmmHelper->getHardwareInfo()), + CacheSettingsHelper::getGmmUsageType(allocation.getAllocationType(), false, productHelper), compression, limitedStorageInfo, true); @@ -1455,12 +1457,13 @@ void createColouredGmms(GmmHelper *gmmHelper, DrmAllocation &allocation, const S void fillGmmsInAllocation(GmmHelper *gmmHelper, DrmAllocation *allocation, const StorageInfo &storageInfo) { auto alignedSize = alignUp(allocation->getUnderlyingBufferSize(), MemoryConstants::pageSize64k); + auto &productHelper = gmmHelper->getRootDeviceEnvironment().getHelper(); for (auto handleId = 0u; handleId < storageInfo.getNumBanks(); handleId++) { StorageInfo limitedStorageInfo = storageInfo; limitedStorageInfo.memoryBanks &= 1u << handleId; limitedStorageInfo.pageTablesVisibility &= 1u << handleId; auto gmm = new Gmm(gmmHelper, nullptr, alignedSize, 0u, - CacheSettingsHelper::getGmmUsageType(allocation->getAllocationType(), false, *gmmHelper->getHardwareInfo()), false, limitedStorageInfo, true); + CacheSettingsHelper::getGmmUsageType(allocation->getAllocationType(), false, productHelper), false, limitedStorageInfo, true); allocation->setGmm(gmm, handleId); } } @@ -1521,7 +1524,6 @@ void DrmMemoryManager::cleanupBeforeReturn(const AllocationData &allocationData, } GraphicsAllocation *DrmMemoryManager::allocatePhysicalLocalDeviceMemory(const AllocationData &allocationData, AllocationStatus &status) { - auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo(); std::unique_ptr gmm; size_t sizeAligned = 0; @@ -1531,11 +1533,12 @@ GraphicsAllocation *DrmMemoryManager::allocatePhysicalLocalDeviceMemory(const Al sizeAligned = alignUp(allocationData.size, MemoryConstants::pageSize64k); if (createSingleHandle) { + auto &productHelper = gmmHelper->getRootDeviceEnvironment().getHelper(); gmm = std::make_unique(gmmHelper, nullptr, sizeAligned, 0u, - CacheSettingsHelper::getGmmUsageType(allocationData.type, !!allocationData.flags.uncacheable, *hwInfo), + CacheSettingsHelper::getGmmUsageType(allocationData.type, !!allocationData.flags.uncacheable, productHelper), allocationData.flags.preferCompressed, allocationData.storageInfo, true); @@ -1615,12 +1618,12 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A sizeAligned = alignUp(allocationData.size, MemoryConstants::pageSize64k); } if (createSingleHandle) { - + auto &productHelper = gmmHelper->getRootDeviceEnvironment().getHelper(); gmm = std::make_unique(gmmHelper, nullptr, sizeAligned, 0u, - CacheSettingsHelper::getGmmUsageType(allocationData.type, !!allocationData.flags.uncacheable, *hwInfo), + CacheSettingsHelper::getGmmUsageType(allocationData.type, !!allocationData.flags.uncacheable, productHelper), allocationData.flags.preferCompressed, allocationData.storageInfo, true); diff --git a/shared/source/os_interface/linux/drm_neo.cpp b/shared/source/os_interface/linux/drm_neo.cpp index 40aa0a45a1..c0ffe69dab 100644 --- a/shared/source/os_interface/linux/drm_neo.cpp +++ b/shared/source/os_interface/linux/drm_neo.cpp @@ -1333,8 +1333,6 @@ uint64_t Drm::getPatIndex(Gmm *gmm, AllocationType allocationType, CacheRegion c return static_cast(DebugManager.flags.OverridePatIndex.get()); } - auto hwInfo = rootDeviceEnvironment.getHardwareInfo(); - if (!this->vmBindPatIndexProgrammingSupported) { return CommonConstants::unsupportedPatIndex; } @@ -1343,7 +1341,7 @@ uint64_t Drm::getPatIndex(Gmm *gmm, AllocationType allocationType, CacheRegion c auto &productHelper = rootDeviceEnvironment.getProductHelper(); GMM_RESOURCE_INFO *resourceInfo = nullptr; - GMM_RESOURCE_USAGE_TYPE usageType = CacheSettingsHelper::getGmmUsageType(allocationType, false, *hwInfo); + GMM_RESOURCE_USAGE_TYPE usageType = CacheSettingsHelper::getGmmUsageType(allocationType, false, productHelper); bool cachable = !CacheSettingsHelper::isUncachedType(usageType); bool compressed = false; diff --git a/shared/source/os_interface/windows/wddm_memory_manager.cpp b/shared/source/os_interface/windows/wddm_memory_manager.cpp index 150a65a2bc..08d10c5e80 100644 --- a/shared/source/os_interface/windows/wddm_memory_manager.cpp +++ b/shared/source/os_interface/windows/wddm_memory_manager.cpp @@ -87,11 +87,11 @@ bool WddmMemoryManager::mapPhysicalToVirtualMemory(GraphicsAllocation *physicalA } GraphicsAllocation *WddmMemoryManager::allocatePhysicalDeviceMemory(const AllocationData &allocationData, AllocationStatus &status) { - auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo(); + auto &productHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHelper(); StorageInfo systemMemoryStorageInfo = {}; auto gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), nullptr, allocationData.size, 0u, - CacheSettingsHelper::getGmmUsageType(allocationData.type, !!allocationData.flags.uncacheable, *hwInfo), false, systemMemoryStorageInfo, true); + CacheSettingsHelper::getGmmUsageType(allocationData.type, !!allocationData.flags.uncacheable, productHelper), false, systemMemoryStorageInfo, true); auto allocation = std::make_unique(allocationData.rootDeviceIndex, 1u, // numGmms allocationData.type, nullptr, 0, allocationData.size, nullptr, @@ -110,11 +110,11 @@ GraphicsAllocation *WddmMemoryManager::allocateMemoryByKMD(const AllocationData if (allocationData.size > getHugeGfxMemoryChunkSize(GfxMemoryAllocationMethod::AllocateByKmd)) { return allocateHugeGraphicsMemory(allocationData, false); } - auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo(); + auto &productHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHelper(); StorageInfo systemMemoryStorageInfo = {}; auto gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), allocationData.hostPtr, allocationData.size, 0u, - CacheSettingsHelper::getGmmUsageType(allocationData.type, !!allocationData.flags.uncacheable, *hwInfo), false, systemMemoryStorageInfo, true); + CacheSettingsHelper::getGmmUsageType(allocationData.type, !!allocationData.flags.uncacheable, productHelper), false, systemMemoryStorageInfo, true); auto allocation = std::make_unique(allocationData.rootDeviceIndex, 1u, // numGmms allocationData.type, nullptr, 0, allocationData.size, nullptr, @@ -170,11 +170,10 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryUsingKmdAndMapItToC 0u, // shareable maxOsContextCount); - auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo(); - + auto &productHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHelper(); auto gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), nullptr, sizeAligned, 0u, - CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!allocationData.flags.uncacheable, *hwInfo), + CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!allocationData.flags.uncacheable, productHelper), allocationData.flags.preferCompressed, allocationData.storageInfo, allowLargePages); @@ -244,13 +243,13 @@ GraphicsAllocation *WddmMemoryManager::allocateHugeGraphicsMemory(const Allocati wddmAllocation->setDriverAllocatedCpuPtr(hostPtr); } - auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo(); + auto &productHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHelper(); auto sizeRemaining = alignedSize; for (auto gmmId = 0u; gmmId < numGmms; ++gmmId) { auto size = sizeRemaining > chunkSize ? chunkSize : sizeRemaining; auto gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), static_cast(alignedPtr) + gmmId * chunkSize, size, 0u, - CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!uncacheable, *hwInfo), false, {}, true); + CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!uncacheable, productHelper), false, {}, true); wddmAllocation->setGmm(gmm, gmmId); sizeRemaining -= size; } @@ -306,11 +305,10 @@ GraphicsAllocation *WddmMemoryManager::allocateSystemMemoryAndCreateGraphicsAllo 0u, // shareable maxOsContextCount); wddmAllocation->setDriverAllocatedCpuPtr(pSysMem); - - auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo(); + auto &productHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHelper(); gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), pSysMem, sizeAligned, 0u, - CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!allocationData.flags.uncacheable, *hwInfo), + CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!allocationData.flags.uncacheable, productHelper), allocationData.flags.preferCompressed, allocationData.storageInfo, true); wddmAllocation->setDefaultGmm(gmm); @@ -356,11 +354,10 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(co auto alignedPtr = alignDown(allocationData.hostPtr, MemoryConstants::pageSize); auto offsetInPage = ptrDiff(allocationData.hostPtr, alignedPtr); wddmAllocation->setAllocationOffset(offsetInPage); - - auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo(); + auto &productHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHelper(); auto gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), alignedPtr, alignedSize, 0u, - CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!allocationData.flags.uncacheable, *hwInfo), false, {}, true); + CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!allocationData.flags.uncacheable, productHelper), false, {}, true); wddmAllocation->setDefaultGmm(gmm); @@ -401,10 +398,9 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithHostPtr(const A maxOsContextCount); allocation->setAllocationOffset(offset); - auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo(); - + auto &productHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHelper(); Gmm *gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), ptrAligned, sizeAligned, 0u, - CacheSettingsHelper::getGmmUsageType(allocation->getAllocationType(), !!allocationData.flags.uncacheable, *hwInfo), false, {}, true); + CacheSettingsHelper::getGmmUsageType(allocation->getAllocationType(), !!allocationData.flags.uncacheable, productHelper), false, {}, true); allocation->setDefaultGmm(gmm); if (createWddmAllocation(allocation, reserve)) { return allocation; @@ -450,11 +446,12 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All wddmAllocation->set32BitAllocation(true); wddmAllocation->setAllocationOffset(offset); wddmAllocation->allocInFrontWindowPool = allocationData.flags.use32BitFrontWindow; + auto &productHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHelper(); auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo(); gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(), ptrAligned, sizeAligned, 0u, - CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!allocationData.flags.uncacheable, *hwInfo), false, {}, true); + CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), !!allocationData.flags.uncacheable, productHelper), false, {}, true); wddmAllocation->setDefaultGmm(gmm); if (!createWddmAllocation(wddmAllocation.get(), nullptr)) { @@ -689,7 +686,7 @@ MemoryManager::AllocationStatus WddmMemoryManager::populateOsHandles(OsHandleSto uint32_t allocatedFragmentIndexes[maxFragmentsCount]; uint32_t allocatedFragmentsCounter = 0; - auto hwInfo = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo(); + auto &productHelper = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHelper(); for (unsigned int i = 0; i < maxFragmentsCount; i++) { // If no fragment is present it means it already exists. @@ -701,7 +698,7 @@ MemoryManager::AllocationStatus WddmMemoryManager::populateOsHandles(OsHandleSto osHandle->gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getGmmHelper(), handleStorage.fragmentStorageData[i].cpuPtr, handleStorage.fragmentStorageData[i].fragmentSize, 0u, - CacheSettingsHelper::getGmmUsageType(AllocationType::EXTERNAL_HOST_PTR, false, *hwInfo), false, {}, true); + CacheSettingsHelper::getGmmUsageType(AllocationType::EXTERNAL_HOST_PTR, false, productHelper), false, {}, true); allocatedFragmentIndexes[allocatedFragmentsCounter] = i; allocatedFragmentsCounter++; } @@ -1055,6 +1052,8 @@ void createColouredGmms(GmmHelper *gmmHelper, WddmAllocation &allocation, const 18 pages is coloured to (5, 5, 4, 4). It was tested and doesn't require any debug*/ + auto &productHelper = gmmHelper->getRootDeviceEnvironment().getHelper(); + for (auto handleId = 0u; handleId < handles; handleId++) { auto currentSize = alignUp(remainingSize / (handles - handleId), MemoryConstants::pageSize64k); remainingSize -= currentSize; @@ -1064,7 +1063,7 @@ void createColouredGmms(GmmHelper *gmmHelper, WddmAllocation &allocation, const nullptr, currentSize, 0u, - CacheSettingsHelper::getGmmUsageType(allocation.getAllocationType(), false, *gmmHelper->getHardwareInfo()), + CacheSettingsHelper::getGmmUsageType(allocation.getAllocationType(), false, productHelper), compression, limitedStorageInfo, true); allocation.setGmm(gmm, handleId); @@ -1072,22 +1071,26 @@ void createColouredGmms(GmmHelper *gmmHelper, WddmAllocation &allocation, const } void fillGmmsInAllocation(GmmHelper *gmmHelper, WddmAllocation *allocation, const StorageInfo &storageInfo) { + auto &productHelper = gmmHelper->getRootDeviceEnvironment().getHelper(); + for (auto handleId = 0u; handleId < storageInfo.getNumBanks(); handleId++) { StorageInfo limitedStorageInfo = storageInfo; limitedStorageInfo.memoryBanks &= static_cast(1u << handleId); limitedStorageInfo.pageTablesVisibility &= static_cast(1u << handleId); auto gmm = new Gmm(gmmHelper, nullptr, allocation->getAlignedSize(), 0u, - CacheSettingsHelper::getGmmUsageType(allocation->getAllocationType(), false, *gmmHelper->getHardwareInfo()), false, limitedStorageInfo, true); + CacheSettingsHelper::getGmmUsageType(allocation->getAllocationType(), false, productHelper), false, limitedStorageInfo, true); allocation->setGmm(gmm, handleId); } } void splitGmmsInAllocation(GmmHelper *gmmHelper, WddmAllocation *wddmAllocation, size_t alignment, size_t chunkSize, StorageInfo &storageInfo) { auto sizeRemaining = wddmAllocation->getAlignedSize(); + auto &productHelper = gmmHelper->getRootDeviceEnvironment().getHelper(); + for (auto gmmId = 0u; gmmId < wddmAllocation->getNumGmms(); ++gmmId) { auto size = sizeRemaining > chunkSize ? chunkSize : sizeRemaining; auto gmm = new Gmm(gmmHelper, nullptr, size, alignment, - CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), false, *gmmHelper->getHardwareInfo()), false, storageInfo, true); + CacheSettingsHelper::getGmmUsageType(wddmAllocation->getAllocationType(), false, productHelper), false, storageInfo, true); wddmAllocation->setGmm(gmm, gmmId); sizeRemaining -= size; } @@ -1106,7 +1109,7 @@ uint32_t getPriorityForAllocation(AllocationType allocationType) { GraphicsAllocation *WddmMemoryManager::allocatePhysicalLocalDeviceMemory(const AllocationData &allocationData, AllocationStatus &status) { auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]; - auto gmmHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper(); + auto gmmHelper = rootDeviceEnvironment.getGmmHelper(); std::unique_ptr gmm; size_t sizeAligned = 0; @@ -1117,11 +1120,13 @@ GraphicsAllocation *WddmMemoryManager::allocatePhysicalLocalDeviceMemory(const A sizeAligned = alignUp(allocationData.size, alignment); if (singleBankAllocation) { + auto &productHelper = rootDeviceEnvironment.getHelper(); + gmm = std::make_unique(gmmHelper, nullptr, sizeAligned, alignment, - CacheSettingsHelper::getGmmUsageType(allocationData.type, !!allocationData.flags.uncacheable, *rootDeviceEnvironment.getHardwareInfo()), + CacheSettingsHelper::getGmmUsageType(allocationData.type, !!allocationData.flags.uncacheable, productHelper), allocationData.flags.preferCompressed, allocationData.storageInfo, true); @@ -1199,11 +1204,13 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryInDevicePool(const sizeAligned = alignUp(allocationData.size, alignment); if (singleBankAllocation) { + auto &productHelper = rootDeviceEnvironment.getHelper(); + gmm = std::make_unique(gmmHelper, nullptr, sizeAligned, alignment, - CacheSettingsHelper::getGmmUsageType(allocationData.type, !!allocationData.flags.uncacheable, *rootDeviceEnvironment.getHardwareInfo()), + CacheSettingsHelper::getGmmUsageType(allocationData.type, !!allocationData.flags.uncacheable, productHelper), allocationData.flags.preferCompressed, allocationData.storageInfo, true);