Refactor: Change canonize method accessing point

Accessing canonize method as a member of GmmHelper class object

Related-To: NEO-6523
Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
Krzysztof Gibala
2022-04-29 13:28:15 +00:00
committed by Compute-Runtime-Automation
parent b42a49eb4b
commit 1c366d1ec0
21 changed files with 210 additions and 130 deletions

View File

@@ -1952,7 +1952,8 @@ TEST_F(DebugSessionRegistersAccessTest, WhenReadingSbaRegistersThenCorrectAddres
scratchAllocationBase = sbaExpected[ZET_DEBUG_SBA_SCRATCH_SPACE_INTEL_GPU];
uint64_t scratchAllocationBase2 = (1ULL << 47) + 0x12000u;
auto scratchAllocationBase2Canonized = NEO::GmmHelper::canonize(scratchAllocationBase2);
auto gmmHelper = neoDevice->getGmmHelper();
auto scratchAllocationBase2Canonized = gmmHelper->canonize(scratchAllocationBase2);
if (hwHelper.isScratchSpaceSurfaceStateAccessible()) {
const uint32_t ptss = 128;

View File

@@ -372,18 +372,18 @@ TEST_F(GmmCanonizeTests, WhenCanonizingThenCorrectAddressIsReturned) {
uint64_t testAddr1 = 0x7777777777777777;
uint64_t goodAddr1 = 0x0000777777777777;
EXPECT_EQ(GmmHelper::canonize(testAddr1), goodAddr1);
EXPECT_EQ(gmmHelper.get()->canonize(testAddr1), goodAddr1);
uint64_t testAddr2 = 0x7FFFFFFFFFFFFFFF;
uint64_t goodAddr2 = 0xFFFFFFFFFFFFFFFF;
EXPECT_EQ(GmmHelper::canonize(testAddr2), goodAddr2);
EXPECT_EQ(gmmHelper.get()->canonize(testAddr2), goodAddr2);
// 36 bit - also canonize to 48 bit
hwInfo.capabilityTable.gpuAddressSpace = maxNBitValue(36); // 0x0000000FFFFFFFFF;
gmmHelper = std::make_unique<GmmHelper>(nullptr, &hwInfo);
EXPECT_EQ(GmmHelper::canonize(testAddr1), goodAddr1);
EXPECT_EQ(GmmHelper::canonize(testAddr2), goodAddr2);
EXPECT_EQ(gmmHelper.get()->canonize(testAddr1), goodAddr1);
EXPECT_EQ(gmmHelper.get()->canonize(testAddr2), goodAddr2);
}
TEST_F(GmmCanonizeTests, WhenDecanonizingThenCorrectAddressIsReturned) {

View File

@@ -81,7 +81,9 @@ TEST_F(ImageInLocalMemoryTest, givenImageWithoutHostPtrWhenLocalMemoryIsEnabledT
EXPECT_LE(imageDesc.image_width * surfaceFormat->surfaceFormat.ImageElementSizeInBytes, imgGfxAlloc->getUnderlyingBufferSize());
EXPECT_EQ(AllocationType::IMAGE, imgGfxAlloc->getAllocationType());
EXPECT_EQ(0u, imgGfxAlloc->getDefaultGmm()->resourceParams.Flags.Info.NonLocalOnly);
EXPECT_LT(GmmHelper::canonize(mockMemoryManager->getGfxPartition(imgGfxAlloc->getRootDeviceIndex())->getHeapBase(HeapIndex::HEAP_STANDARD64KB)), imgGfxAlloc->getGpuAddress());
EXPECT_GT(GmmHelper::canonize(mockMemoryManager->getGfxPartition(imgGfxAlloc->getRootDeviceIndex())->getHeapLimit(HeapIndex::HEAP_STANDARD64KB)), imgGfxAlloc->getGpuAddress());
auto gmmHelper = context->getDevice(0)->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(mockMemoryManager->getGfxPartition(imgGfxAlloc->getRootDeviceIndex())->getHeapBase(HeapIndex::HEAP_STANDARD64KB)), imgGfxAlloc->getGpuAddress());
EXPECT_GT(gmmHelper->canonize(mockMemoryManager->getGfxPartition(imgGfxAlloc->getRootDeviceIndex())->getHeapLimit(HeapIndex::HEAP_STANDARD64KB)), imgGfxAlloc->getGpuAddress());
EXPECT_EQ(0llu, imgGfxAlloc->getGpuBaseAddress());
}

View File

@@ -1071,8 +1071,10 @@ TEST(MemoryManagerTest, givenEnabledLocalMemoryWhenAllocatingSharedResourceCopyT
ASSERT_NE(nullptr, allocation);
EXPECT_EQ(MemoryPool::LocalMemory, allocation->getMemoryPool());
EXPECT_EQ(0u, allocation->getDefaultGmm()->resourceParams.Flags.Info.NonLocalOnly);
EXPECT_LT(GmmHelper::canonize(memoryManager.getGfxPartition(allocation->getRootDeviceIndex())->getHeapBase(HeapIndex::HEAP_STANDARD64KB)), allocation->getGpuAddress());
EXPECT_GT(GmmHelper::canonize(memoryManager.getGfxPartition(allocation->getRootDeviceIndex())->getHeapLimit(HeapIndex::HEAP_STANDARD64KB)), allocation->getGpuAddress());
auto gmmHelper = executionEnvironment->rootDeviceEnvironments[allocation->getRootDeviceIndex()].get()->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager.getGfxPartition(allocation->getRootDeviceIndex())->getHeapBase(HeapIndex::HEAP_STANDARD64KB)), allocation->getGpuAddress());
EXPECT_GT(gmmHelper->canonize(memoryManager.getGfxPartition(allocation->getRootDeviceIndex())->getHeapLimit(HeapIndex::HEAP_STANDARD64KB)), allocation->getGpuAddress());
EXPECT_EQ(0llu, allocation->getGpuBaseAddress());
memoryManager.freeGraphicsMemory(allocation);

View File

@@ -1308,7 +1308,8 @@ TEST(OsAgnosticMemoryManager, givenDebugModuleAreaTypeWhenCreatingAllocationThen
EXPECT_LT(address64bit, MemoryConstants::max32BitAddress);
EXPECT_TRUE(moduleDebugArea->is32BitAllocation());
auto frontWindowBase = GmmHelper::canonize(memoryManager.getGfxPartition(moduleDebugArea->getRootDeviceIndex())->getHeapBase(memoryManager.selectInternalHeap(moduleDebugArea->isAllocatedInLocalMemoryPool())));
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[moduleDebugArea->getRootDeviceIndex()].get()->getGmmHelper();
auto frontWindowBase = gmmHelper->canonize(memoryManager.getGfxPartition(moduleDebugArea->getRootDeviceIndex())->getHeapBase(memoryManager.selectInternalHeap(moduleDebugArea->isAllocatedInLocalMemoryPool())));
EXPECT_EQ(frontWindowBase, moduleDebugArea->getGpuBaseAddress());
EXPECT_EQ(frontWindowBase, moduleDebugArea->getGpuAddress());
@@ -1345,7 +1346,8 @@ TEST(OsAgnosticMemoryManager, givenLocalMemoryAndDebugModuleAreaTypeWhenCreating
EXPECT_LT(address64bit, MemoryConstants::max32BitAddress);
EXPECT_TRUE(moduleDebugArea->is32BitAllocation());
auto frontWindowBase = GmmHelper::canonize(memoryManager.getGfxPartition(moduleDebugArea->getRootDeviceIndex())->getHeapBase(memoryManager.selectInternalHeap(moduleDebugArea->isAllocatedInLocalMemoryPool())));
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[moduleDebugArea->getRootDeviceIndex()].get()->getGmmHelper();
auto frontWindowBase = gmmHelper->canonize(memoryManager.getGfxPartition(moduleDebugArea->getRootDeviceIndex())->getHeapBase(memoryManager.selectInternalHeap(moduleDebugArea->isAllocatedInLocalMemoryPool())));
EXPECT_EQ(frontWindowBase, moduleDebugArea->getGpuBaseAddress());
EXPECT_EQ(frontWindowBase, moduleDebugArea->getGpuAddress());

View File

@@ -1173,14 +1173,15 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenSupportedTypeWhenAllocatingIn
EXPECT_EQ(MemoryManager::AllocationStatus::Success, status);
auto gpuAddress = allocation->getGpuAddress();
auto gmmHelper = device->getGmmHelper();
if (allocation->getAllocationType() == AllocationType::SVM_GPU) {
if (!memoryManager->isLimitedRange(0)) {
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_SVM)), gpuAddress);
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_SVM)), gpuAddress);
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_SVM)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_SVM)), gpuAddress);
}
} else if (memoryManager->heapAssigner.useInternal32BitHeap(allocation->getAllocationType())) {
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), gpuAddress);
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), gpuAddress);
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), gpuAddress);
} else {
const bool prefer2MBAlignment = allocation->getUnderlyingBufferSize() >= 2 * MemoryConstants::megaByte;
const bool prefer57bitAddressing = memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTENDED) > 0 && !allocData.flags.resource48Bit;
@@ -1192,8 +1193,8 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenSupportedTypeWhenAllocatingIn
heap = HeapIndex::HEAP_EXTENDED;
}
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(heap)), gpuAddress);
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapLimit(heap)), gpuAddress);
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(heap)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(heap)), gpuAddress);
}
memoryManager->freeGraphicsMemory(allocation);
@@ -1343,10 +1344,11 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenDebugModuleAreaTypeWhenAlloca
auto moduleDebugArea = memoryManager->allocateGraphicsMemoryWithProperties(properties);
auto gpuAddress = moduleDebugArea->getGpuAddress();
EXPECT_LE(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW)), gpuAddress);
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW)), gpuAddress);
EXPECT_EQ(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW)), moduleDebugArea->getGpuBaseAddress());
EXPECT_EQ(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), moduleDebugArea->getGpuBaseAddress());
auto gmmHelper = device->getGmmHelper();
EXPECT_LE(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW)), gpuAddress);
EXPECT_EQ(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW)), moduleDebugArea->getGpuBaseAddress());
EXPECT_EQ(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), moduleDebugArea->getGpuBaseAddress());
EXPECT_EQ(MemoryPool::LocalMemory, moduleDebugArea->getMemoryPool());
memoryManager->freeGraphicsMemory(moduleDebugArea);
@@ -1360,10 +1362,10 @@ TEST_F(DrmMemoryManagerLocalMemoryPrelimTest, givenSipKernelTypeWhenAllocatingTh
auto sipAllocation = memoryManager->allocateGraphicsMemoryWithProperties(properties);
auto gpuAddress = sipAllocation->getGpuAddress();
EXPECT_LE(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW)), gpuAddress);
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW)), gpuAddress);
EXPECT_EQ(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW)), sipAllocation->getGpuBaseAddress());
EXPECT_EQ(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), sipAllocation->getGpuBaseAddress());
EXPECT_LE(device->getGmmHelper()->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW)), gpuAddress);
EXPECT_GT(device->getGmmHelper()->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW)), gpuAddress);
EXPECT_EQ(device->getGmmHelper()->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW)), sipAllocation->getGpuBaseAddress());
EXPECT_EQ(device->getGmmHelper()->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), sipAllocation->getGpuBaseAddress());
EXPECT_EQ(MemoryPool::LocalMemory, sipAllocation->getMemoryPool());
memoryManager->freeGraphicsMemory(sipAllocation);
@@ -2037,8 +2039,9 @@ TEST_P(DrmMemoryManagerAllocation57BitTest, givenAllocationTypeHaveToBeAllocated
ASSERT_NE(nullptr, allocation);
auto gpuAddress = allocation->getGpuAddress();
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTENDED)), gpuAddress);
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTENDED)), gpuAddress);
auto gmmHelper = device->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTENDED)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTENDED)), gpuAddress);
memoryManager->freeGraphicsMemory(allocation);
}

