@@ -70,26 +70,32 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryWithAlignment
70
70
return memoryAllocation;
71
71
}
72
72
73
+ auto alignment = allocationData.alignment ;
74
+ if (allocationData.type == GraphicsAllocation::AllocationType::SVM_CPU) {
75
+ alignment = MemoryConstants::pageSize2Mb;
76
+ sizeAligned = alignUp (allocationData.size , MemoryConstants::pageSize2Mb);
77
+ }
78
+
73
79
if (allocationData.type == GraphicsAllocation::AllocationType::DEBUG_CONTEXT_SAVE_AREA) {
74
80
sizeAligned *= allocationData.storageInfo .getNumBanks ();
75
81
}
76
82
77
- auto ptr = allocateSystemMemory (sizeAligned, allocationData. alignment ? alignUp (allocationData. alignment , MemoryConstants::pageSize) : MemoryConstants::pageSize);
83
+ auto ptr = allocateSystemMemory (sizeAligned, alignment ? alignUp (alignment, MemoryConstants::pageSize) : MemoryConstants::pageSize);
78
84
if (ptr != nullptr ) {
79
85
memoryAllocation = createMemoryAllocation (allocationData.type , ptr, ptr, reinterpret_cast <uint64_t >(ptr), allocationData.size ,
80
86
counter, MemoryPool::System4KBPages, allocationData.rootDeviceIndex , allocationData.flags .uncacheable , allocationData.flags .flushL3 , false );
81
87
82
88
if (allocationData.type == GraphicsAllocation::AllocationType::SVM_CPU) {
83
- // add 2MB padding in case mapPtr is not 2MB aligned
84
- size_t reserveSize = sizeAligned + allocationData. alignment ;
89
+ // add padding in case mapPtr is not aligned
90
+ size_t reserveSize = sizeAligned + alignment;
85
91
void *gpuPtr = reserveCpuAddressRange (reserveSize, allocationData.rootDeviceIndex );
86
92
if (!gpuPtr) {
87
93
delete memoryAllocation;
88
94
alignedFreeWrapper (ptr);
89
95
return nullptr ;
90
96
}
91
97
memoryAllocation->setReservedAddressRange (gpuPtr, reserveSize);
92
- gpuPtr = alignUp (gpuPtr, allocationData. alignment );
98
+ gpuPtr = alignUp (gpuPtr, alignment);
93
99
memoryAllocation->setCpuPtrAndGpuAddress (ptr, reinterpret_cast <uint64_t >(gpuPtr));
94
100
}
95
101
@@ -436,7 +442,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryInDevicePool(
436
442
adjustedAllocationData.alignment = MemoryConstants::pageSize64k;
437
443
allocation = static_cast <MemoryAllocation *>(allocate32BitGraphicsMemoryImpl (adjustedAllocationData, true ));
438
444
} else if (allocationData.type == GraphicsAllocation::AllocationType::SVM_GPU) {
439
- auto storage = allocateSystemMemory (allocationData.size , allocationData. alignment );
445
+ auto storage = allocateSystemMemory (allocationData.size , MemoryConstants::pageSize2Mb );
440
446
allocation = new MemoryAllocation (allocationData.rootDeviceIndex , numHandles, allocationData.type , storage, storage, reinterpret_cast <uint64_t >(allocationData.hostPtr ),
441
447
allocationData.size , counter, MemoryPool::LocalMemory, false , allocationData.flags .flushL3 , maxOsContextCount);
442
448
counter++;
0 commit comments