mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Create getGmmHelper function in MemoryManager
Related-To: NEO-6523 Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
518595dd97
commit
4f1e01d279
@@ -207,6 +207,9 @@ class MemoryManager {
|
||||
virtual void releaseReservedCpuAddressRange(void *reserved, size_t size, uint32_t rootDeviceIndex){};
|
||||
void *getReservedMemory(size_t size, size_t alignment);
|
||||
GfxPartition *getGfxPartition(uint32_t rootDeviceIndex) { return gfxPartitions.at(rootDeviceIndex).get(); }
|
||||
GmmHelper *getGmmHelper(uint32_t rootDeviceIndex) {
|
||||
return executionEnvironment.rootDeviceEnvironments[rootDeviceIndex].get()->getGmmHelper();
|
||||
}
|
||||
virtual AddressRange reserveGpuAddress(size_t size, uint32_t rootDeviceIndex) = 0;
|
||||
virtual void freeGpuAddress(AddressRange addressRange, uint32_t rootDeviceIndex) = 0;
|
||||
static HeapIndex selectInternalHeap(bool useLocalMemory) { return useLocalMemory ? HeapIndex::HEAP_INTERNAL_DEVICE_MEMORY : HeapIndex::HEAP_INTERNAL; }
|
||||
|
||||
@@ -177,7 +177,7 @@ 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();
|
||||
auto gmmHelper = getGmmHelper(allocationData.rootDeviceIndex);
|
||||
|
||||
if (allocationData.hostPtr) {
|
||||
auto allocationSize = alignSizeWholePage(allocationData.hostPtr, allocationData.size);
|
||||
@@ -432,7 +432,7 @@ MemoryAllocation *OsAgnosticMemoryManager::createMemoryAllocation(AllocationType
|
||||
|
||||
auto gfxPartition = getGfxPartition(rootDeviceIndex);
|
||||
uint64_t limitedGpuAddress = gfxPartition->heapAllocate(heap, alignedSize);
|
||||
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getGmmHelper();
|
||||
auto gmmHelper = getGmmHelper(rootDeviceIndex);
|
||||
auto memoryAllocation = new MemoryAllocation(rootDeviceIndex, allocationType, driverAllocatedCpuPointer, pMem, limitedGpuAddress, memSize,
|
||||
count, pool, uncacheable, flushL3Required, maxOsContextCount);
|
||||
|
||||
@@ -446,7 +446,7 @@ MemoryAllocation *OsAgnosticMemoryManager::createMemoryAllocation(AllocationType
|
||||
|
||||
AddressRange OsAgnosticMemoryManager::reserveGpuAddress(size_t size, uint32_t rootDeviceIndex) {
|
||||
auto gfxPartition = getGfxPartition(rootDeviceIndex);
|
||||
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getGmmHelper();
|
||||
auto gmmHelper = getGmmHelper(rootDeviceIndex);
|
||||
auto gpuVa = gmmHelper->canonize(gfxPartition->heapAllocate(HeapIndex::HEAP_STANDARD, size));
|
||||
return AddressRange{gpuVa, size};
|
||||
}
|
||||
@@ -518,7 +518,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryInDevicePool(
|
||||
memset(systemMemory, 0, sizeAligned64k);
|
||||
}
|
||||
auto sizeOfHeapChunk = sizeAligned64k;
|
||||
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper();
|
||||
auto gmmHelper = getGmmHelper(allocationData.rootDeviceIndex);
|
||||
auto gpuAddress = gmmHelper->canonize(gfxPartition->heapAllocate(heapIndex, sizeOfHeapChunk));
|
||||
allocation = new MemoryAllocation(allocationData.rootDeviceIndex, numHandles, allocationData.type, systemMemory, systemMemory,
|
||||
gpuAddress, sizeAligned64k, counter,
|
||||
|
||||
@@ -203,7 +203,7 @@ 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);
|
||||
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex].get()->gmmHelper.get();
|
||||
auto gmmHelper = getGmmHelper(rootDeviceIndex);
|
||||
return gmmHelper->canonize(gfxPartition->heapAllocate(heapIndex, size));
|
||||
}
|
||||
|
||||
@@ -596,7 +596,7 @@ DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemoryImpl(const Allocatio
|
||||
}
|
||||
|
||||
bo->setAddress(gpuVirtualAddress);
|
||||
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex].get()->gmmHelper.get();
|
||||
auto gmmHelper = getGmmHelper(allocationData.rootDeviceIndex);
|
||||
auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), const_cast<void *>(allocationData.hostPtr),
|
||||
gmmHelper->canonize(ptrOffset(gpuVirtualAddress, inputPointerOffset)),
|
||||
allocationSize, MemoryPool::System4KBPagesWith32BitGpuAddressing);
|
||||
@@ -632,7 +632,7 @@ DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemoryImpl(const Allocatio
|
||||
}
|
||||
|
||||
bo->setAddress(gpuVA);
|
||||
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex].get()->gmmHelper.get();
|
||||
auto gmmHelper = getGmmHelper(allocationData.rootDeviceIndex);
|
||||
|
||||
// softpin to the GPU address, res if it uses limitedRange Allocation
|
||||
auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo.get(), ptrAlloc,
|
||||
@@ -810,7 +810,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o
|
||||
|
||||
if (requireSpecificBitness && this->force32bitAllocations) {
|
||||
drmAllocation->set32BitAllocation(true);
|
||||
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex].get()->gmmHelper.get();
|
||||
auto gmmHelper = getGmmHelper(properties.rootDeviceIndex);
|
||||
drmAllocation->setGpuBaseAddress(gmmHelper->canonize(getExternalHeapBaseAddress(properties.rootDeviceIndex, drmAllocation->isAllocatedInLocalMemoryPool())));
|
||||
}
|
||||
|
||||
@@ -874,7 +874,7 @@ GraphicsAllocation *DrmMemoryManager::createPaddedAllocation(GraphicsAllocation
|
||||
return nullptr;
|
||||
}
|
||||
bo->setAddress(gpuRange);
|
||||
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex].get()->gmmHelper.get();
|
||||
auto gmmHelper = getGmmHelper(rootDeviceIndex);
|
||||
auto allocation = new DrmAllocation(rootDeviceIndex, inputGraphicsAllocation->getAllocationType(), bo.get(), srcPtr,
|
||||
gmmHelper->canonize(ptrOffset(gpuRange, offset)), sizeWithPadding,
|
||||
inputGraphicsAllocation->getMemoryPool());
|
||||
@@ -1520,7 +1520,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A
|
||||
allocation->setCpuPtrAndGpuAddress(cpuAddress, gpuAddress);
|
||||
}
|
||||
if (heapAssigner.useInternal32BitHeap(allocationData.type)) {
|
||||
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex].get()->gmmHelper.get();
|
||||
auto gmmHelper = getGmmHelper(allocationData.rootDeviceIndex);
|
||||
allocation->setGpuBaseAddress(gmmHelper->canonize(getInternalHeapBaseAddress(allocationData.rootDeviceIndex, true)));
|
||||
}
|
||||
if (!allocation->setCacheRegion(&getDrm(allocationData.rootDeviceIndex), static_cast<CacheRegion>(allocationData.cacheRegion))) {
|
||||
|
||||
@@ -395,7 +395,7 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All
|
||||
return nullptr;
|
||||
}
|
||||
auto baseAddress = getGfxPartition(allocationData.rootDeviceIndex)->getHeapBase(heapAssigner.get32BitHeapIndex(allocationData.type, useLocalMemory, *hwInfo, allocationData.flags.use32BitFrontWindow));
|
||||
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmHelper();
|
||||
auto gmmHelper = getGmmHelper(allocationData.rootDeviceIndex);
|
||||
wddmAllocation->setGpuBaseAddress(gmmHelper->canonize(baseAddress));
|
||||
|
||||
if (preferredAllocationMethod != GfxMemoryAllocationMethod::UseUmdSystemPtr) {
|
||||
@@ -439,7 +439,7 @@ GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handl
|
||||
allocation->setReservedAddressRange(ptr, size);
|
||||
} else if (requireSpecificBitness && this->force32bitAllocations) {
|
||||
allocation->set32BitAllocation(true);
|
||||
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[allocation->getRootDeviceIndex()]->getGmmHelper();
|
||||
auto gmmHelper = getGmmHelper(allocation->getRootDeviceIndex());
|
||||
allocation->setGpuBaseAddress(gmmHelper->canonize(getExternalHeapBaseAddress(allocation->getRootDeviceIndex(), false)));
|
||||
}
|
||||
status = mapGpuVirtualAddress(allocation.get(), allocation->getReservedAddressPtr());
|
||||
@@ -775,7 +775,7 @@ bool WddmMemoryManager::mapMultiHandleAllocationWithRetry(WddmAllocation *alloca
|
||||
allocation->reservedSizeForGpuVirtualAddress = alignUp(alignedSize, MemoryConstants::pageSize64k);
|
||||
allocation->reservedGpuVirtualAddress = wddm.reserveGpuVirtualAddress(gfxPartition->getHeapMinimalAddress(heapIndex), gfxPartition->getHeapLimit(heapIndex),
|
||||
allocation->reservedSizeForGpuVirtualAddress);
|
||||
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[allocation->getRootDeviceIndex()]->getGmmHelper();
|
||||
auto gmmHelper = getGmmHelper(allocation->getRootDeviceIndex());
|
||||
allocation->getGpuAddressToModify() = gmmHelper->canonize(allocation->reservedGpuVirtualAddress);
|
||||
addressToMap = allocation->reservedGpuVirtualAddress;
|
||||
}
|
||||
@@ -1093,7 +1093,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryInDevicePool(const
|
||||
wddmAllocation->setCpuAddress(lockResource(wddmAllocation.get()));
|
||||
}
|
||||
if (heapAssigner.useInternal32BitHeap(allocationData.type)) {
|
||||
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[wddmAllocation->getRootDeviceIndex()]->getGmmHelper();
|
||||
auto gmmHelper = getGmmHelper(wddmAllocation->getRootDeviceIndex());
|
||||
wddmAllocation->setGpuBaseAddress(gmmHelper->canonize(getInternalHeapBaseAddress(wddmAllocation->getRootDeviceIndex(), true)));
|
||||
}
|
||||
|
||||
|
||||
@@ -272,7 +272,7 @@ HWTEST_F(MemoryManagerTests, givenEnabledLocalMemoryWhenAllocatingDebugAreaThenH
|
||||
}
|
||||
auto moduleDebugArea = osAgnosticMemoryManager.allocateGraphicsMemoryWithProperties(properties);
|
||||
auto gpuAddress = moduleDebugArea->getGpuAddress();
|
||||
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[moduleDebugArea->getRootDeviceIndex()].get()->getGmmHelper();
|
||||
auto gmmHelper = osAgnosticMemoryManager.getGmmHelper(moduleDebugArea->getRootDeviceIndex());
|
||||
|
||||
EXPECT_LE(gmmHelper->canonize(osAgnosticMemoryManager.getGfxPartition(0)->getHeapBase(expectedHeap)), gpuAddress);
|
||||
EXPECT_GT(gmmHelper->canonize(osAgnosticMemoryManager.getGfxPartition(0)->getHeapLimit(expectedHeap)), gpuAddress);
|
||||
|
||||
@@ -30,7 +30,7 @@ TEST_F(FrontWindowAllocatorTests, givenAllocateInFrontWindowPoolFlagWhenAllocate
|
||||
allocData.size = MemoryConstants::kiloByte;
|
||||
auto allocation(memManager->allocate32BitGraphicsMemoryImpl(allocData, false));
|
||||
auto heap = memManager->heapAssigner.get32BitHeapIndex(allocData.type, false, *defaultHwInfo, true);
|
||||
auto gmmHelper = memManager.get()->peekExecutionEnvironment().rootDeviceEnvironments[allocation->getRootDeviceIndex()].get()->getGmmHelper();
|
||||
auto gmmHelper = memManager.get()->getGmmHelper(allocData.rootDeviceIndex);
|
||||
|
||||
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)));
|
||||
|
||||
@@ -48,7 +48,7 @@ TEST_F(WddmFrontWindowPoolAllocatorTests, givenAllocateInFrontWindowPoolFlagWhen
|
||||
allocData.flags.use32BitFrontWindow = true;
|
||||
allocData.size = MemoryConstants::kiloByte;
|
||||
auto allocation = memManager->allocate32BitGraphicsMemoryImpl(allocData, false);
|
||||
auto gmmHelper = executionEnvironment->rootDeviceEnvironments[allocData.rootDeviceIndex]->getGmmHelper();
|
||||
auto gmmHelper = memManager->getGmmHelper(allocData.rootDeviceIndex);
|
||||
EXPECT_EQ(allocation->getGpuBaseAddress(), gmmHelper->canonize(allocation->getGpuAddress()));
|
||||
memManager->freeGraphicsMemory(allocation);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user