View File

@@ -573,14 +573,15 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenSupportedTypeWhenAllocatingInDev
EXPECT_EQ(MemoryManager::AllocationStatus::Success, status);
auto gpuAddress = allocation->getGpuAddress();
auto gmmHelper = device->getGmmHelper();
if (allocation->getAllocationType() == AllocationType::SVM_GPU) {
if (!memoryManager->isLimitedRange(0)) {
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_SVM)), gpuAddress);
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_SVM)), gpuAddress);
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_SVM)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_SVM)), gpuAddress);
}
} else if (memoryManager->heapAssigner.useInternal32BitHeap(allocation->getAllocationType())) {
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), gpuAddress);
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), gpuAddress);
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), gpuAddress);
} else {
const bool prefer2MBAlignment = allocation->getUnderlyingBufferSize() >= 2 * MemoryConstants::megaByte;
@@ -591,8 +592,8 @@ HWTEST2_F(DrmMemoryManagerLocalMemoryTest, givenSupportedTypeWhenAllocatingInDev
heap = HeapIndex::HEAP_EXTENDED;
}
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(heap)), gpuAddress);
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapLimit(heap)), gpuAddress);
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(heap)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(heap)), gpuAddress);
}
memoryManager->freeGraphicsMemory(allocation);

View File

@@ -1224,8 +1224,9 @@ TEST_F(DrmMemoryManagerTest, givenRequiresStandardHeapThenStandardHeapIsAcquired
size_t bufferSize = 4096u;
uint64_t range = memoryManager->acquireGpuRange(bufferSize, rootDeviceIndex, HeapIndex::HEAP_STANDARD);
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_STANDARD)), range);
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_STANDARD)), range);
auto gmmHelper = device->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_STANDARD)), range);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_STANDARD)), range);
}
TEST_F(DrmMemoryManagerTest, givenRequiresStandard2MBHeapThenStandard2MBHeapIsAcquired) {
@@ -1233,8 +1234,9 @@ TEST_F(DrmMemoryManagerTest, givenRequiresStandard2MBHeapThenStandard2MBHeapIsAc
size_t bufferSize = 4096u;
uint64_t range = memoryManager->acquireGpuRange(bufferSize, rootDeviceIndex, HeapIndex::HEAP_STANDARD2MB);
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_STANDARD2MB)), range);
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_STANDARD2MB)), range);
auto gmmHelper = device->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_STANDARD2MB)), range);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_STANDARD2MB)), range);
}
TEST_F(DrmMemoryManagerTest, GivenShareableEnabledWhenAskedToCreateGraphicsAllocationThenValidAllocationIsReturnedAndStandard64KBHeapIsUsed) {
@@ -1248,8 +1250,9 @@ TEST_F(DrmMemoryManagerTest, GivenShareableEnabledWhenAskedToCreateGraphicsAlloc
EXPECT_NE(nullptr, allocation);
EXPECT_NE(0u, allocation->getGpuAddress());
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(allocation->getRootDeviceIndex())->getHeapBase(HeapIndex::HEAP_STANDARD64KB)), allocation->getGpuAddress());
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(allocation->getRootDeviceIndex())->getHeapLimit(HeapIndex::HEAP_STANDARD64KB)), allocation->getGpuAddress());
auto gmmHelper = device->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(allocation->getRootDeviceIndex())->getHeapBase(HeapIndex::HEAP_STANDARD64KB)), allocation->getGpuAddress());
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(allocation->getRootDeviceIndex())->getHeapLimit(HeapIndex::HEAP_STANDARD64KB)), allocation->getGpuAddress());
memoryManager->freeGraphicsMemory(allocation);
}
@@ -1304,7 +1307,8 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedFor32BitAllocationThen32
EXPECT_LT(address64bit, MemoryConstants::max32BitAddress);
EXPECT_TRUE(allocation->is32BitAllocation());
EXPECT_EQ(GmmHelper::canonize(memoryManager->getExternalHeapBaseAddress(allocation->getRootDeviceIndex(), allocation->isAllocatedInLocalMemoryPool())), allocation->getGpuBaseAddress());
auto gmmHelper = device->getGmmHelper();
EXPECT_EQ(gmmHelper->canonize(memoryManager->getExternalHeapBaseAddress(allocation->getRootDeviceIndex(), allocation->isAllocatedInLocalMemoryPool())), allocation->getGpuBaseAddress());
memoryManager->freeGraphicsMemory(allocation);
}
@@ -2198,8 +2202,9 @@ TEST_F(DrmMemoryManagerWithLocalMemoryTest, givenDrmMemoryManagerWithLocalMemory
EXPECT_EQ(this->mock->inputFd, static_cast<int32_t>(handle));
auto gpuAddress = graphicsAllocation->getGpuAddress();
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_STANDARD2MB)), gpuAddress);
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_STANDARD2MB)), gpuAddress);
auto gmmHelper = device->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_STANDARD2MB)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_STANDARD2MB)), gpuAddress);
DrmAllocation *drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
auto bo = drmAllocation->getBO();
@@ -2454,7 +2459,8 @@ TEST_F(DrmMemoryManagerTest, given32BitAddressingWhenBufferFromSharedHandleAndBi
auto drmAllocation = static_cast<DrmAllocation *>(graphicsAllocation);
EXPECT_TRUE(graphicsAllocation->is32BitAllocation());
EXPECT_EQ(1, lseekCalledCount);
EXPECT_EQ(GmmHelper::canonize(memoryManager->getExternalHeapBaseAddress(graphicsAllocation->getRootDeviceIndex(), drmAllocation->isAllocatedInLocalMemoryPool())), drmAllocation->getGpuBaseAddress());
auto gmmHelper = device->getGmmHelper();
EXPECT_EQ(gmmHelper->canonize(memoryManager->getExternalHeapBaseAddress(graphicsAllocation->getRootDeviceIndex(), drmAllocation->isAllocatedInLocalMemoryPool())), drmAllocation->getGpuBaseAddress());
memoryManager->freeGraphicsMemory(graphicsAllocation);
}
@@ -2824,7 +2830,9 @@ TEST_F(DrmMemoryManagerTest, given32BitAllocatorWithHeapAllocatorWhenLargerFragm
auto bo = graphicsAlloaction->getBO();
EXPECT_EQ(pages3size, bo->peekSize());
EXPECT_EQ(GmmHelper::canonize(ptr), graphicsAlloaction->getGpuAddress());
auto gmmHelper = device->getGmmHelper();
EXPECT_EQ(gmmHelper->canonize(ptr), graphicsAlloaction->getGpuAddress());
memoryManager->freeGraphicsMemory(graphicsAlloaction);
}
@@ -2905,8 +2913,8 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForInternalAllocationWit
EXPECT_TRUE(drmAllocation->is32BitAllocation());
auto gpuPtr = drmAllocation->getGpuAddress();
auto heapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(drmAllocation->getRootDeviceIndex(), drmAllocation->isAllocatedInLocalMemoryPool()));
auto gmmHelper = device->getGmmHelper();
auto heapBase = gmmHelper->canonize(memoryManager->getInternalHeapBaseAddress(drmAllocation->getRootDeviceIndex(), drmAllocation->isAllocatedInLocalMemoryPool()));
auto heapSize = 4 * GB;
EXPECT_GE(gpuPtr, heapBase);
@@ -2938,8 +2946,8 @@ TEST_F(DrmMemoryManagerTest, givenLimitedRangeAllocatorWhenAskedForInternalAlloc
EXPECT_TRUE(drmAllocation->is32BitAllocation());
auto gpuPtr = drmAllocation->getGpuAddress();
auto heapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(drmAllocation->getRootDeviceIndex(), drmAllocation->isAllocatedInLocalMemoryPool()));
auto gmmHelper = device->getGmmHelper();
auto heapBase = gmmHelper->canonize(memoryManager->getInternalHeapBaseAddress(drmAllocation->getRootDeviceIndex(), drmAllocation->isAllocatedInLocalMemoryPool()));
auto heapSize = 4 * GB;
EXPECT_GE(gpuPtr, heapBase);
@@ -2995,8 +3003,8 @@ TEST_F(DrmMemoryManagerTest, givenMemoryManagerWhenAskedForInternalAllocationWit
EXPECT_TRUE(drmAllocation->is32BitAllocation());
auto gpuPtr = drmAllocation->getGpuAddress();
auto heapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(drmAllocation->getRootDeviceIndex(), drmAllocation->isAllocatedInLocalMemoryPool()));
auto gmmHelper = device->getGmmHelper();
auto heapBase = gmmHelper->canonize(memoryManager->getInternalHeapBaseAddress(drmAllocation->getRootDeviceIndex(), drmAllocation->isAllocatedInLocalMemoryPool()));
auto heapSize = 4 * GB;
EXPECT_GE(gpuPtr, heapBase);
@@ -3962,11 +3970,12 @@ TEST_F(DrmMemoryManagerTest, givenDebugModuleAreaTypeWhenCreatingAllocationThen3
HeapIndex heap = HeapAssigner::mapInternalWindowIndex(memoryManager->selectInternalHeap(moduleDebugArea->isAllocatedInLocalMemoryPool()));
EXPECT_TRUE(heap == HeapIndex::HEAP_INTERNAL_DEVICE_FRONT_WINDOW || heap == HeapIndex::HEAP_INTERNAL_FRONT_WINDOW);
auto frontWindowBase = GmmHelper::canonize(memoryManager->getGfxPartition(moduleDebugArea->getRootDeviceIndex())->getHeapBase(heap));
auto gmmHelper = device->getGmmHelper();
auto frontWindowBase = gmmHelper->canonize(memoryManager->getGfxPartition(moduleDebugArea->getRootDeviceIndex())->getHeapBase(heap));
EXPECT_EQ(frontWindowBase, moduleDebugArea->getGpuBaseAddress());
EXPECT_EQ(frontWindowBase, moduleDebugArea->getGpuAddress());
auto internalHeapBase = GmmHelper::canonize(memoryManager->getGfxPartition(moduleDebugArea->getRootDeviceIndex())->getHeapBase(memoryManager->selectInternalHeap(moduleDebugArea->isAllocatedInLocalMemoryPool())));
auto internalHeapBase = gmmHelper->canonize(memoryManager->getGfxPartition(moduleDebugArea->getRootDeviceIndex())->getHeapBase(memoryManager->selectInternalHeap(moduleDebugArea->isAllocatedInLocalMemoryPool())));
EXPECT_EQ(internalHeapBase, moduleDebugArea->getGpuBaseAddress());
memoryManager->freeGraphicsMemory(moduleDebugArea);
@@ -4062,8 +4071,9 @@ TEST_F(DrmMemoryManagerTest, givenSvmCpuAllocationWhenSizeAndAlignmentProvidedTh
EXPECT_NE(0llu, bo->peekAddress());
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_STANDARD)), bo->peekAddress());
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_STANDARD)), bo->peekAddress());
auto gmmHelper = device->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_STANDARD)), bo->peekAddress());
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_STANDARD)), bo->peekAddress());
EXPECT_EQ(reinterpret_cast<void *>(allocation->getGpuAddress()), alignUp(allocation->getReservedAddressPtr(), allocationData.alignment));
EXPECT_EQ(alignUp(allocationData.size, allocationData.alignment) + allocationData.alignment, allocation->getReservedAddressSize());
@@ -4097,7 +4107,8 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndReleaseGpuRangeIsCalledThen
mockGfxPartition->init(hwInfo->capabilityTable.gpuAddressSpace, reservedCpuAddressRangeSize, 0, 1);
auto size = 2 * MemoryConstants::megaByte;
auto gpuAddress = mockGfxPartition->heapAllocate(HeapIndex::HEAP_STANDARD, size);
auto gpuAddressCanonized = GmmHelper::canonize(gpuAddress);
auto gmmHelper = device->getGmmHelper();
auto gpuAddressCanonized = gmmHelper->canonize(gpuAddress);
EXPECT_LE(gpuAddress, gpuAddressCanonized);
memoryManager->overrideGfxPartition(mockGfxPartition.release());
@@ -5210,8 +5221,9 @@ struct DrmMemoryManagerLocalMemoryAlignmentTest : DrmMemoryManagerWithLocalMemor
bool isAllocationWithinHeap(MemoryManager &memoryManager, const GraphicsAllocation &allocation, HeapIndex heap) {
const auto allocationStart = allocation.getGpuAddress();
const auto allocationEnd = allocationStart + allocation.getUnderlyingBufferSize();
const auto heapStart = GmmHelper::canonize(memoryManager.getGfxPartition(rootDeviceIndex)->getHeapBase(heap));
const auto heapEnd = GmmHelper::canonize(memoryManager.getGfxPartition(rootDeviceIndex)->getHeapLimit(heap));
const auto gmmHelper = device->getGmmHelper();
const auto heapStart = gmmHelper->canonize(memoryManager.getGfxPartition(rootDeviceIndex)->getHeapBase(heap));
const auto heapEnd = gmmHelper->canonize(memoryManager.getGfxPartition(rootDeviceIndex)->getHeapLimit(heap));
return heapStart <= allocationStart && allocationEnd <= heapEnd;
}
@@ -5458,8 +5470,10 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenNotSetUs
if (memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTENDED)) {
heap = HeapIndex::HEAP_EXTENDED;
}
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(heap)), gpuAddress);
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(heap)), gpuAddress);
auto gmmHelper = device->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(heap)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(heap)), gpuAddress);
EXPECT_EQ(0u, allocation->getGpuBaseAddress());
EXPECT_EQ(sizeAligned, allocation->getUnderlyingBufferSize());
EXPECT_EQ(gpuAddress, reinterpret_cast<uint64_t>(allocation->getReservedAddressPtr()));
@@ -5542,8 +5556,10 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenNotSetUs
auto gpuAddress = allocation->getGpuAddress();
auto sizeAligned = alignUp(allocData.imgInfo->size, MemoryConstants::pageSize64k);
EXPECT_NE(0u, gpuAddress);
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_STANDARD64KB)), gpuAddress);
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_STANDARD64KB)), gpuAddress);
auto gmmHelper = device->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_STANDARD64KB)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_STANDARD64KB)), gpuAddress);
EXPECT_EQ(0u, allocation->getGpuBaseAddress());
EXPECT_EQ(sizeAligned, allocation->getUnderlyingBufferSize());
EXPECT_EQ(gpuAddress, reinterpret_cast<uint64_t>(allocation->getReservedAddressPtr()));
@@ -5583,9 +5599,10 @@ TEST_F(DrmMemoryManagerWithLocalMemoryAndExplicitExpectationsTest, givenNotSetUs
EXPECT_EQ(MemoryPool::LocalMemory, allocation->getMemoryPool());
auto gpuAddress = allocation->getGpuAddress();
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), gpuAddress);
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), gpuAddress);
EXPECT_EQ(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), allocation->getGpuBaseAddress());
auto gmmHelper = device->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), gpuAddress);
EXPECT_EQ(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY)), allocation->getGpuBaseAddress());
EXPECT_EQ(sizeAligned, allocation->getUnderlyingBufferSize());
EXPECT_EQ(gpuAddress, reinterpret_cast<uint64_t>(allocation->getReservedAddressPtr()));
EXPECT_EQ(sizeAligned, allocation->getReservedAddressSize());

