mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-25 13:33:02 +08:00
feature: Support for pStart
Related-To: NEO-15156, GSD-9939 Support for start address hint in zeVirtualMemReserve. If it fails to find pStart then it defaults to the base line allocateWithCustomAlignment(...) Signed-off-by: Chandio, Bibrak Qamar <bibrak.qamar.chandio@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
01a4769141
commit
47caeda487
@@ -1258,34 +1258,34 @@ bool Wddm::isGpuHangDetected(OsContext &osContext) {
|
||||
|
||||
void Wddm::initGfxPartition(GfxPartition &outGfxPartition, uint32_t rootDeviceIndex, size_t numRootDevices, bool useExternalFrontWindowPool) const {
|
||||
if (gfxPartition.SVM.Limit != 0) {
|
||||
outGfxPartition.heapInit(HeapIndex::heapSvm, gfxPartition.SVM.Base, gfxPartition.SVM.Limit - gfxPartition.SVM.Base + 1);
|
||||
outGfxPartition.heapInitWithAllocationAlignment(HeapIndex::heapSvm, gfxPartition.SVM.Base, gfxPartition.SVM.Limit - gfxPartition.SVM.Base + 1, MemoryConstants::pageSize64k);
|
||||
} else if (is32bit) {
|
||||
outGfxPartition.heapInit(HeapIndex::heapSvm, 0x0ull, 4 * MemoryConstants::gigaByte);
|
||||
outGfxPartition.heapInitWithAllocationAlignment(HeapIndex::heapSvm, 0x0ull, 4 * MemoryConstants::gigaByte, MemoryConstants::pageSize64k);
|
||||
}
|
||||
|
||||
outGfxPartition.heapInit(HeapIndex::heapStandard, gfxPartition.Standard.Base, gfxPartition.Standard.Limit - gfxPartition.Standard.Base + 1);
|
||||
outGfxPartition.heapInitWithAllocationAlignment(HeapIndex::heapStandard, gfxPartition.Standard.Base, gfxPartition.Standard.Limit - gfxPartition.Standard.Base + 1, MemoryConstants::pageSize64k);
|
||||
|
||||
// Split HEAP_STANDARD64K among root devices
|
||||
auto gfxStandard64KBSize = alignDown((gfxPartition.Standard64KB.Limit - gfxPartition.Standard64KB.Base + 1) / numRootDevices, GfxPartition::heapGranularity);
|
||||
outGfxPartition.heapInit(HeapIndex::heapStandard64KB, gfxPartition.Standard64KB.Base + rootDeviceIndex * gfxStandard64KBSize, gfxStandard64KBSize);
|
||||
outGfxPartition.heapInitWithAllocationAlignment(HeapIndex::heapStandard64KB, gfxPartition.Standard64KB.Base + rootDeviceIndex * gfxStandard64KBSize, gfxStandard64KBSize, MemoryConstants::pageSize64k);
|
||||
|
||||
for (auto heap : GfxPartition::heap32Names) {
|
||||
if (useExternalFrontWindowPool && HeapAssigner::heapTypeExternalWithFrontWindowPool(heap)) {
|
||||
outGfxPartition.heapInitExternalWithFrontWindow(heap, gfxPartition.Heap32[static_cast<uint32_t>(heap)].Base,
|
||||
gfxPartition.Heap32[static_cast<uint32_t>(heap)].Limit - gfxPartition.Heap32[static_cast<uint32_t>(heap)].Base + 1);
|
||||
gfxPartition.Heap32[static_cast<uint32_t>(heap)].Limit - gfxPartition.Heap32[static_cast<uint32_t>(heap)].Base + 1, MemoryConstants::pageSize64k);
|
||||
size_t externalFrontWindowSize = GfxPartition::externalFrontWindowPoolSize;
|
||||
outGfxPartition.heapInitExternalWithFrontWindow(HeapAssigner::mapExternalWindowIndex(heap), outGfxPartition.heapAllocate(heap, externalFrontWindowSize),
|
||||
externalFrontWindowSize);
|
||||
externalFrontWindowSize, MemoryConstants::pageSize64k);
|
||||
} else if (HeapAssigner::isInternalHeap(heap)) {
|
||||
auto baseAddress = gfxPartition.Heap32[static_cast<uint32_t>(heap)].Base >= minAddress ? gfxPartition.Heap32[static_cast<uint32_t>(heap)].Base : minAddress;
|
||||
|
||||
outGfxPartition.heapInitWithFrontWindow(heap, baseAddress,
|
||||
gfxPartition.Heap32[static_cast<uint32_t>(heap)].Limit - baseAddress + 1,
|
||||
GfxPartition::internalFrontWindowPoolSize);
|
||||
outGfxPartition.heapInitFrontWindow(HeapAssigner::mapInternalWindowIndex(heap), baseAddress, GfxPartition::internalFrontWindowPoolSize);
|
||||
GfxPartition::internalFrontWindowPoolSize, MemoryConstants::pageSize64k);
|
||||
outGfxPartition.heapInitFrontWindow(HeapAssigner::mapInternalWindowIndex(heap), baseAddress, GfxPartition::internalFrontWindowPoolSize, MemoryConstants::pageSize64k);
|
||||
} else {
|
||||
outGfxPartition.heapInit(heap, gfxPartition.Heap32[static_cast<uint32_t>(heap)].Base,
|
||||
gfxPartition.Heap32[static_cast<uint32_t>(heap)].Limit - gfxPartition.Heap32[static_cast<uint32_t>(heap)].Base + 1);
|
||||
outGfxPartition.heapInitWithAllocationAlignment(heap, gfxPartition.Heap32[static_cast<uint32_t>(heap)].Base,
|
||||
gfxPartition.Heap32[static_cast<uint32_t>(heap)].Limit - gfxPartition.Heap32[static_cast<uint32_t>(heap)].Base + 1, MemoryConstants::pageSize64k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -987,13 +987,30 @@ bool WddmMemoryManager::createWddmAllocation(WddmAllocation *allocation, void *r
|
||||
}
|
||||
|
||||
size_t WddmMemoryManager::selectAlignmentAndHeap(size_t size, HeapIndex *heap) {
|
||||
AlignmentSelector::CandidateAlignment alignment = alignmentSelector.selectAlignment(size);
|
||||
return selectAlignmentAndHeap(0ULL, size, heap);
|
||||
}
|
||||
|
||||
size_t WddmMemoryManager::selectAlignmentAndHeap(const uint64_t requiredStartAddress, size_t size, HeapIndex *heap) {
|
||||
|
||||
// Always default to heapStandard64KB.
|
||||
*heap = HeapIndex::heapStandard64KB;
|
||||
|
||||
// If the user provides a start address, we try to find the heap and page size alignment based on that address.
|
||||
if (requiredStartAddress != 0ULL) {
|
||||
auto rootDeviceIndex = 0u;
|
||||
auto gfxPartition = getGfxPartition(rootDeviceIndex);
|
||||
size_t pageSizeAlignment = 0;
|
||||
if (gfxPartition->getHeapIndexAndPageSizeBasedOnAddress(requiredStartAddress, *heap, pageSizeAlignment)) {
|
||||
return pageSizeAlignment;
|
||||
}
|
||||
}
|
||||
|
||||
AlignmentSelector::CandidateAlignment alignment = alignmentSelector.selectAlignment(size);
|
||||
return alignment.alignment;
|
||||
}
|
||||
|
||||
AddressRange WddmMemoryManager::reserveGpuAddress(const uint64_t requiredStartAddress, size_t size, const RootDeviceIndicesContainer &rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex) {
|
||||
return reserveGpuAddressOnHeap(requiredStartAddress, size, rootDeviceIndices, reservedOnRootDeviceIndex, HeapIndex::heapStandard64KB, MemoryConstants::pageSize64k);
|
||||
return reserveGpuAddressOnHeap(requiredStartAddress, size, rootDeviceIndices, reservedOnRootDeviceIndex, HeapIndex::heapStandard64KB, MemoryConstants::pageSize2M);
|
||||
}
|
||||
|
||||
AddressRange WddmMemoryManager::reserveGpuAddressOnHeap(const uint64_t requiredStartAddress, size_t size, const RootDeviceIndicesContainer &rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex, HeapIndex heap, size_t alignment) {
|
||||
|
||||
@@ -65,6 +65,7 @@ class WddmMemoryManager : public MemoryManager, NEO::NonCopyableAndNonMovableCla
|
||||
AddressRange reserveGpuAddress(const uint64_t requiredStartAddress, size_t size, const RootDeviceIndicesContainer &rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex) override;
|
||||
AddressRange reserveGpuAddressOnHeap(const uint64_t requiredStartAddress, size_t size, const RootDeviceIndicesContainer &rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex, HeapIndex heap, size_t alignment) override;
|
||||
size_t selectAlignmentAndHeap(size_t size, HeapIndex *heap) override;
|
||||
size_t selectAlignmentAndHeap(const uint64_t requiredStartAddress, size_t size, HeapIndex *heap) override;
|
||||
void freeGpuAddress(AddressRange addressRange, uint32_t rootDeviceIndex) override;
|
||||
AddressRange reserveCpuAddress(const uint64_t requiredStartAddress, size_t size) override;
|
||||
void freeCpuAddress(AddressRange addressRange) override;
|
||||
|
||||
Reference in New Issue
Block a user