55 *
66 */
77
8+ #include " runtime/execution_environment/execution_environment.h"
89#include " runtime/memory_manager/os_agnostic_memory_manager.h"
910#include " runtime/gmm_helper/gmm.h"
1011#include " runtime/gmm_helper/gmm_helper.h"
@@ -35,14 +36,16 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemory(size_t size,
3536 MemoryAllocation *memoryAllocation = nullptr ;
3637
3738 if (fakeBigAllocations && size > bigAllocation) {
38- memoryAllocation = new MemoryAllocation (nullptr , (void *)dummyAddress, static_cast <uint64_t >(dummyAddress), size, counter, MemoryPool::System4KBPages);
39+ memoryAllocation = new MemoryAllocation (nullptr , (void *)dummyAddress, static_cast <uint64_t >(dummyAddress), size, counter,
40+ MemoryPool::System4KBPages, this ->getOsContextCount (), false );
3941 counter++;
4042 memoryAllocation->uncacheable = uncacheable;
4143 return memoryAllocation;
4244 }
4345 auto ptr = allocateSystemMemory (sizeAligned, alignment ? alignUp (alignment, MemoryConstants::pageSize) : MemoryConstants::pageSize);
4446 if (ptr != nullptr ) {
45- memoryAllocation = new MemoryAllocation (ptr, ptr, reinterpret_cast <uint64_t >(ptr), size, counter, MemoryPool::System4KBPages);
47+ memoryAllocation = new MemoryAllocation (ptr, ptr, reinterpret_cast <uint64_t >(ptr), size, counter, MemoryPool::System4KBPages,
48+ this ->getOsContextCount (), false );
4649 if (!memoryAllocation) {
4750 alignedFreeWrapper (ptr);
4851 return nullptr ;
@@ -58,7 +61,8 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryForNonSvmHost
5861 auto alignedPtr = alignDown (reinterpret_cast <char *>(cpuPtr), MemoryConstants::pageSize);
5962 auto offsetInPage = reinterpret_cast <char *>(cpuPtr) - alignedPtr;
6063
61- memoryAllocation = new MemoryAllocation (nullptr , cpuPtr, reinterpret_cast <uint64_t >(alignedPtr), size, counter, MemoryPool::System4KBPages);
64+ memoryAllocation = new MemoryAllocation (nullptr , cpuPtr, reinterpret_cast <uint64_t >(alignedPtr), size, counter, MemoryPool::System4KBPages,
65+ this ->getOsContextCount (), false );
6266
6367 memoryAllocation->allocationOffset = offsetInPage;
6468 memoryAllocation->uncacheable = false ;
@@ -83,7 +87,8 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemory(size_t
8387 return nullptr ;
8488 }
8589 uint64_t offset = static_cast <uint64_t >(reinterpret_cast <uintptr_t >(ptr) & MemoryConstants::pageMask);
86- MemoryAllocation *memAlloc = new MemoryAllocation (nullptr , const_cast <void *>(ptr), GmmHelper::canonize (gpuVirtualAddress + offset), size, counter, MemoryPool::System4KBPagesWith32BitGpuAddressing);
90+ MemoryAllocation *memAlloc = new MemoryAllocation (nullptr , const_cast <void *>(ptr), GmmHelper::canonize (gpuVirtualAddress + offset), size,
91+ counter, MemoryPool::System4KBPagesWith32BitGpuAddressing, this ->getOsContextCount (), false );
8792 memAlloc->is32BitAllocation = true ;
8893 memAlloc->gpuBaseAddress = GmmHelper::canonize (allocator32Bit->getBase ());
8994 memAlloc->sizeToFree = allocationSize;
@@ -109,7 +114,8 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemory(size_t
109114
110115 MemoryAllocation *memoryAllocation = nullptr ;
111116 if (ptrAlloc != nullptr ) {
112- memoryAllocation = new MemoryAllocation (freeCpuPointer ? ptrAlloc : nullptr , ptrAlloc, GmmHelper::canonize (gpuAddress), size, counter, MemoryPool::System4KBPagesWith32BitGpuAddressing);
117+ memoryAllocation = new MemoryAllocation (freeCpuPointer ? ptrAlloc : nullptr , ptrAlloc, GmmHelper::canonize (gpuAddress), size, counter,
118+ MemoryPool::System4KBPagesWith32BitGpuAddressing, this ->getOsContextCount (), false );
113119 memoryAllocation->is32BitAllocation = true ;
114120 memoryAllocation->gpuBaseAddress = GmmHelper::canonize (allocator32Bit->getBase ());
115121 memoryAllocation->sizeToFree = allocationSize;
@@ -119,7 +125,8 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemory(size_t
119125}
120126
121127GraphicsAllocation *OsAgnosticMemoryManager::createGraphicsAllocationFromSharedHandle (osHandle handle, bool requireSpecificBitness) {
122- auto graphicsAllocation = new MemoryAllocation (nullptr , reinterpret_cast <void *>(1 ), 1 , 4096u , static_cast <uint64_t >(handle), MemoryPool::SystemCpuInaccessible);
128+ auto graphicsAllocation = new MemoryAllocation (nullptr , reinterpret_cast <void *>(1 ), 1 , 4096u , static_cast <uint64_t >(handle),
129+ MemoryPool::SystemCpuInaccessible, this ->getOsContextCount (), false );
123130 graphicsAllocation->setSharedHandle (handle);
124131 graphicsAllocation->is32BitAllocation = requireSpecificBitness;
125132 return graphicsAllocation;
@@ -187,7 +194,8 @@ uint64_t OsAgnosticMemoryManager::getInternalHeapBaseAddress() {
187194}
188195
189196GraphicsAllocation *OsAgnosticMemoryManager::createGraphicsAllocation (OsHandleStorage &handleStorage, size_t hostPtrSize, const void *hostPtr) {
190- auto allocation = new MemoryAllocation (nullptr , const_cast <void *>(hostPtr), reinterpret_cast <uint64_t >(hostPtr), hostPtrSize, counter++, MemoryPool::System4KBPages);
197+ auto allocation = new MemoryAllocation (nullptr , const_cast <void *>(hostPtr), reinterpret_cast <uint64_t >(hostPtr),
198+ hostPtrSize, counter++, MemoryPool::System4KBPages, this ->getOsContextCount (), false );
191199 allocation->fragmentsStorage = handleStorage;
192200 return allocation;
193201}
@@ -227,7 +235,8 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryForImage(Imag
227235 } else {
228236 auto ptr = allocateSystemMemory (alignUp (imgInfo.size , MemoryConstants::pageSize), MemoryConstants::pageSize);
229237 if (ptr != nullptr ) {
230- alloc = new MemoryAllocation (ptr, ptr, reinterpret_cast <uint64_t >(ptr), imgInfo.size , counter, MemoryPool::SystemCpuInaccessible);
238+ alloc = new MemoryAllocation (ptr, ptr, reinterpret_cast <uint64_t >(ptr), imgInfo.size , counter,
239+ MemoryPool::SystemCpuInaccessible, this ->getOsContextCount (), false );
231240 counter++;
232241 }
233242 }
0 commit comments