Skip to content

Commit 61ca84e

Browse files
Pass memory placement info to StorageInfo
Signed-off-by: Bartosz Dunajski <[email protected]>
1 parent 85eb6d7 commit 61ca84e

File tree

7 files changed

+51
-4
lines changed

7 files changed

+51
-4
lines changed

opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,7 @@ TEST_F(GmmLocalMemoryTests, givenFtrLocalMemoryWhenUsingLocalMemoryAndAllocation
13031303
StorageInfo storageInfo{};
13041304
storageInfo.isLockable = true;
13051305
storageInfo.memoryBanks.set(1);
1306+
storageInfo.systemMemoryPlacement = false;
13061307
auto gmm = std::make_unique<Gmm>(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true);
13071308
EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.NonLocalOnly);
13081309
EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.LocalOnly);
@@ -1313,6 +1314,7 @@ TEST_F(GmmLocalMemoryTests, givenFtrLocalMemoryWhenUsingLocalMemoryFalseAndAlloc
13131314
StorageInfo storageInfo{};
13141315
storageInfo.isLockable = false;
13151316
storageInfo.memoryBanks.set(1);
1317+
storageInfo.systemMemoryPlacement = false;
13161318
auto gmm = std::make_unique<Gmm>(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true);
13171319
EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.NonLocalOnly);
13181320
EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.LocalOnly);
@@ -1324,6 +1326,7 @@ TEST_F(GmmLocalMemoryTests, givenLocalMemoryAndNotLockableAllocationAndStorageIn
13241326
storageInfo.localOnlyRequired = true;
13251327
storageInfo.isLockable = false;
13261328
storageInfo.memoryBanks.set(1);
1329+
storageInfo.systemMemoryPlacement = false;
13271330

13281331
auto gmm = std::make_unique<Gmm>(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true);
13291332

@@ -1336,6 +1339,7 @@ TEST_F(GmmLocalMemoryTests, givenLocalMemoryAndStorageInfoWithLocalOnlyRequiredW
13361339
storageInfo.localOnlyRequired = true;
13371340
storageInfo.isLockable = false;
13381341
storageInfo.memoryBanks.set(1);
1342+
storageInfo.systemMemoryPlacement = false;
13391343

13401344
DebugManagerStateRestore restorer;
13411345

@@ -1368,6 +1372,7 @@ TEST_F(GmmLocalMemoryTests, givenFtrLocalMemoryAndCompressionEnabledWhenUsingLoc
13681372
DebugManager.flags.RenderCompressedBuffersEnabled.set(1);
13691373
StorageInfo storageInfo{};
13701374
storageInfo.isLockable = false;
1375+
storageInfo.systemMemoryPlacement = false;
13711376
storageInfo.memoryBanks.set(1);
13721377

13731378
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
13831388
DebugManager.flags.SetCommandStreamReceiver.set(csrMode);
13841389
StorageInfo storageInfo{};
13851390
storageInfo.memoryBanks.set(1);
1391+
storageInfo.systemMemoryPlacement = false;
13861392
storageInfo.isLockable = false;
13871393
auto gmm = std::make_unique<Gmm>(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true);
13881394
EXPECT_EQ(0u, gmm->resourceParams.Flags.Info.NonLocalOnly);
@@ -1406,6 +1412,7 @@ TEST_F(GmmLocalMemoryTests, givenUseLocalMemoryInImageInfoTrueWhenGmmIsCreatedTh
14061412

14071413
imgInfo.useLocalMemory = true;
14081414
StorageInfo storageInfo = {};
1415+
storageInfo.systemMemoryPlacement = false;
14091416
storageInfo.memoryBanks.set(1);
14101417

14111418
auto gmm = std::make_unique<Gmm>(getGmmClientContext(), imgInfo, storageInfo, false);
@@ -1433,6 +1440,7 @@ TEST_F(GmmLocalMemoryTests, givenUseCompressionAndLocalMemoryInImageInfoTrueWhen
14331440

14341441
StorageInfo storageInfo = {};
14351442
storageInfo.memoryBanks.set(1);
1443+
storageInfo.systemMemoryPlacement = false;
14361444

14371445
auto gmm = std::make_unique<Gmm>(getGmmClientContext(), imgInfo, storageInfo, true);
14381446
EXPECT_TRUE(gmm->isCompressionEnabled);
@@ -1498,6 +1506,7 @@ TEST_F(MultiTileGmmTests, givenMultiTileAllocationWithoutCloningWhenGmmIsCreated
14981506
StorageInfo storageInfo;
14991507
storageInfo.memoryBanks = 1;
15001508
storageInfo.cloningOfPageTables = false;
1509+
storageInfo.systemMemoryPlacement = false;
15011510

15021511
Gmm gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true);
15031512

@@ -1522,6 +1531,7 @@ TEST_F(MultiTileGmmTests, givenMultiTileWhenGmmIsCreatedWithNonLocalMemoryThenMu
15221531

15231532
TEST_F(MultiTileGmmTests, givenMultiTileWhenGmmIsCreatedWithSpecificMemoryBanksThenMultitileArchIsEnabled) {
15241533
StorageInfo storageInfo;
1534+
storageInfo.systemMemoryPlacement = false;
15251535
storageInfo.memoryBanks = 1u;
15261536
storageInfo.cloningOfPageTables = false;
15271537

@@ -1538,6 +1548,7 @@ TEST_F(MultiTileGmmTests, givenMultiTileWhenGmmIsCreatedWithCloningEnabledThenGp
15381548
StorageInfo storageInfo;
15391549
storageInfo.memoryBanks = 2u;
15401550
storageInfo.cloningOfPageTables = true;
1551+
storageInfo.systemMemoryPlacement = false;
15411552
storageInfo.pageTablesVisibility = 3u;
15421553

15431554
Gmm gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true);
@@ -1554,6 +1565,7 @@ TEST_F(MultiTileGmmTests, whenAllocationIsTileInstancedWithoutClonningPageTables
15541565
storageInfo.cloningOfPageTables = false;
15551566
storageInfo.tileInstanced = true;
15561567
storageInfo.memoryBanks = 2u;
1568+
storageInfo.systemMemoryPlacement = false;
15571569

15581570
Gmm gmm(getGmmClientContext(), nullptr, 1, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, storageInfo, true);
15591571

opencl/test/unit_test/memory_manager/memory_manager_tests.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3022,6 +3022,36 @@ TEST(MemoryManagerTest, givenDebugModuleAreaAllocationTypeWhenCallingGetAllocati
30223022
EXPECT_EQ(1u, allocData.flags.use32BitFrontWindow);
30233023
}
30243024

3025+
TEST(MemoryManagerTest, givenStorageInfoWithParamsWhenGettingAllocDataForSystemMemoryThenSetSystemMemoryFlag) {
3026+
AllocationData allocData;
3027+
AllocationProperties properties(mockRootDeviceIndex, 1, AllocationType::BUFFER_HOST_MEMORY, mockDeviceBitfield);
3028+
3029+
EXPECT_NE(0lu, mockDeviceBitfield.to_ulong());
3030+
3031+
MockMemoryManager mockMemoryManager;
3032+
auto storageInfo = mockMemoryManager.createStorageInfoFromProperties(properties);
3033+
EXPECT_NE(0lu, storageInfo.memoryBanks.to_ulong());
3034+
3035+
mockMemoryManager.getAllocationData(allocData, properties, nullptr, storageInfo);
3036+
EXPECT_EQ(1u, allocData.flags.useSystemMemory);
3037+
EXPECT_TRUE(allocData.storageInfo.systemMemoryPlacement);
3038+
}
3039+
3040+
TEST(MemoryManagerTest, givenStorageInfoWithParamsWhenGettingAllocDataForLocalMemoryThenClearSystemMemoryFlag) {
3041+
AllocationData allocData;
3042+
AllocationProperties properties(mockRootDeviceIndex, 1, AllocationType::BUFFER, mockDeviceBitfield);
3043+
3044+
EXPECT_NE(0lu, mockDeviceBitfield.to_ulong());
3045+
3046+
MockMemoryManager mockMemoryManager;
3047+
auto storageInfo = mockMemoryManager.createStorageInfoFromProperties(properties);
3048+
EXPECT_NE(0lu, storageInfo.memoryBanks.to_ulong());
3049+
3050+
mockMemoryManager.getAllocationData(allocData, properties, nullptr, storageInfo);
3051+
EXPECT_EQ(0u, allocData.flags.useSystemMemory);
3052+
EXPECT_FALSE(allocData.storageInfo.systemMemoryPlacement);
3053+
}
3054+
30253055
TEST(MemoryManagerTest, WhenCallingIsAllocationTypeToCaptureThenScratchAndPrivateTypesReturnTrue) {
30263056
MockMemoryManager mockMemoryManager;
30273057

opencl/test/unit_test/os_interface/windows/wddm_memory_manager_allocate_in_device_pool_tests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenShareableAllocationWhenAllocateInDevice
6666
allocData.flags.allocateMemory = true;
6767
allocData.flags.shareable = true;
6868
allocData.storageInfo.memoryBanks = 2;
69+
allocData.storageInfo.systemMemoryPlacement = false;
6970

7071
auto allocation = memoryManager->allocateGraphicsMemoryInDevicePool(allocData, status);
7172
EXPECT_NE(nullptr, allocation);

shared/source/gmm_helper/gmm.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,9 @@ uint32_t Gmm::getAuxQPitch() {
333333

334334
void Gmm::applyMemoryFlags(StorageInfo &storageInfo) {
335335
auto hardwareInfo = clientContext->getHardwareInfo();
336-
bool systemMemoryPool = (storageInfo.getMemoryBanks() == 0);
337336

338337
if (hardwareInfo->featureTable.flags.ftrLocalMemory) {
339-
if (systemMemoryPool) {
338+
if (storageInfo.systemMemoryPlacement) {
340339
resourceParams.Flags.Info.NonLocalOnly = 1;
341340
} else {
342341
if (extraMemoryFlagsRequired()) {
@@ -352,7 +351,7 @@ void Gmm::applyMemoryFlags(StorageInfo &storageInfo) {
352351

353352
if (hardwareInfo->featureTable.flags.ftrMultiTileArch) {
354353
resourceParams.MultiTileArch.Enable = 1;
355-
if (systemMemoryPool) {
354+
if (storageInfo.systemMemoryPlacement) {
356355
resourceParams.MultiTileArch.GpuVaMappingSet = hardwareInfo->gtSystemInfo.MultiTileArchInfo.TileMask;
357356
resourceParams.MultiTileArch.LocalMemPreferredSet = 0;
358357
resourceParams.MultiTileArch.LocalMemEligibilitySet = 0;

shared/source/memory_manager/definitions/storage_info.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2021 Intel Corporation
2+
* Copyright (C) 2020-2022 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -31,6 +31,7 @@ struct StorageInfo {
3131
bool cpuVisibleSegment = false;
3232
bool isLockable = false;
3333
bool localOnlyRequired = false;
34+
bool systemMemoryPlacement = true;
3435
char resourceTag[AppResourceDefines::maxStrLen + 1] = "";
3536
uint32_t getMemoryBanks() const { return static_cast<uint32_t>(memoryBanks.to_ulong()); }
3637
uint32_t getTotalBanksCnt() const { return Math::log2(getMemoryBanks()) + 1; }

shared/source/memory_manager/memory_manager.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,9 @@ bool MemoryManager::getAllocationData(AllocationData &allocationData, const Allo
464464

465465
overrideAllocationData(allocationData, properties);
466466
allocationData.flags.isUSMHostAllocation = properties.flags.isUSMHostAllocation;
467+
468+
allocationData.storageInfo.systemMemoryPlacement = allocationData.flags.useSystemMemory;
469+
467470
return true;
468471
}
469472

shared/test/unit_test/os_interface/wddm_linux/configure_device_address_space_drm_or_wddm_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ HWTEST2_F(GmmTestsDG2, givenGmmForImageWithForceLocalMemThenNonLocalIsSetToFalse
255255
NEO::StorageInfo storageInfo = {};
256256
storageInfo.localOnlyRequired = true;
257257
storageInfo.memoryBanks = 2;
258+
storageInfo.systemMemoryPlacement = false;
258259

259260
std::unique_ptr<NEO::Gmm> gmm(new NEO::Gmm(mockExecEnv.rootDeviceEnvironments[0]->getGmmClientContext(), imgInfo, storageInfo, false));
260261

0 commit comments

Comments
 (0)