View File

@@ -339,8 +339,10 @@ TEST_F(Wddm20Tests, givenGraphicsAllocationWhenItIsMappedInHeap0ThenItHasGpuAddr
bool ret = wddm->mapGpuVirtualAddress(gmm.get(), ALLOCATION_HANDLE, heapBase, heapLimit, 0u, gpuAddress);
EXPECT_TRUE(ret);
auto cannonizedHeapBase = GmmHelper::canonize(heapBase);
auto cannonizedHeapEnd = GmmHelper::canonize(heapLimit);
auto gmmHelper = rootDeviceEnvironment->getGmmHelper();
auto cannonizedHeapBase = gmmHelper->canonize(heapBase);
auto cannonizedHeapEnd = gmmHelper->canonize(heapLimit);
EXPECT_GE(gpuAddress, cannonizedHeapBase);
EXPECT_LE(gpuAddress, cannonizedHeapEnd);
@@ -435,7 +437,9 @@ TEST_F(Wddm20Tests, givenNullAllocationWhenCreateThenAllocateAndMap) {
EXPECT_TRUE(ret);
EXPECT_NE(0u, allocation.getGpuAddress());
EXPECT_EQ(allocation.getGpuAddress(), GmmHelper::canonize(allocation.getGpuAddress()));
auto gmmHelper = rootDeviceEnvironment->getGmmHelper();
EXPECT_EQ(allocation.getGpuAddress(), gmmHelper->canonize(allocation.getGpuAddress()));
mm.freeSystemMemory(allocation.getUnderlyingBuffer());
}

View File

@@ -235,12 +235,13 @@ HWTEST_F(WddmMemoryManagerSimpleTest, givenLinearStreamWhenItIsAllocatedThenItIs
auto &partition = wddm->getGfxPartition();
if (is64bit) {
auto gmmHelper = executionEnvironment->rootDeviceEnvironments[graphicsAllocation->getRootDeviceIndex()].get()->getGmmHelper();
if (executionEnvironment->rootDeviceEnvironments[graphicsAllocation->getRootDeviceIndex()]->isFullRangeSvm()) {
EXPECT_GE(gpuAddress, GmmHelper::canonize(partition.Standard64KB.Base));
EXPECT_LE(gpuAddressEnd, GmmHelper::canonize(partition.Standard64KB.Limit));
EXPECT_GE(gpuAddress, gmmHelper->canonize(partition.Standard64KB.Base));
EXPECT_LE(gpuAddressEnd, gmmHelper->canonize(partition.Standard64KB.Limit));
} else {
EXPECT_GE(gpuAddress, GmmHelper::canonize(partition.Standard.Base));
EXPECT_LE(gpuAddressEnd, GmmHelper::canonize(partition.Standard.Limit));
EXPECT_GE(gpuAddress, gmmHelper->canonize(partition.Standard.Base));
EXPECT_LE(gpuAddressEnd, gmmHelper->canonize(partition.Standard.Limit));
}
} else {
if (executionEnvironment->rootDeviceEnvironments[graphicsAllocation->getRootDeviceIndex()]->isFullRangeSvm()) {

View File

@@ -730,7 +730,9 @@ TEST_F(WddmMemoryManagerTest, GivenForce32bitAddressingAndRequireSpecificBitness
EXPECT_TRUE(gpuAllocation->is32BitAllocation());
uint64_t base = memoryManager->getExternalHeapBaseAddress(gpuAllocation->getRootDeviceIndex(), gpuAllocation->isAllocatedInLocalMemoryPool());
EXPECT_EQ(GmmHelper::canonize(base), gpuAllocation->getGpuBaseAddress());
auto gmmHelper = executionEnvironment->rootDeviceEnvironments[gpuAllocation->getRootDeviceIndex()].get()->getGmmHelper();
EXPECT_EQ(gmmHelper->canonize(base), gpuAllocation->getGpuBaseAddress());
}
memoryManager->freeGraphicsMemory(gpuAllocation);
@@ -1155,8 +1157,10 @@ TEST_F(WddmMemoryManagerTest, GivenNullptrWhenAllocating32BitMemoryThenAddressIs
auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(rootDeviceIndex, 3 * MemoryConstants::pageSize, nullptr, AllocationType::BUFFER);
ASSERT_NE(nullptr, gpuAllocation);
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTERNAL)), gpuAllocation->getGpuAddress());
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTERNAL)), gpuAllocation->getGpuAddress() + gpuAllocation->getUnderlyingBufferSize());
auto gmmHelper = executionEnvironment->rootDeviceEnvironments[gpuAllocation->getRootDeviceIndex()].get()->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTERNAL)), gpuAllocation->getGpuAddress());
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTERNAL)), gpuAllocation->getGpuAddress() + gpuAllocation->getUnderlyingBufferSize());
EXPECT_EQ(0u, gpuAllocation->fragmentsStorage.fragmentCount);
memoryManager->freeGraphicsMemory(gpuAllocation);
@@ -1167,8 +1171,10 @@ TEST_F(WddmMemoryManagerTest, given32BitAllocationWhenItIsCreatedThenItHasNonZer
ASSERT_NE(nullptr, gpuAllocation);
EXPECT_NE(0llu, gpuAllocation->getGpuAddressToPatch());
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTERNAL)), gpuAllocation->getGpuAddress());
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTERNAL)), gpuAllocation->getGpuAddress() + gpuAllocation->getUnderlyingBufferSize());
auto gmmHelper = executionEnvironment->rootDeviceEnvironments[gpuAllocation->getRootDeviceIndex()].get()->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTERNAL)), gpuAllocation->getGpuAddress());
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTERNAL)), gpuAllocation->getGpuAddress() + gpuAllocation->getUnderlyingBufferSize());
memoryManager->freeGraphicsMemory(gpuAllocation);
}
@@ -1182,8 +1188,9 @@ TEST_F(WddmMemoryManagerTest, GivenMisalignedHostPtrWhenAllocating32BitMemoryThe
EXPECT_EQ(alignSizeWholePage(misalignedPtr, misalignedSize), gpuAllocation->getUnderlyingBufferSize());
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_EXTERNAL)), gpuAllocation->getGpuAddress());
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTERNAL)), gpuAllocation->getGpuAddress() + gpuAllocation->getUnderlyingBufferSize());
auto gmmHelper = executionEnvironment->rootDeviceEnvironments[gpuAllocation->getRootDeviceIndex()].get()->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapBase(HeapIndex::HEAP_EXTERNAL)), gpuAllocation->getGpuAddress());
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(HeapIndex::HEAP_EXTERNAL)), gpuAllocation->getGpuAddress() + gpuAllocation->getUnderlyingBufferSize());
EXPECT_EQ(0u, gpuAllocation->fragmentsStorage.fragmentCount);
@@ -1199,7 +1206,8 @@ TEST_F(WddmMemoryManagerTest, WhenAllocating32BitMemoryThenGpuBaseAddressIsCanno
ASSERT_NE(nullptr, gpuAllocation);
uint64_t cannonizedAddress = GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(MemoryManager::selectExternalHeap(gpuAllocation->isAllocatedInLocalMemoryPool())));
auto gmmHelper = executionEnvironment->rootDeviceEnvironments[gpuAllocation->getRootDeviceIndex()].get()->getGmmHelper();
uint64_t cannonizedAddress = gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(MemoryManager::selectExternalHeap(gpuAllocation->isAllocatedInLocalMemoryPool())));
EXPECT_EQ(cannonizedAddress, gpuAllocation->getGpuBaseAddress());
memoryManager->freeGraphicsMemory(gpuAllocation);
@@ -1324,12 +1332,13 @@ TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstAnd
TEST_F(WddmMemoryManagerTest, givenNullPtrAndSizePassedToCreateInternalAllocationWhenCallIsMadeThenAllocationIsCreatedIn32BitHeapInternal) {
auto wddmAllocation = static_cast<WddmAllocation *>(memoryManager->allocate32BitGraphicsMemory(rootDeviceIndex, MemoryConstants::pageSize, nullptr, AllocationType::INTERNAL_HEAP));
ASSERT_NE(nullptr, wddmAllocation);
EXPECT_EQ(wddmAllocation->getGpuBaseAddress(), GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(wddmAllocation->getRootDeviceIndex(), wddmAllocation->isAllocatedInLocalMemoryPool())));
auto gmmHelper = executionEnvironment->rootDeviceEnvironments[wddmAllocation->getRootDeviceIndex()].get()->getGmmHelper();
EXPECT_EQ(wddmAllocation->getGpuBaseAddress(), gmmHelper->canonize(memoryManager->getInternalHeapBaseAddress(wddmAllocation->getRootDeviceIndex(), wddmAllocation->isAllocatedInLocalMemoryPool())));
EXPECT_NE(nullptr, wddmAllocation->getUnderlyingBuffer());
EXPECT_EQ(4096u, wddmAllocation->getUnderlyingBufferSize());
EXPECT_NE((uint64_t)wddmAllocation->getUnderlyingBuffer(), wddmAllocation->getGpuAddress());
auto cannonizedHeapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(rootDeviceIndex, wddmAllocation->isAllocatedInLocalMemoryPool()));
auto cannonizedHeapEnd = GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(MemoryManager::selectInternalHeap(wddmAllocation->isAllocatedInLocalMemoryPool())));
auto cannonizedHeapBase = gmmHelper->canonize(memoryManager->getInternalHeapBaseAddress(rootDeviceIndex, wddmAllocation->isAllocatedInLocalMemoryPool()));
auto cannonizedHeapEnd = gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(MemoryManager::selectInternalHeap(wddmAllocation->isAllocatedInLocalMemoryPool())));
EXPECT_GT(wddmAllocation->getGpuAddress(), cannonizedHeapBase);
EXPECT_LT(wddmAllocation->getGpuAddress() + wddmAllocation->getUnderlyingBufferSize(), cannonizedHeapEnd);
@@ -1343,13 +1352,14 @@ TEST_F(WddmMemoryManagerTest, givenPtrAndSizePassedToCreateInternalAllocationWhe
auto ptr = reinterpret_cast<void *>(0x1000000);
auto wddmAllocation = static_cast<WddmAllocation *>(memoryManager->allocate32BitGraphicsMemory(rootDeviceIndex, MemoryConstants::pageSize, ptr, AllocationType::INTERNAL_HEAP));
ASSERT_NE(nullptr, wddmAllocation);
EXPECT_EQ(wddmAllocation->getGpuBaseAddress(), GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(rootDeviceIndex, wddmAllocation->isAllocatedInLocalMemoryPool())));
auto gmmHelper = executionEnvironment->rootDeviceEnvironments[wddmAllocation->getRootDeviceIndex()].get()->getGmmHelper();
EXPECT_EQ(wddmAllocation->getGpuBaseAddress(), gmmHelper->canonize(memoryManager->getInternalHeapBaseAddress(rootDeviceIndex, wddmAllocation->isAllocatedInLocalMemoryPool())));
EXPECT_EQ(ptr, wddmAllocation->getUnderlyingBuffer());
EXPECT_EQ(4096u, wddmAllocation->getUnderlyingBufferSize());
EXPECT_NE((uint64_t)wddmAllocation->getUnderlyingBuffer(), wddmAllocation->getGpuAddress());
auto cannonizedHeapBase = GmmHelper::canonize(memoryManager->getInternalHeapBaseAddress(rootDeviceIndex, wddmAllocation->isAllocatedInLocalMemoryPool()));
auto cannonizedHeapEnd = GmmHelper::canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(MemoryManager::selectInternalHeap(wddmAllocation->isAllocatedInLocalMemoryPool())));
auto cannonizedHeapBase = gmmHelper->canonize(memoryManager->getInternalHeapBaseAddress(rootDeviceIndex, wddmAllocation->isAllocatedInLocalMemoryPool()));
auto cannonizedHeapEnd = gmmHelper->canonize(memoryManager->getGfxPartition(rootDeviceIndex)->getHeapLimit(MemoryManager::selectInternalHeap(wddmAllocation->isAllocatedInLocalMemoryPool())));
EXPECT_GT(wddmAllocation->getGpuAddress(), cannonizedHeapBase);
EXPECT_LT(wddmAllocation->getGpuAddress() + wddmAllocation->getUnderlyingBufferSize(), cannonizedHeapEnd);
@@ -1779,7 +1789,9 @@ TEST_F(MockWddmMemoryManagerTest, givenAllocateGraphicsMemoryForBufferAndRequest
EXPECT_NE(nullptr, wddmAlloc);
EXPECT_EQ(4, wddmAlloc->getNumGmms());
EXPECT_EQ(4, wddm->createAllocationResult.called);
EXPECT_EQ(wddmAlloc->getGpuAddressToModify(), GmmHelper::canonize(wddmAlloc->reservedGpuVirtualAddress));
auto gmmHelper = executionEnvironment->rootDeviceEnvironments[wddmAlloc->getRootDeviceIndex()].get()->getGmmHelper();
EXPECT_EQ(wddmAlloc->getGpuAddressToModify(), gmmHelper->canonize(wddmAlloc->reservedGpuVirtualAddress));
memoryManager.freeGraphicsMemory(wddmAlloc);
}
@@ -1815,7 +1827,9 @@ TEST_F(MockWddmMemoryManagerTest, givenAllocateGraphicsMemoryForHostBufferAndReq
EXPECT_NE(nullptr, wddmAlloc);
EXPECT_EQ(4, wddmAlloc->getNumGmms());
EXPECT_EQ(4, wddm->createAllocationResult.called);
EXPECT_EQ(wddmAlloc->getGpuAddressToModify(), GmmHelper::canonize(wddmAlloc->reservedGpuVirtualAddress));
auto gmmHelper = executionEnvironment->rootDeviceEnvironments[wddmAlloc->getRootDeviceIndex()].get()->getGmmHelper();
EXPECT_EQ(wddmAlloc->getGpuAddressToModify(), gmmHelper->canonize(wddmAlloc->reservedGpuVirtualAddress));
memoryManager.freeGraphicsMemory(wddmAlloc);
}
@@ -1971,7 +1985,8 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationWhenMappedGpuVaAndPag
auto result = wddm.mapGpuVirtualAddress(gmm.get(), ALLOCATION_HANDLE, wddm.getGfxPartition().Standard.Base, wddm.getGfxPartition().Standard.Limit, 0u, gpuVa);
ASSERT_TRUE(result);
EXPECT_EQ(GmmHelper::canonize(wddm.getGfxPartition().Standard.Base), gpuVa);
auto gmmHelper = rootDeviceEnvironment->getGmmHelper();
EXPECT_EQ(gmmHelper->canonize(wddm.getGfxPartition().Standard.Base), gpuVa);
EXPECT_EQ(0u, mockMngr->updateAuxTableCalled);
}
@@ -1999,7 +2014,8 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationWhenMappedGpuVaAndPag
}
GMM_DDI_UPDATEAUXTABLE expectedDdiUpdateAuxTable = {};
expectedDdiUpdateAuxTable.BaseGpuVA = GmmHelper::canonize(wddm.getGfxPartition().Standard.Base);
auto gmmHelper = rootDeviceEnvironment->getGmmHelper();
expectedDdiUpdateAuxTable.BaseGpuVA = gmmHelper->canonize(wddm.getGfxPartition().Standard.Base);
expectedDdiUpdateAuxTable.BaseResInfo = gmm->gmmResourceInfo->peekGmmResourceInfo();
expectedDdiUpdateAuxTable.DoNotWait = true;
expectedDdiUpdateAuxTable.Map = true;
@@ -2010,8 +2026,7 @@ TEST_F(MockWddmMemoryManagerTest, givenCompressedAllocationWhenMappedGpuVaAndPag
ASSERT_NE(nullptr, hwInfoMock);
auto result = wddm.mapGpuVirtualAddress(gmm.get(), ALLOCATION_HANDLE, wddm.getGfxPartition().Standard.Base, wddm.getGfxPartition().Standard.Limit, 0u, gpuVa);
ASSERT_TRUE(result);
EXPECT_EQ(GmmHelper::canonize(wddm.getGfxPartition().Standard.Base), gpuVa);
EXPECT_EQ(gmmHelper->canonize(wddm.getGfxPartition().Standard.Base), gpuVa);
EXPECT_TRUE(memcmp(&expectedDdiUpdateAuxTable, &mockMngr->updateAuxTableParamsPassed[0].ddiUpdateAuxTable, sizeof(GMM_DDI_UPDATEAUXTABLE)) == 0);
EXPECT_EQ(expectedCallCount, mockMngr->updateAuxTableCalled);
}
@@ -2407,8 +2422,9 @@ TEST_F(WddmMemoryManagerSimpleTest, givenBufferHostMemoryAllocationAndLimitedRan
EXPECT_NE(0ULL, gpuAddress);
EXPECT_EQ(0ULL, gpuAddress & 0xffFFffF000000000);
EXPECT_LT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTERNAL)), gpuAddress);
EXPECT_GT(GmmHelper::canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTERNAL)), gpuAddress);
auto gmmHelper = rootDeviceEnvironment->getGmmHelper();
EXPECT_LT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTERNAL)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTERNAL)), gpuAddress);
memoryManager->freeGraphicsMemory(allocation);
}
@@ -2431,7 +2447,8 @@ TEST_F(WddmMemoryManagerSimpleTest, givenDebugModuleAreaTypeWhenCreatingAllocati
EXPECT_LT(address64bit, MemoryConstants::max32BitAddress);
EXPECT_TRUE(moduleDebugArea->is32BitAllocation());
auto frontWindowBase = GmmHelper::canonize(memoryManager->getGfxPartition(moduleDebugArea->getRootDeviceIndex())->getHeapBase(memoryManager->selectInternalHeap(moduleDebugArea->isAllocatedInLocalMemoryPool())));
auto gmmHelper = rootDeviceEnvironment->getGmmHelper();
auto frontWindowBase = gmmHelper->canonize(memoryManager->getGfxPartition(moduleDebugArea->getRootDeviceIndex())->getHeapBase(memoryManager->selectInternalHeap(moduleDebugArea->isAllocatedInLocalMemoryPool())));
EXPECT_EQ(frontWindowBase, moduleDebugArea->getGpuBaseAddress());
EXPECT_EQ(frontWindowBase, moduleDebugArea->getGpuAddress());
@@ -2688,7 +2705,8 @@ TEST_F(PlatformWithFourDevicesTest, whenCreateColoredAllocationAndWddmReturnsCan
using WddmMock::WddmMock;
bool mapGpuVirtualAddress(Gmm *gmm, D3DKMT_HANDLE handle, D3DGPU_VIRTUAL_ADDRESS minimumAddress, D3DGPU_VIRTUAL_ADDRESS maximumAddress, D3DGPU_VIRTUAL_ADDRESS preferredAddress, D3DGPU_VIRTUAL_ADDRESS &gpuPtr) override {
gpuPtr = GmmHelper::canonize(preferredAddress);
auto gmmHelper = rootDeviceEnvironment.getGmmHelper();
gpuPtr = gmmHelper->canonize(preferredAddress);
return mapGpuVaStatus;
}
};

View File

@@ -115,8 +115,9 @@ void WddmDirectSubmission<GfxFamily, Dispatcher>::handleCompletionRingBuffer(uin
template <typename GfxFamily, typename Dispatcher>
void WddmDirectSubmission<GfxFamily, Dispatcher>::getTagAddressValue(TagData &tagData) {
MonitoredFence &currentFence = osContextWin->getResidencyController().getMonitoredFence();
auto gmmHelper = wddm->getRootDeviceEnvironment().getGmmHelper();
tagData.tagAddress = GmmHelper::canonize(currentFence.gpuAddress);
tagData.tagAddress = gmmHelper->canonize(currentFence.gpuAddress);
tagData.tagValue = currentFence.currentFenceValue;
}

View File

@@ -49,7 +49,7 @@ GmmHelper::GmmHelper(OSInterface *osInterface, const HardwareInfo *pHwInfo) : hw
bool GmmHelper::isValidCanonicalGpuAddress(uint64_t address) {
auto decanonizedAddress = NEO::GmmHelper::decanonize(address);
auto canonizedAddress = NEO::GmmHelper::canonize(decanonizedAddress);
auto canonizedAddress = this->canonize(decanonizedAddress);
if (address == canonizedAddress) {
return true;

View File

@@ -177,6 +177,8 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(con
auto hwInfo = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getHardwareInfo();
auto heap = heapAssigner.get32BitHeapIndex(allocationData.type, useLocalMemory, *hwInfo, allocationData.flags.use32BitFrontWindow);
auto gfxPartition = getGfxPartition(allocationData.rootDeviceIndex);
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper();
if (allocationData.hostPtr) {
auto allocationSize = alignSizeWholePage(allocationData.hostPtr, allocationData.size);
auto gpuVirtualAddress = gfxPartition->heapAllocate(heap, allocationSize);
@@ -186,11 +188,11 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(con
uint64_t offset = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(allocationData.hostPtr) & MemoryConstants::pageMask);
MemoryAllocation *memAlloc = new MemoryAllocation(
allocationData.rootDeviceIndex, allocationData.type, nullptr, const_cast<void *>(allocationData.hostPtr),
GmmHelper::canonize(gpuVirtualAddress + offset), allocationData.size,
gmmHelper->canonize(gpuVirtualAddress + offset), allocationData.size,
counter, MemoryPool::System4KBPagesWith32BitGpuAddressing, false, false, maxOsContextCount);
memAlloc->set32BitAllocation(true);
memAlloc->setGpuBaseAddress(GmmHelper::canonize(gfxPartition->getHeapBase(heap)));
memAlloc->setGpuBaseAddress(gmmHelper->canonize(gfxPartition->getHeapBase(heap)));
memAlloc->sizeToFree = allocationSize;
counter++;
@@ -211,12 +213,13 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(con
MemoryAllocation *memoryAllocation = nullptr;
if (ptrAlloc != nullptr) {
memoryAllocation = new MemoryAllocation(allocationData.rootDeviceIndex, allocationData.type, ptrAlloc, ptrAlloc, GmmHelper::canonize(gpuAddress),
memoryAllocation = new MemoryAllocation(allocationData.rootDeviceIndex, allocationData.type, ptrAlloc, ptrAlloc,
gmmHelper->canonize(gpuAddress),
allocationData.size, counter, MemoryPool::System4KBPagesWith32BitGpuAddressing,
false, allocationData.flags.flushL3, maxOsContextCount);
memoryAllocation->set32BitAllocation(true);
memoryAllocation->setGpuBaseAddress(GmmHelper::canonize(gfxPartition->getHeapBase(heap)));
memoryAllocation->setGpuBaseAddress(gmmHelper->canonize(gfxPartition->getHeapBase(heap)));
memoryAllocation->sizeToFree = allocationSize;
}
counter++;
@@ -429,12 +432,12 @@ MemoryAllocation *OsAgnosticMemoryManager::createMemoryAllocation(AllocationType
auto gfxPartition = getGfxPartition(rootDeviceIndex);
uint64_t limitedGpuAddress = gfxPartition->heapAllocate(heap, alignedSize);
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getGmmHelper();
auto memoryAllocation = new MemoryAllocation(rootDeviceIndex, allocationType, driverAllocatedCpuPointer, pMem, limitedGpuAddress, memSize,
count, pool, uncacheable, flushL3Required, maxOsContextCount);
if (heap == HeapIndex::HEAP_EXTERNAL) {
memoryAllocation->setGpuBaseAddress(GmmHelper::canonize(gfxPartition->getHeapBase(heap)));
memoryAllocation->setGpuBaseAddress(gmmHelper->canonize(gfxPartition->getHeapBase(heap)));
}
memoryAllocation->sizeToFree = alignedSize;
@@ -443,7 +446,8 @@ MemoryAllocation *OsAgnosticMemoryManager::createMemoryAllocation(AllocationType
AddressRange OsAgnosticMemoryManager::reserveGpuAddress(size_t size, uint32_t rootDeviceIndex) {
auto gfxPartition = getGfxPartition(rootDeviceIndex);
auto gpuVa = GmmHelper::canonize(gfxPartition->heapAllocate(HeapIndex::HEAP_STANDARD, size));
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getGmmHelper();
auto gpuVa = gmmHelper->canonize(gfxPartition->heapAllocate(HeapIndex::HEAP_STANDARD, size));
return AddressRange{gpuVa, size};
}
@@ -514,7 +518,8 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryInDevicePool(
memset(systemMemory, 0, sizeAligned64k);
}
auto sizeOfHeapChunk = sizeAligned64k;
auto gpuAddress = GmmHelper::canonize(gfxPartition->heapAllocate(heapIndex, sizeOfHeapChunk));
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper();
auto gpuAddress = gmmHelper->canonize(gfxPartition->heapAllocate(heapIndex, sizeOfHeapChunk));
allocation = new MemoryAllocation(allocationData.rootDeviceIndex, numHandles, allocationData.type, systemMemory, systemMemory,
gpuAddress, sizeAligned64k, counter,
MemoryPool::LocalMemory, false, allocationData.flags.flushL3, maxOsContextCount);

View File

@@ -203,7 +203,8 @@ uint32_t DrmMemoryManager::unreference(NEO::BufferObject *bo, bool synchronousDe
uint64_t DrmMemoryManager::acquireGpuRange(size_t &size, uint32_t rootDeviceIndex, HeapIndex heapIndex) {
auto gfxPartition = getGfxPartition(rootDeviceIndex);
return GmmHelper::canonize(gfxPartition->heapAllocate(heapIndex, size));
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex].get()->gmmHelper.get();
return gmmHelper->canonize(gfxPartition->heapAllocate(heapIndex, size));
}
void DrmMemoryManager::releaseGpuRange(void *address, size_t unmapSize, uint32_t rootDeviceIndex) {
@@ -595,10 +596,12 @@ DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemoryImpl(const Allocatio
}
bo->setAddress(gpuVirtualAddress);
auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), const_cast<void *>(allocationData.hostPtr), GmmHelper::canonize(ptrOffset(gpuVirtualAddress, inputPointerOffset)),
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex].get()->gmmHelper.get();
auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), const_cast<void *>(allocationData.hostPtr),
gmmHelper->canonize(ptrOffset(gpuVirtualAddress, inputPointerOffset)),
allocationSize, MemoryPool::System4KBPagesWith32BitGpuAddressing);
allocation->set32BitAllocation(true);
allocation->setGpuBaseAddress(GmmHelper::canonize(gfxPartition->getHeapBase(allocatorToUse)));
allocation->setGpuBaseAddress(gmmHelper->canonize(gfxPartition->getHeapBase(allocatorToUse)));
allocation->setReservedAddressRange(reinterpret_cast<void *>(gpuVirtualAddress), realAllocationSize);
bo.release();
return allocation;
@@ -629,13 +632,15 @@ DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemoryImpl(const Allocatio
}
bo->setAddress(gpuVA);
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex].get()->gmmHelper.get();
// softpin to the GPU address, res if it uses limitedRange Allocation
auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), ptrAlloc, GmmHelper::canonize(gpuVA), alignedAllocationSize,
auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), ptrAlloc,
gmmHelper->canonize(gpuVA), alignedAllocationSize,
MemoryPool::System4KBPagesWith32BitGpuAddressing);
allocation->set32BitAllocation(true);
allocation->setGpuBaseAddress(GmmHelper::canonize(gfxPartition->getHeapBase(allocatorToUse)));
allocation->setGpuBaseAddress(gmmHelper->canonize(gfxPartition->getHeapBase(allocatorToUse)));
allocation->setDriverAllocatedCpuPtr(ptrAlloc);
allocation->setReservedAddressRange(reinterpret_cast<void *>(gpuVA), allocationSize);
bo.release();
@@ -805,7 +810,8 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
if (requireSpecificBitness && this->force32bitAllocations) {
drmAllocation->set32BitAllocation(true);
drmAllocation->setGpuBaseAddress(GmmHelper::canonize(getExternalHeapBaseAddress(properties.rootDeviceIndex, drmAllocation->isAllocatedInLocalMemoryPool())));
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex].get()->gmmHelper.get();
drmAllocation->setGpuBaseAddress(gmmHelper->canonize(getExternalHeapBaseAddress(properties.rootDeviceIndex, drmAllocation->isAllocatedInLocalMemoryPool())));
}
if (properties.imgInfo) {
@@ -868,7 +874,9 @@ GraphicsAllocation *DrmMemoryManager::createPaddedAllocation(GraphicsAllocation
return nullptr;
}
bo->setAddress(gpuRange);
auto allocation = new DrmAllocation(rootDeviceIndex, inputGraphicsAllocation->getAllocationType(), bo.get(), srcPtr, GmmHelper::canonize(ptrOffset(gpuRange, offset)), sizeWithPadding,
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex].get()->gmmHelper.get();
auto allocation = new DrmAllocation(rootDeviceIndex, inputGraphicsAllocation->getAllocationType(), bo.get(), srcPtr,
gmmHelper->canonize(ptrOffset(gpuRange, offset)), sizeWithPadding,
inputGraphicsAllocation->getMemoryPool());
allocation->setReservedAddressRange(reinterpret_cast<void *>(gpuRange), sizeWithPadding);
@@ -1512,7 +1520,8 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A
allocation->setCpuPtrAndGpuAddress(cpuAddress, gpuAddress);
}
if (heapAssigner.useInternal32BitHeap(allocationData.type)) {
allocation->setGpuBaseAddress(GmmHelper::canonize(getInternalHeapBaseAddress(allocationData.rootDeviceIndex, true)));
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex].get()->gmmHelper.get();
allocation->setGpuBaseAddress(gmmHelper->canonize(getInternalHeapBaseAddress(allocationData.rootDeviceIndex, true)));
}
if (!allocation->setCacheRegion(&getDrm(allocationData.rootDeviceIndex), static_cast<CacheRegion>(allocationData.cacheRegion))) {
cleanupBeforeReturn(allocationData, gfxPartition, drmAllocation, graphicsAllocation, gpuAddress, sizeAllocated);

View File

@@ -441,7 +441,9 @@ bool Wddm::mapGpuVirtualAddress(Gmm *gmm, D3DKMT_HANDLE handle, D3DGPU_VIRTUAL_A
applyAdditionalMapGPUVAFields(MapGPUVA, gmm);
NTSTATUS status = getGdi()->mapGpuVirtualAddress(&MapGPUVA);
gpuPtr = GmmHelper::canonize(MapGPUVA.VirtualAddress);
auto gmmHelper = rootDeviceEnvironment.getGmmHelper();
gpuPtr = gmmHelper->canonize(MapGPUVA.VirtualAddress);
if (status == STATUS_PENDING) {
updatePagingFenceValue(MapGPUVA.PagingFenceValue);

View File

@@ -395,7 +395,8 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All
return nullptr;
}
auto baseAddress = getGfxPartition(allocationData.rootDeviceIndex)->getHeapBase(heapAssigner.get32BitHeapIndex(allocationData.type, useLocalMemory, *hwInfo, allocationData.flags.use32BitFrontWindow));
wddmAllocation->setGpuBaseAddress(GmmHelper::canonize(baseAddress));
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper();
wddmAllocation->setGpuBaseAddress(gmmHelper->canonize(baseAddress));
if (preferredAllocationMethod != GfxMemoryAllocationMethod::UseUmdSystemPtr) {
auto lockedPtr = lockResource(wddmAllocation.get());
@@ -438,7 +439,8 @@ GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handl
allocation->setReservedAddressRange(ptr, size);
} else if (requireSpecificBitness && this->force32bitAllocations) {
allocation->set32BitAllocation(true);
allocation->setGpuBaseAddress(GmmHelper::canonize(getExternalHeapBaseAddress(allocation->getRootDeviceIndex(), false)));
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[allocation->getRootDeviceIndex()]->getGmmHelper();
allocation->setGpuBaseAddress(gmmHelper->canonize(getExternalHeapBaseAddress(allocation->getRootDeviceIndex(), false)));
}
status = mapGpuVirtualAddress(allocation.get(), allocation->getReservedAddressPtr());
DEBUG_BREAK_IF(!status);
@@ -773,7 +775,8 @@ bool WddmMemoryManager::mapMultiHandleAllocationWithRetry(WddmAllocation *alloca
allocation->reservedSizeForGpuVirtualAddress = alignUp(alignedSize, MemoryConstants::pageSize64k);
allocation->reservedGpuVirtualAddress = wddm.reserveGpuVirtualAddress(gfxPartition->getHeapMinimalAddress(heapIndex), gfxPartition->getHeapLimit(heapIndex),
allocation->reservedSizeForGpuVirtualAddress);
allocation->getGpuAddressToModify() = GmmHelper::canonize(allocation->reservedGpuVirtualAddress);
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[allocation->getRootDeviceIndex()]->getGmmHelper();
allocation->getGpuAddressToModify() = gmmHelper->canonize(allocation->reservedGpuVirtualAddress);
addressToMap = allocation->reservedGpuVirtualAddress;
}
@@ -1090,7 +1093,8 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryInDevicePool(const
wddmAllocation->setCpuAddress(lockResource(wddmAllocation.get()));
}
if (heapAssigner.useInternal32BitHeap(allocationData.type)) {
wddmAllocation->setGpuBaseAddress(GmmHelper::canonize(getInternalHeapBaseAddress(wddmAllocation->getRootDeviceIndex(), true)));
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[wddmAllocation->getRootDeviceIndex()]->getGmmHelper();
wddmAllocation->setGpuBaseAddress(gmmHelper->canonize(getInternalHeapBaseAddress(wddmAllocation->getRootDeviceIndex(), true)));
}
status = AllocationStatus::Success;

View File

@@ -240,7 +240,8 @@ HWTEST_F(WddmDirectSubmissionTest, givenWddmWhenSwitchingRingBufferStartedThenEx
hwParse.parseCommands<FamilyType>(tmpCmdBuffer, usedSpace);
MI_BATCH_BUFFER_START *bbStart = hwParse.getCommand<MI_BATCH_BUFFER_START>();
ASSERT_NE(nullptr, bbStart);
uint64_t actualGpuVa = GmmHelper::canonize(bbStart->getBatchBufferStartAddress());
auto gmmHelper = device->getGmmHelper();
uint64_t actualGpuVa = gmmHelper->canonize(bbStart->getBatchBufferStartAddress());
EXPECT_EQ(wddmDirectSubmission.ringBuffer2->getGpuAddress(), actualGpuVa);
}
@@ -293,7 +294,8 @@ HWTEST_F(WddmDirectSubmissionTest, givenWddmWhenSwitchingRingBufferStartedAndWai
hwParse.parseCommands<FamilyType>(tmpCmdBuffer, usedSpace);
MI_BATCH_BUFFER_START *bbStart = hwParse.getCommand<MI_BATCH_BUFFER_START>();
ASSERT_NE(nullptr, bbStart);
uint64_t actualGpuVa = GmmHelper::canonize(bbStart->getBatchBufferStartAddress());
auto gmmHelper = device->getGmmHelper();
uint64_t actualGpuVa = gmmHelper->canonize(bbStart->getBatchBufferStartAddress());
EXPECT_EQ(wddmDirectSubmission.ringBuffer2->getGpuAddress(), actualGpuVa);
EXPECT_EQ(1u, wddm->waitFromCpuResult.called);

View File

@@ -272,10 +272,12 @@ HWTEST_F(MemoryManagerTests, givenEnabledLocalMemoryWhenAllocatingDebugAreaThenH
}
auto moduleDebugArea = osAgnosticMemoryManager.allocateGraphicsMemoryWithProperties(properties);
auto gpuAddress = moduleDebugArea->getGpuAddress();
EXPECT_LE(GmmHelper::canonize(osAgnosticMemoryManager.getGfxPartition(0)->getHeapBase(expectedHeap)), gpuAddress);
EXPECT_GT(GmmHelper::canonize(osAgnosticMemoryManager.getGfxPartition(0)->getHeapLimit(expectedHeap)), gpuAddress);
EXPECT_EQ(GmmHelper::canonize(osAgnosticMemoryManager.getGfxPartition(0)->getHeapBase(expectedHeap)), moduleDebugArea->getGpuBaseAddress());
EXPECT_EQ(GmmHelper::canonize(osAgnosticMemoryManager.getGfxPartition(0)->getHeapBase(baseHeap)), moduleDebugArea->getGpuBaseAddress());
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[moduleDebugArea->getRootDeviceIndex()].get()->getGmmHelper();
EXPECT_LE(gmmHelper->canonize(osAgnosticMemoryManager.getGfxPartition(0)->getHeapBase(expectedHeap)), gpuAddress);
EXPECT_GT(gmmHelper->canonize(osAgnosticMemoryManager.getGfxPartition(0)->getHeapLimit(expectedHeap)), gpuAddress);
EXPECT_EQ(gmmHelper->canonize(osAgnosticMemoryManager.getGfxPartition(0)->getHeapBase(expectedHeap)), moduleDebugArea->getGpuBaseAddress());
EXPECT_EQ(gmmHelper->canonize(osAgnosticMemoryManager.getGfxPartition(0)->getHeapBase(baseHeap)), moduleDebugArea->getGpuBaseAddress());
osAgnosticMemoryManager.freeGraphicsMemory(moduleDebugArea);
}

View File

@@ -30,8 +30,11 @@ TEST_F(FrontWindowAllocatorTests, givenAllocateInFrontWindowPoolFlagWhenAllocate
allocData.size = MemoryConstants::kiloByte;
auto allocation(memManager->allocate32BitGraphicsMemoryImpl(allocData, false));
auto heap = memManager->heapAssigner.get32BitHeapIndex(allocData.type, false, *defaultHwInfo, true);
EXPECT_EQ(GmmHelper::canonize(memManager->getGfxPartition(0)->getHeapMinimalAddress(heap)), allocation->getGpuAddress());
EXPECT_LT(ptrOffset(allocation->getGpuAddress(), allocation->getUnderlyingBufferSize()), GmmHelper::canonize(memManager->getGfxPartition(0)->getHeapLimit(heap)));
auto gmmHelper = memManager.get()->peekExecutionEnvironment().rootDeviceEnvironments[allocation->getRootDeviceIndex()].get()->getGmmHelper();
EXPECT_EQ(gmmHelper->canonize(memManager->getGfxPartition(0)->getHeapMinimalAddress(heap)), allocation->getGpuAddress());
EXPECT_LT(ptrOffset(allocation->getGpuAddress(), allocation->getUnderlyingBufferSize()), gmmHelper->canonize(memManager->getGfxPartition(0)->getHeapLimit(heap)));
memManager->freeGraphicsMemory(allocation);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -48,7 +48,8 @@ TEST_F(WddmFrontWindowPoolAllocatorTests, givenAllocateInFrontWindowPoolFlagWhen
allocData.flags.use32BitFrontWindow = true;
allocData.size = MemoryConstants::kiloByte;
auto allocation = memManager->allocate32BitGraphicsMemoryImpl(allocData, false);
EXPECT_EQ(allocation->getGpuBaseAddress(), GmmHelper::canonize(allocation->getGpuAddress()));
auto gmmHelper = executionEnvironment->rootDeviceEnvironments[allocData.rootDeviceIndex]->getGmmHelper();
EXPECT_EQ(allocation->getGpuBaseAddress(), gmmHelper->canonize(allocation->getGpuAddress()));
memManager->freeGraphicsMemory(allocation);
}
} // namespace NEO