mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-26 15:03:02 +08:00
feature: support SVM heap in reserveVirtualMem
Related-To: NEO-11981 Signed-off-by: Wenbin Lu <wenbin.lu@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
e30b8c0300
commit
bfaeeb01d6
@@ -27,8 +27,6 @@
|
||||
#include "shared/source/memory_manager/allocation_properties.h"
|
||||
#include "shared/source/memory_manager/gfx_partition.h"
|
||||
#include "shared/source/memory_manager/host_ptr_manager.h"
|
||||
#include "shared/source/memory_manager/local_memory_usage.h"
|
||||
#include "shared/source/memory_manager/memory_banks.h"
|
||||
#include "shared/source/memory_manager/memory_pool.h"
|
||||
#include "shared/source/memory_manager/multi_graphics_allocation.h"
|
||||
#include "shared/source/memory_manager/residency.h"
|
||||
@@ -47,7 +45,6 @@
|
||||
#include "shared/source/os_interface/product_helper.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
@@ -95,6 +92,7 @@ DrmMemoryManager::DrmMemoryManager(GemCloseWorkerMode mode,
|
||||
const auto heapIndex = customAlignment >= MemoryConstants::pageSize2M ? HeapIndex::heapStandard2MB : HeapIndex::heapStandard64KB;
|
||||
alignmentSelector.addCandidateAlignment(customAlignment, true, AlignmentSelector::anyWastage, heapIndex);
|
||||
}
|
||||
osMemory = OSMemory::create();
|
||||
|
||||
initialize(mode);
|
||||
}
|
||||
@@ -1521,6 +1519,18 @@ void DrmMemoryManager::freeGpuAddress(AddressRange addressRange, uint32_t rootDe
|
||||
releaseGpuRange(reinterpret_cast<void *>(addressRange.address), addressRange.size, rootDeviceIndex);
|
||||
}
|
||||
|
||||
AddressRange DrmMemoryManager::reserveCpuAddress(const uint64_t requiredStartAddress, size_t size) {
|
||||
void *ptr = osMemory->osReserveCpuAddressRange(addrToPtr(requiredStartAddress), size, false);
|
||||
if (ptr == MAP_FAILED) {
|
||||
ptr = nullptr;
|
||||
}
|
||||
return {castToUint64(ptr), size};
|
||||
}
|
||||
|
||||
void DrmMemoryManager::freeCpuAddress(AddressRange addressRange) {
|
||||
osMemory->osReleaseCpuAddressRange(addrToPtr(addressRange.address), addressRange.size);
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> DrmMemoryManager::acquireAllocLock() {
|
||||
return std::unique_lock<std::mutex>(this->allocMutex);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#pragma once
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/os_interface/linux/drm_buffer_object.h"
|
||||
#include "shared/source/os_interface/os_memory.h"
|
||||
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
@@ -70,6 +70,8 @@ class DrmMemoryManager : public MemoryManager {
|
||||
AddressRange reserveGpuAddressOnHeap(const uint64_t requiredStartAddress, size_t size, RootDeviceIndicesContainer rootDeviceIndices, uint32_t *reservedOnRootDeviceIndex, HeapIndex heap, size_t alignment) override;
|
||||
size_t selectAlignmentAndHeap(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;
|
||||
MOCKABLE_VIRTUAL BufferObject *createBufferObjectInMemoryRegion(uint32_t rootDeviceIndex, Gmm *gmm, AllocationType allocationType, uint64_t gpuAddress, size_t size,
|
||||
DeviceBitfield memoryBanks, size_t maxOsContextCount, int32_t pairHandle, bool isSystemMemoryPool, bool isUsmHostAllocation);
|
||||
|
||||
@@ -178,6 +180,7 @@ class DrmMemoryManager : public MemoryManager {
|
||||
bool forcePinEnabled = false;
|
||||
const bool validateHostPtrMemory;
|
||||
std::unique_ptr<DrmGemCloseWorker> gemCloseWorker;
|
||||
std::unique_ptr<OSMemory> osMemory;
|
||||
decltype(&mmap) mmapFunction = mmap;
|
||||
decltype(&munmap) munmapFunction = munmap;
|
||||
decltype(&close) closeFunction = close;
|
||||
|
||||
Reference in New Issue
Block a user