mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Pass memory placement info to StorageInfo
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
85eb6d7403
commit
61ca84e94b
@ -1303,6 +1303,7 @@ TEST_F(GmmLocalMemoryTests, givenFtrLocalMemoryWhenUsingLocalMemoryAndAllocation
|
||||
StorageInfo storageInfo{};
|
||||
storageInfo.isLockable = true;
|
||||
storageInfo.memoryBanks.set(1);
|
||||
storageInfo.systemMemoryPlacement = false;
|
||||
auto gmm = std::make_unique<Gmm>(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true);
|
||||
EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.NonLocalOnly);
|
||||
EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.LocalOnly);
|
||||
@ -1313,6 +1314,7 @@ TEST_F(GmmLocalMemoryTests, givenFtrLocalMemoryWhenUsingLocalMemoryFalseAndAlloc
|
||||
StorageInfo storageInfo{};
|
||||
storageInfo.isLockable = false;
|
||||
storageInfo.memoryBanks.set(1);
|
||||
storageInfo.systemMemoryPlacement = false;
|
||||
auto gmm = std::make_unique<Gmm>(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true);
|
||||
EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.NonLocalOnly);
|
||||
EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.LocalOnly);
|
||||
@ -1324,6 +1326,7 @@ TEST_F(GmmLocalMemoryTests, givenLocalMemoryAndNotLockableAllocationAndStorageIn
|
||||
storageInfo.localOnlyRequired = true;
|
||||
storageInfo.isLockable = false;
|
||||
storageInfo.memoryBanks.set(1);
|
||||
storageInfo.systemMemoryPlacement = false;
|
||||
|
||||
auto gmm = std::make_unique<Gmm>(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true);
|
||||
|
||||
@ -1336,6 +1339,7 @@ TEST_F(GmmLocalMemoryTests, givenLocalMemoryAndStorageInfoWithLocalOnlyRequiredW
|
||||
storageInfo.localOnlyRequired = true;
|
||||
storageInfo.isLockable = false;
|
||||
storageInfo.memoryBanks.set(1);
|
||||
storageInfo.systemMemoryPlacement = false;
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
|
||||
@ -1368,6 +1372,7 @@ TEST_F(GmmLocalMemoryTests, givenFtrLocalMemoryAndCompressionEnabledWhenUsingLoc
|
||||
DebugManager.flags.RenderCompressedBuffersEnabled.set(1);
|
||||
StorageInfo storageInfo{};
|
||||
storageInfo.isLockable = false;
|
||||
storageInfo.systemMemoryPlacement = false;
|
||||
storageInfo.memoryBanks.set(1);
|
||||
|
||||
auto gmm = std::make_unique<Gmm>(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, true, storageInfo, true);
|
||||
@ -1383,6 +1388,7 @@ TEST_F(GmmLocalMemoryTests, givenFtrLocalMemoryWhenUseSystemMemoryIsFalseAndAllo
|
||||
DebugManager.flags.SetCommandStreamReceiver.set(csrMode);
|
||||
StorageInfo storageInfo{};
|
||||
storageInfo.memoryBanks.set(1);
|
||||
storageInfo.systemMemoryPlacement = false;
|
||||
storageInfo.isLockable = false;
|
||||
auto gmm = std::make_unique<Gmm>(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true);
|
||||
EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.NonLocalOnly);
|
||||
@ -1406,6 +1412,7 @@ TEST_F(GmmLocalMemoryTests, givenUseLocalMemoryInImageInfoTrueWhenGmmIsCreatedTh
|
||||
|
||||
imgInfo.useLocalMemory = true;
|
||||
StorageInfo storageInfo = {};
|
||||
storageInfo.systemMemoryPlacement = false;
|
||||
storageInfo.memoryBanks.set(1);
|
||||
|
||||
auto gmm = std::make_unique<Gmm>(getGmmClientContext(), imgInfo, storageInfo, false);
|
||||
@ -1433,6 +1440,7 @@ TEST_F(GmmLocalMemoryTests, givenUseCompressionAndLocalMemoryInImageInfoTrueWhen
|
||||
|
||||
StorageInfo storageInfo = {};
|
||||
storageInfo.memoryBanks.set(1);
|
||||
storageInfo.systemMemoryPlacement = false;
|
||||
|
||||
auto gmm = std::make_unique<Gmm>(getGmmClientContext(), imgInfo, storageInfo, true);
|
||||
EXPECT_TRUE(gmm->isCompressionEnabled);
|
||||
@ -1498,6 +1506,7 @@ TEST_F(MultiTileGmmTests, givenMultiTileAllocationWithoutCloningWhenGmmIsCreated
|
||||
StorageInfo storageInfo;
|
||||
storageInfo.memoryBanks = 1;
|
||||
storageInfo.cloningOfPageTables = false;
|
||||
storageInfo.systemMemoryPlacement = false;
|
||||
|
||||
Gmm gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true);
|
||||
|
||||
@ -1522,6 +1531,7 @@ TEST_F(MultiTileGmmTests, givenMultiTileWhenGmmIsCreatedWithNonLocalMemoryThenMu
|
||||
|
||||
TEST_F(MultiTileGmmTests, givenMultiTileWhenGmmIsCreatedWithSpecificMemoryBanksThenMultitileArchIsEnabled) {
|
||||
StorageInfo storageInfo;
|
||||
storageInfo.systemMemoryPlacement = false;
|
||||
storageInfo.memoryBanks = 1u;
|
||||
storageInfo.cloningOfPageTables = false;
|
||||
|
||||
@ -1538,6 +1548,7 @@ TEST_F(MultiTileGmmTests, givenMultiTileWhenGmmIsCreatedWithCloningEnabledThenGp
|
||||
StorageInfo storageInfo;
|
||||
storageInfo.memoryBanks = 2u;
|
||||
storageInfo.cloningOfPageTables = true;
|
||||
storageInfo.systemMemoryPlacement = false;
|
||||
storageInfo.pageTablesVisibility = 3u;
|
||||
|
||||
Gmm gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true);
|
||||
@ -1554,6 +1565,7 @@ TEST_F(MultiTileGmmTests, whenAllocationIsTileInstancedWithoutClonningPageTables
|
||||
storageInfo.cloningOfPageTables = false;
|
||||
storageInfo.tileInstanced = true;
|
||||
storageInfo.memoryBanks = 2u;
|
||||
storageInfo.systemMemoryPlacement = false;
|
||||
|
||||
Gmm gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true);
|
||||
|
||||
|
@ -3022,6 +3022,36 @@ TEST(MemoryManagerTest, givenDebugModuleAreaAllocationTypeWhenCallingGetAllocati
|
||||
EXPECT_EQ(1u, allocData.flags.use32BitFrontWindow);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenStorageInfoWithParamsWhenGettingAllocDataForSystemMemoryThenSetSystemMemoryFlag) {
|
||||
AllocationData allocData;
|
||||
AllocationProperties properties(mockRootDeviceIndex, 1, AllocationType::BUFFER_HOST_MEMORY, mockDeviceBitfield);
|
||||
|
||||
EXPECT_NE(0lu, mockDeviceBitfield.to_ulong());
|
||||
|
||||
MockMemoryManager mockMemoryManager;
|
||||
auto storageInfo = mockMemoryManager.createStorageInfoFromProperties(properties);
|
||||
EXPECT_NE(0lu, storageInfo.memoryBanks.to_ulong());
|
||||
|
||||
mockMemoryManager.getAllocationData(allocData, properties, nullptr, storageInfo);
|
||||
EXPECT_EQ(1u, allocData.flags.useSystemMemory);
|
||||
EXPECT_TRUE(allocData.storageInfo.systemMemoryPlacement);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, givenStorageInfoWithParamsWhenGettingAllocDataForLocalMemoryThenClearSystemMemoryFlag) {
|
||||
AllocationData allocData;
|
||||
AllocationProperties properties(mockRootDeviceIndex, 1, AllocationType::BUFFER, mockDeviceBitfield);
|
||||
|
||||
EXPECT_NE(0lu, mockDeviceBitfield.to_ulong());
|
||||
|
||||
MockMemoryManager mockMemoryManager;
|
||||
auto storageInfo = mockMemoryManager.createStorageInfoFromProperties(properties);
|
||||
EXPECT_NE(0lu, storageInfo.memoryBanks.to_ulong());
|
||||
|
||||
mockMemoryManager.getAllocationData(allocData, properties, nullptr, storageInfo);
|
||||
EXPECT_EQ(0u, allocData.flags.useSystemMemory);
|
||||
EXPECT_FALSE(allocData.storageInfo.systemMemoryPlacement);
|
||||
}
|
||||
|
||||
TEST(MemoryManagerTest, WhenCallingIsAllocationTypeToCaptureThenScratchAndPrivateTypesReturnTrue) {
|
||||
MockMemoryManager mockMemoryManager;
|
||||
|
||||
|
@ -66,6 +66,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenShareableAllocationWhenAllocateInDevice
|
||||
allocData.flags.allocateMemory = true;
|
||||
allocData.flags.shareable = true;
|
||||
allocData.storageInfo.memoryBanks = 2;
|
||||
allocData.storageInfo.systemMemoryPlacement = false;
|
||||
|
||||
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);
|
||||
EXPECT_NE(nullptr, allocation);
|
||||
|
@ -333,10 +333,9 @@ uint32_t Gmm::getAuxQPitch() {
|
||||
|
||||
void Gmm::applyMemoryFlags(StorageInfo &storageInfo) {
|
||||
auto hardwareInfo = clientContext->getHardwareInfo();
|
||||
bool systemMemoryPool = (storageInfo.getMemoryBanks() == 0);
|
||||
|
||||
if (hardwareInfo->featureTable.flags.ftrLocalMemory) {
|
||||
if (systemMemoryPool) {
|
||||
if (storageInfo.systemMemoryPlacement) {
|
||||
resourceParams.Flags.Info.NonLocalOnly = 1;
|
||||
} else {
|
||||
if (extraMemoryFlagsRequired()) {
|
||||
@ -352,7 +351,7 @@ void Gmm::applyMemoryFlags(StorageInfo &storageInfo) {
|
||||
|
||||
if (hardwareInfo->featureTable.flags.ftrMultiTileArch) {
|
||||
resourceParams.MultiTileArch.Enable = 1;
|
||||
if (systemMemoryPool) {
|
||||
if (storageInfo.systemMemoryPlacement) {
|
||||
resourceParams.MultiTileArch.GpuVaMappingSet = hardwareInfo->gtSystemInfo.MultiTileArchInfo.TileMask;
|
||||
resourceParams.MultiTileArch.LocalMemPreferredSet = 0;
|
||||
resourceParams.MultiTileArch.LocalMemEligibilitySet = 0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -31,6 +31,7 @@ struct StorageInfo {
|
||||
bool cpuVisibleSegment = false;
|
||||
bool isLockable = false;
|
||||
bool localOnlyRequired = false;
|
||||
bool systemMemoryPlacement = true;
|
||||
char resourceTag[AppResourceDefines::maxStrLen + 1] = "";
|
||||
uint32_t getMemoryBanks() const { return static_cast<uint32_t>(memoryBanks.to_ulong()); }
|
||||
uint32_t getTotalBanksCnt() const { return Math::log2(getMemoryBanks()) + 1; }
|
||||
|
@ -464,6 +464,9 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
|
||||
|
||||
overrideAllocationData(allocationData, properties);
|
||||
allocationData.flags.isUSMHostAllocation = properties.flags.isUSMHostAllocation;
|
||||
|
||||
allocationData.storageInfo.systemMemoryPlacement = allocationData.flags.useSystemMemory;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -255,6 +255,7 @@ HWTEST2_F(GmmTestsDG2, givenGmmForImageWithForceLocalMemThenNonLocalIsSetToFalse
|
||||
NEO::StorageInfo storageInfo = {};
|
||||
storageInfo.localOnlyRequired = true;
|
||||
storageInfo.memoryBanks = 2;
|
||||
storageInfo.systemMemoryPlacement = false;
|
||||
|
||||
std::unique_ptr<NEO::Gmm> gmm(new NEO::Gmm(mockExecEnv.rootDeviceEnvironments[0]->getGmmClientContext(), imgInfo, storageInfo, false));
|
||||
|
||||
|
Reference in New Issue
Block a user