mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 12:23:05 +08:00
feature: Allow for Allocating a base address in the heap and grow an allocation
Related-To: LOCI-3871 - Enabled allocation of specified base address in the targeted heap. - Enabled virtual memory reservations to grow by allocating at the start of the heap vs the end of the heap. Signed-off-by: Spruit, Neil R <neil.r.spruit@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
6308c1b210
commit
44ec497b1a
@@ -217,6 +217,12 @@ uint32_t DrmMemoryManager::unreference(NEO::BufferObject *bo, bool synchronousDe
|
||||
return r;
|
||||
}
|
||||
|
||||
uint64_t DrmMemoryManager::acquireGpuRangeWithBaseAddress(size_t &size, uint32_t rootDeviceIndex, HeapIndex heapIndex, uint64_t base) {
|
||||
auto gfxPartition = getGfxPartition(rootDeviceIndex);
|
||||
auto gmmHelper = getGmmHelper(rootDeviceIndex);
|
||||
return gmmHelper->canonize(gfxPartition->heapAllocateWithBaseAddress(heapIndex, size, base));
|
||||
}
|
||||
|
||||
uint64_t DrmMemoryManager::acquireGpuRange(size_t &size, uint32_t rootDeviceIndex, HeapIndex heapIndex) {
|
||||
auto gfxPartition = getGfxPartition(rootDeviceIndex);
|
||||
auto gmmHelper = getGmmHelper(rootDeviceIndex);
|
||||
@@ -1320,20 +1326,21 @@ uint32_t DrmMemoryManager::getRootDeviceIndex(const Drm *drm) {
|
||||
return CommonConstants::unspecifiedDeviceIndex;
|
||||
}
|
||||
|
||||
AddressRange DrmMemoryManager::reserveGpuAddress(const void *requiredStartAddress, size_t size, RootDeviceIndicesContainer rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex) {
|
||||
AddressRange DrmMemoryManager::reserveGpuAddress(const uint64_t requiredStartAddress, size_t size, RootDeviceIndicesContainer rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex) {
|
||||
uint64_t gpuVa = 0u;
|
||||
*reservedOnRootDeviceIndex = 0;
|
||||
if (requiredStartAddress) {
|
||||
return AddressRange{0, 0};
|
||||
}
|
||||
size_t allocatedSize = 0;
|
||||
for (auto rootDeviceIndex : rootDeviceIndices) {
|
||||
gpuVa = acquireGpuRange(size, rootDeviceIndex, HeapIndex::HEAP_STANDARD);
|
||||
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[*reservedOnRootDeviceIndex]->getGmmHelper();
|
||||
uint64_t baseAddress = gmmHelper->decanonize(requiredStartAddress);
|
||||
gpuVa = acquireGpuRangeWithBaseAddress(size, rootDeviceIndex, HeapIndex::HEAP_STANDARD, baseAddress);
|
||||
if (gpuVa != 0u) {
|
||||
*reservedOnRootDeviceIndex = rootDeviceIndex;
|
||||
allocatedSize = size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return AddressRange{gpuVa, size};
|
||||
return AddressRange{gpuVa, allocatedSize};
|
||||
}
|
||||
|
||||
void DrmMemoryManager::freeGpuAddress(AddressRange addressRange, uint32_t rootDeviceIndex) {
|
||||
|
||||
@@ -65,7 +65,7 @@ class DrmMemoryManager : public MemoryManager {
|
||||
bool copyMemoryToAllocationBanks(GraphicsAllocation *graphicsAllocation, size_t destinationOffset, const void *memoryToCopy, size_t sizeToCopy, DeviceBitfield handleMask) override;
|
||||
|
||||
MOCKABLE_VIRTUAL int obtainFdFromHandle(int boHandle, uint32_t rootDeviceindex);
|
||||
AddressRange reserveGpuAddress(const void *requiredStartAddress, size_t size, RootDeviceIndicesContainer rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex) override;
|
||||
AddressRange reserveGpuAddress(const uint64_t requiredStartAddress, size_t size, RootDeviceIndicesContainer rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex) override;
|
||||
void freeGpuAddress(AddressRange addressRange, uint32_t rootDeviceIndex) override;
|
||||
MOCKABLE_VIRTUAL BufferObject *createBufferObjectInMemoryRegion(Drm *drm, Gmm *gmm, AllocationType allocationType, uint64_t gpuAddress, size_t size,
|
||||
uint32_t memoryBanks, size_t maxOsContextCount, int32_t pairHandle);
|
||||
@@ -100,6 +100,7 @@ class DrmMemoryManager : public MemoryManager {
|
||||
BufferObject *allocUserptr(uintptr_t address, size_t size, uint32_t rootDeviceIndex);
|
||||
bool setDomainCpu(GraphicsAllocation &graphicsAllocation, bool writeEnable);
|
||||
uint64_t acquireGpuRange(size_t &size, uint32_t rootDeviceIndex, HeapIndex heapIndex);
|
||||
uint64_t acquireGpuRangeWithBaseAddress(size_t &size, uint32_t rootDeviceIndex, HeapIndex heapIndex, uint64_t base);
|
||||
uint64_t acquireGpuRangeWithCustomAlignment(size_t &size, uint32_t rootDeviceIndex, HeapIndex heapIndex, size_t alignment);
|
||||
MOCKABLE_VIRTUAL void releaseGpuRange(void *address, size_t size, uint32_t rootDeviceIndex);
|
||||
void emitPinningRequest(BufferObject *bo, const AllocationData &allocationData) const;
|
||||
|
||||
Reference in New Issue
Block a user