@@ -70,26 +70,32 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryWithAlignment
7070 return memoryAllocation;
7171 }
7272
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+
7379 if (allocationData.type == GraphicsAllocation::AllocationType::DEBUG_CONTEXT_SAVE_AREA) {
7480 sizeAligned *= allocationData.storageInfo .getNumBanks ();
7581 }
7682
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);
7884 if (ptr != nullptr ) {
7985 memoryAllocation = createMemoryAllocation (allocationData.type , ptr, ptr, reinterpret_cast <uint64_t >(ptr), allocationData.size ,
8086 counter, MemoryPool::System4KBPages, allocationData.rootDeviceIndex , allocationData.flags .uncacheable , allocationData.flags .flushL3 , false );
8187
8288 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;
8591 void *gpuPtr = reserveCpuAddressRange (reserveSize, allocationData.rootDeviceIndex );
8692 if (!gpuPtr) {
8793 delete memoryAllocation;
8894 alignedFreeWrapper (ptr);
8995 return nullptr ;
9096 }
9197 memoryAllocation->setReservedAddressRange (gpuPtr, reserveSize);
92- gpuPtr = alignUp (gpuPtr, allocationData. alignment );
98+ gpuPtr = alignUp (gpuPtr, alignment);
9399 memoryAllocation->setCpuPtrAndGpuAddress (ptr, reinterpret_cast <uint64_t >(gpuPtr));
94100 }
95101
@@ -436,7 +442,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryInDevicePool(
436442 adjustedAllocationData.alignment = MemoryConstants::pageSize64k;
437443 allocation = static_cast <MemoryAllocation *>(allocate32BitGraphicsMemoryImpl (adjustedAllocationData, true ));
438444 } else if (allocationData.type == GraphicsAllocation::AllocationType::SVM_GPU) {
439- auto storage = allocateSystemMemory (allocationData.size , allocationData. alignment );
445+ auto storage = allocateSystemMemory (allocationData.size , MemoryConstants::pageSize2Mb );
440446 allocation = new MemoryAllocation (allocationData.rootDeviceIndex , numHandles, allocationData.type , storage, storage, reinterpret_cast <uint64_t >(allocationData.hostPtr ),
441447 allocationData.size , counter, MemoryPool::LocalMemory, false , allocationData.flags .flushL3 , maxOsContextCount);
442448 counter++;
0 commit comments