mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-30 01:35:20 +08:00
Refactor a createUnifiedMemoryAllocation method
Related-To: NEO-3330 Change-Id: I3703d2474b7b3c91d584c165952d2762c7423bab Signed-off-by: Jobczyk, Lukasz <lukasz.jobczyk@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
f4008336f8
commit
b25422deb1
@@ -92,26 +92,7 @@ void *SVMAllocsManager::createSVMAlloc(size_t size, const SvmAllocationPropertie
|
||||
}
|
||||
}
|
||||
|
||||
void *SVMAllocsManager::createUnifiedMemoryAllocation(size_t size, const UnifiedMemoryProperties memoryProperties, void *cmdQ) {
|
||||
auto supportDualStorageSharedMemory = memoryManager->isLocalMemorySupported();
|
||||
|
||||
if (DebugManager.flags.AllocateSharedAllocationsWithCpuAndGpuStorage.get() != -1) {
|
||||
supportDualStorageSharedMemory = !!DebugManager.flags.AllocateSharedAllocationsWithCpuAndGpuStorage.get();
|
||||
}
|
||||
|
||||
if (memoryProperties.memoryType == InternalMemoryType::SHARED_UNIFIED_MEMORY && supportDualStorageSharedMemory) {
|
||||
auto unifiedMemoryPointer = createUnifiedAllocationWithDeviceStorage(size, {});
|
||||
UNRECOVERABLE_IF(unifiedMemoryPointer == nullptr);
|
||||
auto unifiedMemoryAllocation = this->getSVMAlloc(unifiedMemoryPointer);
|
||||
unifiedMemoryAllocation->memoryType = memoryProperties.memoryType;
|
||||
|
||||
UNRECOVERABLE_IF(cmdQ == nullptr);
|
||||
auto pageFaultManager = this->memoryManager->getPageFaultManager();
|
||||
pageFaultManager->insertAllocation(unifiedMemoryPointer, size, this, cmdQ);
|
||||
|
||||
return unifiedMemoryPointer;
|
||||
}
|
||||
|
||||
void *SVMAllocsManager::createUnifiedMemoryAllocation(size_t size, const UnifiedMemoryProperties memoryProperties) {
|
||||
size_t alignedSize = alignUp<size_t>(size, MemoryConstants::pageSize64k);
|
||||
|
||||
AllocationProperties unifiedMemoryProperties{true,
|
||||
@@ -132,6 +113,28 @@ void *SVMAllocsManager::createUnifiedMemoryAllocation(size_t size, const Unified
|
||||
return reinterpret_cast<void *>(unifiedMemoryAllocation->getGpuAddress());
|
||||
}
|
||||
|
||||
void *SVMAllocsManager::createSharedUnifiedMemoryAllocation(size_t size, const UnifiedMemoryProperties memoryProperties, void *cmdQ) {
|
||||
auto supportDualStorageSharedMemory = memoryManager->isLocalMemorySupported();
|
||||
|
||||
if (DebugManager.flags.AllocateSharedAllocationsWithCpuAndGpuStorage.get() != -1) {
|
||||
supportDualStorageSharedMemory = !!DebugManager.flags.AllocateSharedAllocationsWithCpuAndGpuStorage.get();
|
||||
}
|
||||
|
||||
if (supportDualStorageSharedMemory) {
|
||||
auto unifiedMemoryPointer = createUnifiedAllocationWithDeviceStorage(size, {});
|
||||
UNRECOVERABLE_IF(unifiedMemoryPointer == nullptr);
|
||||
auto unifiedMemoryAllocation = this->getSVMAlloc(unifiedMemoryPointer);
|
||||
unifiedMemoryAllocation->memoryType = memoryProperties.memoryType;
|
||||
|
||||
UNRECOVERABLE_IF(cmdQ == nullptr);
|
||||
auto pageFaultManager = this->memoryManager->getPageFaultManager();
|
||||
pageFaultManager->insertAllocation(unifiedMemoryPointer, size, this, cmdQ);
|
||||
|
||||
return unifiedMemoryPointer;
|
||||
}
|
||||
return createUnifiedMemoryAllocation(size, memoryProperties);
|
||||
}
|
||||
|
||||
SvmAllocationData *SVMAllocsManager::getSVMAlloc(const void *ptr) {
|
||||
std::unique_lock<SpinLock> lock(mtx);
|
||||
return SVMAllocs.get(ptr);
|
||||
|
||||
Reference in New Issue
Block a user