diff --git a/core/memory_manager/graphics_allocation.cpp b/core/memory_manager/graphics_allocation.cpp index cc771575d5..740f3455c6 100644 --- a/core/memory_manager/graphics_allocation.cpp +++ b/core/memory_manager/graphics_allocation.cpp @@ -17,25 +17,25 @@ void GraphicsAllocation::setAllocationType(AllocationType allocationType) { DebugManager.logAllocation(this); } -GraphicsAllocation::GraphicsAllocation(AllocationType allocationType, void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, - size_t sizeIn, MemoryPool::Type pool, uint32_t rootDeviceIndex) - : gpuBaseAddress(baseAddress), +GraphicsAllocation::GraphicsAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, + size_t sizeIn, MemoryPool::Type pool) + : rootDeviceIndex(rootDeviceIndex), + gpuBaseAddress(baseAddress), gpuAddress(gpuAddress), size(sizeIn), cpuPtr(cpuPtrIn), memoryPool(pool), - allocationType(allocationType), - rootDeviceIndex(rootDeviceIndex) { + allocationType(allocationType) { } -GraphicsAllocation::GraphicsAllocation(AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, - MemoryPool::Type pool, uint32_t rootDeviceIndex) - : gpuAddress(castToUint64(cpuPtrIn)), +GraphicsAllocation::GraphicsAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, + MemoryPool::Type pool) + : rootDeviceIndex(rootDeviceIndex), + gpuAddress(castToUint64(cpuPtrIn)), size(sizeIn), cpuPtr(cpuPtrIn), memoryPool(pool), - allocationType(allocationType), - rootDeviceIndex(rootDeviceIndex) { + allocationType(allocationType) { sharingInfo.sharedHandle = sharedHandleIn; } diff --git a/core/memory_manager/graphics_allocation.h b/core/memory_manager/graphics_allocation.h index 0b4404ed3e..00952b2537 100644 --- a/core/memory_manager/graphics_allocation.h +++ b/core/memory_manager/graphics_allocation.h @@ -80,9 +80,9 @@ class GraphicsAllocation : public IDNode { GraphicsAllocation &operator=(const GraphicsAllocation &) = delete; GraphicsAllocation(const GraphicsAllocation &) = delete; - GraphicsAllocation(AllocationType allocationType, void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn, MemoryPool::Type pool, uint32_t rootDeviceIndex); + GraphicsAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn, MemoryPool::Type pool); - GraphicsAllocation(AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, MemoryPool::Type pool, uint32_t rootDeviceIndex); + GraphicsAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, MemoryPool::Type pool); uint32_t getRootDeviceIndex() { return rootDeviceIndex; } void *getUnderlyingBuffer() const { return cpuPtr; } @@ -265,6 +265,7 @@ class GraphicsAllocation : public IDNode { friend class SubmissionAggregator; + const uint32_t rootDeviceIndex; AllocationInfo allocationInfo; AubInfo aubInfo; SharingInfo sharingInfo; @@ -281,7 +282,6 @@ class GraphicsAllocation : public IDNode { MemoryPool::Type memoryPool = MemoryPool::MemoryNull; AllocationType allocationType = AllocationType::UNKNOWN; - uint32_t rootDeviceIndex = 0; std::array usageInfos; std::atomic registeredContextsNum{0}; diff --git a/runtime/command_stream/aub_command_stream_receiver_hw_base.inl b/runtime/command_stream/aub_command_stream_receiver_hw_base.inl index af79090720..e69abe42ec 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw_base.inl +++ b/runtime/command_stream/aub_command_stream_receiver_hw_base.inl @@ -659,7 +659,7 @@ bool AUBCommandStreamReceiverHw::writeMemory(GraphicsAllocation &gfxA template bool AUBCommandStreamReceiverHw::writeMemory(AllocationView &allocationView) { - GraphicsAllocation gfxAllocation(GraphicsAllocation::AllocationType::UNKNOWN, reinterpret_cast(allocationView.first), allocationView.first, 0llu, allocationView.second, MemoryPool::MemoryNull, this->rootDeviceIndex); + GraphicsAllocation gfxAllocation(this->rootDeviceIndex, GraphicsAllocation::AllocationType::UNKNOWN, reinterpret_cast(allocationView.first), allocationView.first, 0llu, allocationView.second, MemoryPool::MemoryNull); return writeMemory(gfxAllocation); } diff --git a/runtime/memory_manager/os_agnostic_memory_manager.cpp b/runtime/memory_manager/os_agnostic_memory_manager.cpp index 3bccb43b32..9ab2c562f4 100644 --- a/runtime/memory_manager/os_agnostic_memory_manager.cpp +++ b/runtime/memory_manager/os_agnostic_memory_manager.cpp @@ -113,8 +113,8 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(con } uint64_t offset = static_cast(reinterpret_cast(allocationData.hostPtr) & MemoryConstants::pageMask); MemoryAllocation *memAlloc = new MemoryAllocation( - allocationData.type, nullptr, const_cast(allocationData.hostPtr), GmmHelper::canonize(gpuVirtualAddress + offset), - allocationData.size, counter, MemoryPool::System4KBPagesWith32BitGpuAddressing, allocationData.rootDeviceIndex, false, false); + allocationData.rootDeviceIndex, allocationData.type, nullptr, const_cast(allocationData.hostPtr), + GmmHelper::canonize(gpuVirtualAddress + offset), allocationData.size, counter, MemoryPool::System4KBPagesWith32BitGpuAddressing, false, false); memAlloc->set32BitAllocation(true); memAlloc->setGpuBaseAddress(GmmHelper::canonize(gfxPartition->getHeapBase(heap))); @@ -138,9 +138,9 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocate32BitGraphicsMemoryImpl(con MemoryAllocation *memoryAllocation = nullptr; if (ptrAlloc != nullptr) { - memoryAllocation = new MemoryAllocation(allocationData.type, ptrAlloc, ptrAlloc, GmmHelper::canonize(gpuAddress), + memoryAllocation = new MemoryAllocation(allocationData.rootDeviceIndex, allocationData.type, ptrAlloc, ptrAlloc, GmmHelper::canonize(gpuAddress), allocationData.size, counter, MemoryPool::System4KBPagesWith32BitGpuAddressing, - allocationData.rootDeviceIndex, false, allocationData.flags.flushL3); + false, allocationData.flags.flushL3); memoryAllocation->set32BitAllocation(true); memoryAllocation->setGpuBaseAddress(GmmHelper::canonize(gfxPartition->getHeapBase(heap))); @@ -312,8 +312,8 @@ MemoryAllocation *OsAgnosticMemoryManager::createMemoryAllocation(GraphicsAlloca MemoryPool::Type pool, uint32_t rootDeviceIndex, bool uncacheable, bool flushL3Required, bool requireSpecificBitness) { if (!isLimitedRange(rootDeviceIndex)) { - return new MemoryAllocation(allocationType, driverAllocatedCpuPointer, pMem, gpuAddress, memSize, - count, pool, rootDeviceIndex, uncacheable, flushL3Required); + return new MemoryAllocation(rootDeviceIndex, allocationType, driverAllocatedCpuPointer, pMem, gpuAddress, memSize, + count, pool, uncacheable, flushL3Required); } size_t alignedSize = alignSizeWholePage(pMem, memSize); @@ -323,8 +323,8 @@ MemoryAllocation *OsAgnosticMemoryManager::createMemoryAllocation(GraphicsAlloca auto gfxPartition = getGfxPartition(rootDeviceIndex); uint64_t limitedGpuAddress = gfxPartition->heapAllocate(heap, alignedSize); - auto memoryAllocation = new MemoryAllocation(allocationType, driverAllocatedCpuPointer, pMem, limitedGpuAddress, memSize, - count, pool, rootDeviceIndex, uncacheable, flushL3Required); + auto memoryAllocation = new MemoryAllocation(rootDeviceIndex, allocationType, driverAllocatedCpuPointer, pMem, limitedGpuAddress, memSize, + count, pool, uncacheable, flushL3Required); if (heap == HeapIndex::HEAP_EXTERNAL) { memoryAllocation->setGpuBaseAddress(GmmHelper::canonize(gfxPartition->getHeapBase(heap))); diff --git a/runtime/memory_manager/os_agnostic_memory_manager.h b/runtime/memory_manager/os_agnostic_memory_manager.h index a885d05fd0..970532db05 100644 --- a/runtime/memory_manager/os_agnostic_memory_manager.h +++ b/runtime/memory_manager/os_agnostic_memory_manager.h @@ -20,18 +20,18 @@ class MemoryAllocation : public GraphicsAllocation { void setSharedHandle(osHandle handle) { sharingInfo.sharedHandle = handle; } - MemoryAllocation(AllocationType allocationType, void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn, - MemoryPool::Type pool, uint32_t rootDeviceIndex) - : GraphicsAllocation(allocationType, cpuPtrIn, gpuAddress, baseAddress, sizeIn, pool, rootDeviceIndex), + MemoryAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, uint64_t gpuAddress, uint64_t baseAddress, size_t sizeIn, + MemoryPool::Type pool) + : GraphicsAllocation(rootDeviceIndex, allocationType, cpuPtrIn, gpuAddress, baseAddress, sizeIn, pool), id(0), uncacheable(false) {} - MemoryAllocation(AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, MemoryPool::Type pool, uint32_t rootDeviceIndex) - : GraphicsAllocation(allocationType, cpuPtrIn, sizeIn, sharedHandleIn, pool, rootDeviceIndex), + MemoryAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, MemoryPool::Type pool) + : GraphicsAllocation(rootDeviceIndex, allocationType, cpuPtrIn, sizeIn, sharedHandleIn, pool), id(0), uncacheable(false) {} - MemoryAllocation(AllocationType allocationType, void *driverAllocatedCpuPointer, void *pMem, uint64_t gpuAddress, size_t memSize, - uint64_t count, MemoryPool::Type pool, uint32_t rootDeviceIndex, bool uncacheable, bool flushL3Required) - : GraphicsAllocation(allocationType, pMem, gpuAddress, 0u, memSize, pool, rootDeviceIndex), + MemoryAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *driverAllocatedCpuPointer, void *pMem, uint64_t gpuAddress, size_t memSize, + uint64_t count, MemoryPool::Type pool, bool uncacheable, bool flushL3Required) + : GraphicsAllocation(rootDeviceIndex, allocationType, pMem, gpuAddress, 0u, memSize, pool), id(count), uncacheable(uncacheable) { this->driverAllocatedCpuPointer = driverAllocatedCpuPointer; diff --git a/runtime/memory_manager/os_agnostic_memory_manager_allocate_in_device_pool.cpp b/runtime/memory_manager/os_agnostic_memory_manager_allocate_in_device_pool.cpp index 2c508670e5..0826be9d69 100644 --- a/runtime/memory_manager/os_agnostic_memory_manager_allocate_in_device_pool.cpp +++ b/runtime/memory_manager/os_agnostic_memory_manager_allocate_in_device_pool.cpp @@ -23,7 +23,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::allocateGraphicsMemoryInDevicePool( return nullptr; } uint64_t gpuAddress = reinterpret_cast(allocationData.hostPtr); - allocation = new MemoryAllocation(allocationData.type, cpuAllocation, cpuAllocation, gpuAddress, allocationData.size, counter++, MemoryPool::LocalMemory, allocationData.rootDeviceIndex, false, false); + allocation = new MemoryAllocation(allocationData.rootDeviceIndex, allocationData.type, cpuAllocation, cpuAllocation, gpuAddress, allocationData.size, counter++, MemoryPool::LocalMemory, false, false); } else { allocation = allocateGraphicsMemory(allocationData); } diff --git a/runtime/os_interface/linux/drm_allocation.h b/runtime/os_interface/linux/drm_allocation.h index 8cc34c2f62..efcaffc3a4 100644 --- a/runtime/os_interface/linux/drm_allocation.h +++ b/runtime/os_interface/linux/drm_allocation.h @@ -19,18 +19,18 @@ using BufferObjects = std::array; class DrmAllocation : public GraphicsAllocation { public: - DrmAllocation(AllocationType allocationType, BufferObject *bo, void *ptrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool, uint32_t rootDeviceIndex) - : GraphicsAllocation(allocationType, ptrIn, sizeIn, sharedHandle, pool, rootDeviceIndex), + DrmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObject *bo, void *ptrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool) + : GraphicsAllocation(rootDeviceIndex, allocationType, ptrIn, sizeIn, sharedHandle, pool), bufferObjects({{bo}}) { } - DrmAllocation(AllocationType allocationType, BufferObject *bo, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool::Type pool, uint32_t rootDeviceIndex) - : GraphicsAllocation(allocationType, ptrIn, gpuAddress, 0, sizeIn, pool, rootDeviceIndex), + DrmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObject *bo, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool::Type pool) + : GraphicsAllocation(rootDeviceIndex, allocationType, ptrIn, gpuAddress, 0, sizeIn, pool), bufferObjects({{bo}}) { } - DrmAllocation(AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool::Type pool, uint32_t rootDeviceIndex) - : GraphicsAllocation(allocationType, ptrIn, gpuAddress, 0, sizeIn, pool, rootDeviceIndex), + DrmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObjects &bos, void *ptrIn, uint64_t gpuAddress, size_t sizeIn, MemoryPool::Type pool) + : GraphicsAllocation(rootDeviceIndex, allocationType, ptrIn, gpuAddress, 0, sizeIn, pool), bufferObjects(bos) { } diff --git a/runtime/os_interface/linux/drm_memory_manager.cpp b/runtime/os_interface/linux/drm_memory_manager.cpp index 264445b568..bf5d518292 100644 --- a/runtime/os_interface/linux/drm_memory_manager.cpp +++ b/runtime/os_interface/linux/drm_memory_manager.cpp @@ -163,7 +163,7 @@ void DrmMemoryManager::emitPinningRequest(BufferObject *bo, const AllocationData DrmAllocation *DrmMemoryManager::createGraphicsAllocation(OsHandleStorage &handleStorage, const AllocationData &allocationData) { auto hostPtr = const_cast(allocationData.hostPtr); - auto allocation = new DrmAllocation(allocationData.type, nullptr, hostPtr, castToUint64(hostPtr), allocationData.size, MemoryPool::System4KBPages, allocationData.rootDeviceIndex); + auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, nullptr, hostPtr, castToUint64(hostPtr), allocationData.size, MemoryPool::System4KBPages); allocation->fragmentsStorage = handleStorage; return allocation; } @@ -214,7 +214,7 @@ DrmAllocation *DrmMemoryManager::allocateGraphicsMemoryWithAlignment(const Alloc emitPinningRequest(bo, allocationData); - auto allocation = new DrmAllocation(allocationData.type, bo, res, bo->gpuAddress, cSize, MemoryPool::System4KBPages, allocationData.rootDeviceIndex); + auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo, res, bo->gpuAddress, cSize, MemoryPool::System4KBPages); allocation->setDriverAllocatedCpuPtr(res); allocation->setReservedAddressRange(reinterpret_cast(gpuAddress), alignedSize); @@ -253,8 +253,8 @@ DrmAllocation *DrmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(const Al bo->gpuAddress = gpuVirtualAddress; - auto allocation = new DrmAllocation(allocationData.type, bo, const_cast(allocationData.hostPtr), gpuVirtualAddress, - allocationData.size, MemoryPool::System4KBPages, allocationData.rootDeviceIndex); + auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo, const_cast(allocationData.hostPtr), + gpuVirtualAddress, allocationData.size, MemoryPool::System4KBPages); allocation->setAllocationOffset(offsetInPage); allocation->setReservedAddressRange(reinterpret_cast(gpuVirtualAddress), alignedSize); @@ -295,7 +295,7 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryForImageImpl(const A DEBUG_BREAK_IF(ret2 != true); ((void)(ret2)); - auto allocation = new DrmAllocation(allocationData.type, bo, nullptr, gpuRange, allocationData.imgInfo->size, MemoryPool::SystemCpuInaccessible, allocationData.rootDeviceIndex); + auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo, nullptr, gpuRange, allocationData.imgInfo->size, MemoryPool::SystemCpuInaccessible); allocation->setDefaultGmm(gmm.release()); allocation->setReservedAddressRange(reinterpret_cast(gpuRange), allocationData.imgInfo->size); @@ -326,8 +326,8 @@ DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemoryImpl(const Allocatio } bo->gpuAddress = GmmHelper::canonize(gpuVirtualAddress); - auto allocation = new DrmAllocation(allocationData.type, bo, const_cast(allocationData.hostPtr), GmmHelper::canonize(ptrOffset(gpuVirtualAddress, inputPointerOffset)), - allocationSize, MemoryPool::System4KBPagesWith32BitGpuAddressing, allocationData.rootDeviceIndex); + auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo, const_cast(allocationData.hostPtr), GmmHelper::canonize(ptrOffset(gpuVirtualAddress, inputPointerOffset)), + allocationSize, MemoryPool::System4KBPagesWith32BitGpuAddressing); allocation->set32BitAllocation(true); allocation->setGpuBaseAddress(GmmHelper::canonize(gfxPartition->getHeapBase(allocatorToUse))); allocation->setReservedAddressRange(reinterpret_cast(gpuVirtualAddress), realAllocationSize); @@ -361,8 +361,8 @@ DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemoryImpl(const Allocatio bo->gpuAddress = GmmHelper::canonize(res); // softpin to the GPU address, res if it uses limitedRange Allocation - auto allocation = new DrmAllocation(allocationData.type, bo, ptrAlloc, GmmHelper::canonize(res), alignedAllocationSize, - MemoryPool::System4KBPagesWith32BitGpuAddressing, allocationData.rootDeviceIndex); + auto allocation = new DrmAllocation(allocationData.rootDeviceIndex, allocationData.type, bo, ptrAlloc, GmmHelper::canonize(res), alignedAllocationSize, + MemoryPool::System4KBPagesWith32BitGpuAddressing); allocation->set32BitAllocation(true); allocation->setGpuBaseAddress(GmmHelper::canonize(gfxPartition->getHeapBase(allocatorToUse))); @@ -434,8 +434,8 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o lock.unlock(); - auto drmAllocation = new DrmAllocation(properties.allocationType, bo, reinterpret_cast(bo->gpuAddress), bo->size, - handle, MemoryPool::SystemCpuInaccessible, rootDeviceIndex); + auto drmAllocation = new DrmAllocation(rootDeviceIndex, properties.allocationType, bo, reinterpret_cast(bo->gpuAddress), bo->size, + handle, MemoryPool::SystemCpuInaccessible); if (requireSpecificBitness && this->force32bitAllocations) { drmAllocation->set32BitAllocation(true); @@ -477,8 +477,8 @@ GraphicsAllocation *DrmMemoryManager::createPaddedAllocation(GraphicsAllocation return nullptr; } bo->gpuAddress = gpuRange; - auto allocation = new DrmAllocation(inputGraphicsAllocation->getAllocationType(), bo, srcPtr, GmmHelper::canonize(ptrOffset(gpuRange, offset)), sizeWithPadding, - inputGraphicsAllocation->getMemoryPool(), rootDeviceIndex); + auto allocation = new DrmAllocation(rootDeviceIndex, inputGraphicsAllocation->getAllocationType(), bo, srcPtr, GmmHelper::canonize(ptrOffset(gpuRange, offset)), sizeWithPadding, + inputGraphicsAllocation->getMemoryPool()); allocation->setReservedAddressRange(reinterpret_cast(gpuRange), sizeWithPadding); return allocation; diff --git a/runtime/os_interface/windows/wddm_allocation.h b/runtime/os_interface/windows/wddm_allocation.h index 8c39e3be10..7e639cc49f 100644 --- a/runtime/os_interface/windows/wddm_allocation.h +++ b/runtime/os_interface/windows/wddm_allocation.h @@ -25,15 +25,15 @@ constexpr size_t trimListUnusedPosition = std::numeric_limits::max(); class WddmAllocation : public GraphicsAllocation { public: - WddmAllocation(AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, void *reservedAddr, MemoryPool::Type pool, uint32_t rootDeviceIndex) - : GraphicsAllocation(allocationType, cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn, pool, rootDeviceIndex) { + WddmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, void *reservedAddr, MemoryPool::Type pool) + : GraphicsAllocation(rootDeviceIndex, allocationType, cpuPtrIn, castToUint64(cpuPtrIn), 0llu, sizeIn, pool) { trimCandidateListPositions.fill(trimListUnusedPosition); reservedAddressRangeInfo.addressPtr = reservedAddr; reservedAddressRangeInfo.rangeSize = sizeIn; } - WddmAllocation(AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool, uint32_t rootDeviceIndex) - : GraphicsAllocation(allocationType, cpuPtrIn, sizeIn, sharedHandle, pool, rootDeviceIndex) { + WddmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool::Type pool) + : GraphicsAllocation(rootDeviceIndex, allocationType, cpuPtrIn, sizeIn, sharedHandle, pool) { trimCandidateListPositions.fill(trimListUnusedPosition); } diff --git a/runtime/os_interface/windows/wddm_memory_manager.cpp b/runtime/os_interface/windows/wddm_memory_manager.cpp index c0d9a97cd8..d6d3087c5e 100644 --- a/runtime/os_interface/windows/wddm_memory_manager.cpp +++ b/runtime/os_interface/windows/wddm_memory_manager.cpp @@ -57,7 +57,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForImageImpl(const return allocateGraphicsMemoryWithAlignment(allocationData); } - auto allocation = std::make_unique(allocationData.type, nullptr, allocationData.imgInfo->size, nullptr, MemoryPool::SystemCpuInaccessible, allocationData.rootDeviceIndex); + auto allocation = std::make_unique(allocationData.rootDeviceIndex, allocationData.type, nullptr, allocationData.imgInfo->size, nullptr, MemoryPool::SystemCpuInaccessible); allocation->setDefaultGmm(gmm.get()); if (!createWddmAllocation(allocation.get(), nullptr)) { return nullptr; @@ -71,7 +71,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForImageImpl(const GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(const AllocationData &allocationData) { size_t sizeAligned = alignUp(allocationData.size, MemoryConstants::pageSize64k); - auto wddmAllocation = std::make_unique(allocationData.type, nullptr, sizeAligned, nullptr, MemoryPool::System64KBPages, allocationData.rootDeviceIndex); + auto wddmAllocation = std::make_unique(allocationData.rootDeviceIndex, allocationData.type, nullptr, sizeAligned, nullptr, MemoryPool::System64KBPages); auto gmm = new Gmm(nullptr, sizeAligned, false, allocationData.flags.preferRenderCompressed, true, {}); wddmAllocation->setDefaultGmm(gmm); @@ -101,7 +101,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithAlignment(const return nullptr; } - auto wddmAllocation = std::make_unique(allocationData.type, pSysMem, sizeAligned, nullptr, MemoryPool::System4KBPages, allocationData.rootDeviceIndex); + auto wddmAllocation = std::make_unique(allocationData.rootDeviceIndex, allocationData.type, pSysMem, sizeAligned, nullptr, MemoryPool::System4KBPages); wddmAllocation->setDriverAllocatedCpuPtr(pSysMem); gmm = new Gmm(pSysMem, sizeAligned, allocationData.flags.uncacheable); @@ -135,8 +135,8 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(co auto offsetInPage = ptrDiff(allocationData.hostPtr, alignedPtr); auto alignedSize = alignSizeWholePage(allocationData.hostPtr, allocationData.size); - auto wddmAllocation = std::make_unique(allocationData.type, const_cast(allocationData.hostPtr), - allocationData.size, nullptr, MemoryPool::System4KBPages, allocationData.rootDeviceIndex); + auto wddmAllocation = std::make_unique(allocationData.rootDeviceIndex, allocationData.type, const_cast(allocationData.hostPtr), + allocationData.size, nullptr, MemoryPool::System4KBPages); wddmAllocation->setAllocationOffset(offsetInPage); auto gmm = new Gmm(alignedPtr, alignedSize, false); @@ -163,7 +163,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithHostPtr(const A return nullptr; } - auto allocation = new WddmAllocation(allocationData.type, const_cast(inputPtr), allocationData.size, reserve, MemoryPool::System4KBPages, allocationData.rootDeviceIndex); + auto allocation = new WddmAllocation(allocationData.rootDeviceIndex, allocationData.type, const_cast(inputPtr), allocationData.size, reserve, MemoryPool::System4KBPages); allocation->setAllocationOffset(offset); Gmm *gmm = new Gmm(ptrAligned, sizeAligned, false); @@ -197,8 +197,8 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All ptrAligned = pSysMem; } - auto wddmAllocation = std::make_unique(allocationData.type, const_cast(ptrAligned), sizeAligned, nullptr, - MemoryPool::System4KBPagesWith32BitGpuAddressing, allocationData.rootDeviceIndex); + auto wddmAllocation = std::make_unique(allocationData.rootDeviceIndex, allocationData.type, const_cast(ptrAligned), sizeAligned, nullptr, + MemoryPool::System4KBPagesWith32BitGpuAddressing); wddmAllocation->setDriverAllocatedCpuPtr(pSysMem); wddmAllocation->set32BitAllocation(true); wddmAllocation->setAllocationOffset(offset); @@ -219,7 +219,7 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All } GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handle, bool requireSpecificBitness, bool ntHandle, GraphicsAllocation::AllocationType allocationType, uint32_t rootDeviceIndex) { - auto allocation = std::make_unique(allocationType, nullptr, 0, handle, MemoryPool::SystemCpuInaccessible, rootDeviceIndex); + auto allocation = std::make_unique(rootDeviceIndex, allocationType, nullptr, 0, handle, MemoryPool::SystemCpuInaccessible); bool status = ntHandle ? wddm->openNTHandle(reinterpret_cast(static_cast(handle)), allocation.get()) : wddm->openSharedHandle(handle, allocation.get()); @@ -473,7 +473,7 @@ void WddmMemoryManager::obtainGpuAddressFromFragments(WddmAllocation *allocation } GraphicsAllocation *WddmMemoryManager::createGraphicsAllocation(OsHandleStorage &handleStorage, const AllocationData &allocationData) { - auto allocation = new WddmAllocation(allocationData.type, const_cast(allocationData.hostPtr), allocationData.size, nullptr, MemoryPool::System4KBPages, allocationData.rootDeviceIndex); + auto allocation = new WddmAllocation(allocationData.rootDeviceIndex, allocationData.type, const_cast(allocationData.hostPtr), allocationData.size, nullptr, MemoryPool::System4KBPages); allocation->fragmentsStorage = handleStorage; obtainGpuAddressFromFragments(allocation, handleStorage); return allocation; diff --git a/unit_tests/aub_tests/command_queue/enqueue_read_buffer_aub_tests.cpp b/unit_tests/aub_tests/command_queue/enqueue_read_buffer_aub_tests.cpp index 40e99f6121..07e67a59c8 100644 --- a/unit_tests/aub_tests/command_queue/enqueue_read_buffer_aub_tests.cpp +++ b/unit_tests/aub_tests/command_queue/enqueue_read_buffer_aub_tests.cpp @@ -116,12 +116,12 @@ HWTEST_F(AUBReadBuffer, reserveCanonicalGpuAddress) { cl_float srcMemory[] = {1.0f, 2.0f, 3.0f, 4.0f}; cl_float dstMemory[] = {0.0f, 0.0f, 0.0f, 0.0f}; - GraphicsAllocation *srcAlocation = new MockGraphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN, + GraphicsAllocation *srcAlocation = new MockGraphicsAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, srcMemory, 0xFFFF800400001000, 0xFFFF800400001000, sizeof(srcMemory), - MemoryPool::MemoryNull, 0); + MemoryPool::MemoryNull); std::unique_ptr srcBuffer(Buffer::createBufferHw(&context, MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_USE_HOST_PTR, 0), diff --git a/unit_tests/command_queue/enqueue_read_buffer_tests.cpp b/unit_tests/command_queue/enqueue_read_buffer_tests.cpp index 75947ed5ba..54e695b8a9 100644 --- a/unit_tests/command_queue/enqueue_read_buffer_tests.cpp +++ b/unit_tests/command_queue/enqueue_read_buffer_tests.cpp @@ -503,7 +503,7 @@ HWTEST_F(EnqueueReadBufferTypeTest, givenCommandQueueWhenEnqueueReadBufferIsCall HWTEST_F(EnqueueReadBufferTypeTest, givenCommandQueueWhenEnqueueReadBufferWithMapAllocationIsCalledThenItDoesntCallNotifyFunction) { auto mockCmdQ = std::make_unique>(context, pDevice, nullptr); void *ptr = nonZeroCopyBuffer->getCpuAddressForMemoryTransfer(); - GraphicsAllocation mapAllocation{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; + GraphicsAllocation mapAllocation{0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; auto retVal = mockCmdQ->enqueueReadBuffer(srcBuffer.get(), CL_TRUE, 0, diff --git a/unit_tests/command_queue/enqueue_read_image_tests.cpp b/unit_tests/command_queue/enqueue_read_image_tests.cpp index 2ef10c01a4..128822fef2 100644 --- a/unit_tests/command_queue/enqueue_read_image_tests.cpp +++ b/unit_tests/command_queue/enqueue_read_image_tests.cpp @@ -447,7 +447,7 @@ HWTEST_F(EnqueueReadImageTest, givenCommandQueueWhenEnqueueReadImageWithMapAlloc size_t region[] = {imageDesc.image_width, imageDesc.image_height, imageDesc.image_array_size}; size_t rowPitch = srcImage->getHostPtrRowPitch(); size_t slicePitch = srcImage->getHostPtrSlicePitch(); - GraphicsAllocation mapAllocation{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; + GraphicsAllocation mapAllocation{0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; EnqueueReadImageHelper<>::enqueueReadImage(mockCmdQ.get(), srcImage.get(), CL_TRUE, origin, region, rowPitch, slicePitch, dstPtr, &mapAllocation); diff --git a/unit_tests/command_stream/aub_file_stream_tests.cpp b/unit_tests/command_stream/aub_file_stream_tests.cpp index 95eace3d57..5b5a243e97 100644 --- a/unit_tests/command_stream/aub_file_stream_tests.cpp +++ b/unit_tests/command_stream/aub_file_stream_tests.cpp @@ -258,7 +258,7 @@ HWTEST_F(AubFileStreamTests, givenAubCommandStreamReceiverWhenDumpAllocationIsCa auto mockAubFileStream = std::make_unique(); auto aubExecutionEnvironment = getEnvironment>(true, true, true); auto aubCsr = aubExecutionEnvironment->template getCsr>(); - GraphicsAllocation allocation{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; + GraphicsAllocation allocation{0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; aubCsr->stream = static_cast(mockAubFileStream.get()); diff --git a/unit_tests/command_stream/command_stream_receiver_tests.cpp b/unit_tests/command_stream/command_stream_receiver_tests.cpp index 270596feea..de78700f61 100644 --- a/unit_tests/command_stream/command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_tests.cpp @@ -297,7 +297,7 @@ TEST(CommandStreamReceiverSimpleTest, givenCommandStreamReceiverWhenItIsDestroye bool destructorCalled = false; - auto mockGraphicsAllocation = new MockGraphicsAllocationWithDestructorTracing(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0llu, 0llu, 1u, MemoryPool::MemoryNull); + auto mockGraphicsAllocation = new MockGraphicsAllocationWithDestructorTracing(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0llu, 0llu, 1u, MemoryPool::MemoryNull); mockGraphicsAllocation->destructorCalled = &destructorCalled; MockExecutionEnvironment executionEnvironment(*platformDevices); executionEnvironment.rootDeviceEnvironments[0].commandStreamReceivers.resize(1); diff --git a/unit_tests/fixtures/CMakeLists.txt b/unit_tests/fixtures/CMakeLists.txt index b13b1dd098..013808a16f 100644 --- a/unit_tests/fixtures/CMakeLists.txt +++ b/unit_tests/fixtures/CMakeLists.txt @@ -30,6 +30,7 @@ set(IGDRCL_SRCS_tests_fixtures ${CMAKE_CURRENT_SOURCE_DIR}/kernel_data_fixture.h ${CMAKE_CURRENT_SOURCE_DIR}/media_kernel_fixture.h ${CMAKE_CURRENT_SOURCE_DIR}/memory_allocator_fixture.h + ${CMAKE_CURRENT_SOURCE_DIR}/memory_allocator_multi_device_fixture.h ${CMAKE_CURRENT_SOURCE_DIR}/memory_manager_fixture.cpp ${CMAKE_CURRENT_SOURCE_DIR}/memory_manager_fixture.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_aub_center_fixture.h diff --git a/unit_tests/fixtures/memory_allocator_multi_device_fixture.h b/unit_tests/fixtures/memory_allocator_multi_device_fixture.h new file mode 100644 index 0000000000..bd8a3da5e3 --- /dev/null +++ b/unit_tests/fixtures/memory_allocator_multi_device_fixture.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#include "runtime/execution_environment/execution_environment.h" +#include "runtime/memory_manager/os_agnostic_memory_manager.h" +#include "unit_tests/fixtures/memory_management_fixture.h" +#include "unit_tests/mocks/mock_memory_manager.h" + +using namespace NEO; + +template +class MemoryAllocatorMultiDeviceFixture : public MemoryManagementFixture { + public: + void SetUp() override { + MemoryManagementFixture::SetUp(); + executionEnvironment = std::make_unique(); + executionEnvironment->setHwInfo(*platformDevices); + executionEnvironment->rootDeviceEnvironments.resize(numRootDevices); + memoryManager = new MockMemoryManager(false, false, *executionEnvironment); + executionEnvironment->memoryManager.reset(memoryManager); + } + + void TearDown() override { + executionEnvironment.reset(); + MemoryManagementFixture::TearDown(); + } + + uint32_t getNumRootDevices() { return numRootDevices; } + + protected: + std::unique_ptr executionEnvironment; + MockMemoryManager *memoryManager = nullptr; +}; diff --git a/unit_tests/helpers/hardware_commands_helper_tests.cpp b/unit_tests/helpers/hardware_commands_helper_tests.cpp index 6e19f92055..2c691df92a 100644 --- a/unit_tests/helpers/hardware_commands_helper_tests.cpp +++ b/unit_tests/helpers/hardware_commands_helper_tests.cpp @@ -694,12 +694,12 @@ HWCMDTEST_F(IGFX_GEN8_CORE, HardwareCommandsTest, usedBindingTableStatePointersF // setup global memory char globalBuffer[16]; - GraphicsAllocation gfxGlobalAlloc(GraphicsAllocation::AllocationType::UNKNOWN, globalBuffer, castToUint64(globalBuffer), 0llu, sizeof(globalBuffer), MemoryPool::MemoryNull, 0); + GraphicsAllocation gfxGlobalAlloc(0, GraphicsAllocation::AllocationType::UNKNOWN, globalBuffer, castToUint64(globalBuffer), 0llu, sizeof(globalBuffer), MemoryPool::MemoryNull); program.setGlobalSurface(&gfxGlobalAlloc); // setup constant memory char constBuffer[16]; - GraphicsAllocation gfxConstAlloc(GraphicsAllocation::AllocationType::UNKNOWN, constBuffer, castToUint64(constBuffer), 0llu, sizeof(constBuffer), MemoryPool::MemoryNull, 0); + GraphicsAllocation gfxConstAlloc(0, GraphicsAllocation::AllocationType::UNKNOWN, constBuffer, castToUint64(constBuffer), 0llu, sizeof(constBuffer), MemoryPool::MemoryNull); program.setConstantSurface(&gfxConstAlloc); // create kernel diff --git a/unit_tests/helpers/hw_helper_tests.cpp b/unit_tests/helpers/hw_helper_tests.cpp index d47ad5f707..b26b21f341 100644 --- a/unit_tests/helpers/hw_helper_tests.cpp +++ b/unit_tests/helpers/hw_helper_tests.cpp @@ -335,7 +335,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenAllocationProvidedThenU uint64_t gpuAddr = 0x4000u; size_t allocSize = size; length.Length = static_cast(allocSize - 1); - GraphicsAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, 0); + GraphicsAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull); allocation.setDefaultGmm(new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false)); SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; helper.setRenderSurfaceStateForBuffer(ee, stateBuffer, size, addr, 0, pitch, &allocation, 0, type, true); @@ -372,7 +372,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmAndAllocationCompres void *cpuAddr = reinterpret_cast(0x4000); uint64_t gpuAddr = 0x4000u; size_t allocSize = size; - GraphicsAllocation allocation(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, 0); + GraphicsAllocation allocation(0, GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull); allocation.setDefaultGmm(new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false)); allocation.getDefaultGmm()->isRenderCompressed = true; SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; @@ -404,7 +404,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmCompressionEnabledAn void *cpuAddr = reinterpret_cast(0x4000); uint64_t gpuAddr = 0x4000u; size_t allocSize = size; - GraphicsAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, 0); + GraphicsAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull); allocation.setDefaultGmm(new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false)); allocation.getDefaultGmm()->isRenderCompressed = true; SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; @@ -436,7 +436,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmCompressionDisabledA void *cpuAddr = reinterpret_cast(0x4000); uint64_t gpuAddr = 0x4000u; size_t allocSize = size; - GraphicsAllocation allocation(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, 0); + GraphicsAllocation allocation(0, GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull); allocation.setDefaultGmm(new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false)); SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; helper.setRenderSurfaceStateForBuffer(ee, stateBuffer, size, addr, 0, pitch, &allocation, 0, type, false); @@ -467,7 +467,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenGmmAndAllocationCompres void *cpuAddr = reinterpret_cast(0x4000); uint64_t gpuAddr = 0x4000u; size_t allocSize = size; - GraphicsAllocation allocation(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull, 0); + GraphicsAllocation allocation(0, GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull); allocation.setDefaultGmm(new Gmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false)); allocation.getDefaultGmm()->isRenderCompressed = true; SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; diff --git a/unit_tests/kernel/kernel_tests.cpp b/unit_tests/kernel/kernel_tests.cpp index 490fd62b81..f5e7fe0caf 100644 --- a/unit_tests/kernel/kernel_tests.cpp +++ b/unit_tests/kernel/kernel_tests.cpp @@ -866,7 +866,7 @@ TEST_F(KernelGlobalSurfaceTest, givenBuiltInKernelWhenKernelIsCreatedThenGlobalS char buffer[16]; - GraphicsAllocation gfxAlloc(GraphicsAllocation::AllocationType::UNKNOWN, buffer, (uint64_t)buffer - 8u, 8, 1u, MemoryPool::MemoryNull); + GraphicsAllocation gfxAlloc(0, GraphicsAllocation::AllocationType::UNKNOWN, buffer, (uint64_t)buffer - 8u, 8, (osHandle)1u, MemoryPool::MemoryNull); uint64_t bufferAddress = (uint64_t)gfxAlloc.getUnderlyingBuffer(); // create kernel @@ -909,7 +909,7 @@ TEST_F(KernelGlobalSurfaceTest, givenNDRangeKernelWhenKernelIsCreatedThenGlobalS char buffer[16]; - GraphicsAllocation gfxAlloc(GraphicsAllocation::AllocationType::UNKNOWN, buffer, (uint64_t)buffer - 8u, 8, MemoryPool::MemoryNull, 0); + GraphicsAllocation gfxAlloc(0, GraphicsAllocation::AllocationType::UNKNOWN, buffer, (uint64_t)buffer - 8u, 8, MemoryPool::MemoryNull); uint64_t bufferAddress = gfxAlloc.getGpuAddress(); // create kernel @@ -1041,7 +1041,7 @@ TEST_F(KernelConstantSurfaceTest, givenBuiltInKernelWhenKernelIsCreatedThenConst char buffer[16]; - GraphicsAllocation gfxAlloc(GraphicsAllocation::AllocationType::UNKNOWN, buffer, (uint64_t)buffer - 8u, 8, 1u, MemoryPool::MemoryNull); + GraphicsAllocation gfxAlloc(0, GraphicsAllocation::AllocationType::UNKNOWN, buffer, (uint64_t)buffer - 8u, 8, (osHandle)1u, MemoryPool::MemoryNull); uint64_t bufferAddress = (uint64_t)gfxAlloc.getUnderlyingBuffer(); // create kernel @@ -1083,7 +1083,7 @@ TEST_F(KernelConstantSurfaceTest, givenNDRangeKernelWhenKernelIsCreatedThenConst char buffer[16]; - GraphicsAllocation gfxAlloc(GraphicsAllocation::AllocationType::UNKNOWN, buffer, (uint64_t)buffer - 8u, 8, MemoryPool::MemoryNull, 0); + GraphicsAllocation gfxAlloc(0, GraphicsAllocation::AllocationType::UNKNOWN, buffer, (uint64_t)buffer - 8u, 8, MemoryPool::MemoryNull); uint64_t bufferAddress = gfxAlloc.getGpuAddress(); // create kernel diff --git a/unit_tests/memory_manager/CMakeLists.txt b/unit_tests/memory_manager/CMakeLists.txt index 45b9ca4535..f6fa7e1757 100644 --- a/unit_tests/memory_manager/CMakeLists.txt +++ b/unit_tests/memory_manager/CMakeLists.txt @@ -16,6 +16,7 @@ set(IGDRCL_SRCS_tests_memory_manager ${CMAKE_CURRENT_SOURCE_DIR}/host_ptr_manager_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/internal_allocation_storage_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/local_memory_usage_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/memory_manager_multi_device_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/memory_manager_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/memory_manager_allocate_in_device_pool_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/memory_manager_allocate_in_device_pool_tests.inl diff --git a/unit_tests/memory_manager/graphics_allocation_tests.cpp b/unit_tests/memory_manager/graphics_allocation_tests.cpp index fc38524965..d009ed84a4 100644 --- a/unit_tests/memory_manager/graphics_allocation_tests.cpp +++ b/unit_tests/memory_manager/graphics_allocation_tests.cpp @@ -12,12 +12,12 @@ using namespace NEO; TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenIsCreatedThenAdditionalDataIsSetToNull) { - MockGraphicsAllocation graphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, maxOsContextCount, MemoryPool::MemoryNull); + MockGraphicsAllocation graphicsAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, 0, MemoryPool::MemoryNull); EXPECT_EQ(graphicsAllocation.getAdditionalData(), nullptr); } TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenSetAdditionalDataThenAdditionalDataIsSetCorrectly) { - MockGraphicsAllocation graphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, maxOsContextCount, MemoryPool::MemoryNull); + MockGraphicsAllocation graphicsAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, 0, MemoryPool::MemoryNull); uint32_t dataToCheck = 32u; graphicsAllocation.setAdditionalData(&dataToCheck); @@ -26,15 +26,15 @@ TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenSetAdditionalDataThenAdd } TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenIsCreatedThenAllInspectionIdsAreSetToZero) { - MockGraphicsAllocation graphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, maxOsContextCount, MemoryPool::MemoryNull); + MockGraphicsAllocation graphicsAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, 0, MemoryPool::MemoryNull); for (auto i = 0u; i < maxOsContextCount; i++) { EXPECT_EQ(0u, graphicsAllocation.getInspectionId(i)); } } TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenIsCreatedThenTaskCountsAreInitializedProperly) { - GraphicsAllocation graphicsAllocation1(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, 0u, MemoryPool::MemoryNull, 0); - GraphicsAllocation graphicsAllocation2(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, MemoryPool::MemoryNull, 0); + GraphicsAllocation graphicsAllocation1(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, 0, MemoryPool::MemoryNull); + GraphicsAllocation graphicsAllocation2(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, 0, MemoryPool::MemoryNull); for (auto i = 0u; i < maxOsContextCount; i++) { EXPECT_EQ(MockGraphicsAllocation::objectNotUsed, graphicsAllocation1.getTaskCount(i)); EXPECT_EQ(MockGraphicsAllocation::objectNotUsed, graphicsAllocation2.getTaskCount(i)); @@ -178,7 +178,7 @@ TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenQueryingUsedPageSizeThen MemoryPool::SystemCpuInaccessible}; for (auto pool : page4kPools) { - MockGraphicsAllocation graphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, 1, pool); + MockGraphicsAllocation graphicsAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, (osHandle)1, pool); EXPECT_EQ(MemoryConstants::pageSize, graphicsAllocation.getUsedPageSize()); } @@ -188,7 +188,7 @@ TEST(GraphicsAllocationTest, givenGraphicsAllocationWhenQueryingUsedPageSizeThen MemoryPool::LocalMemory}; for (auto pool : page64kPools) { - MockGraphicsAllocation graphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, pool, 0); + MockGraphicsAllocation graphicsAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0u, 0, pool); EXPECT_EQ(MemoryConstants::pageSize64k, graphicsAllocation.getUsedPageSize()); } diff --git a/unit_tests/memory_manager/memory_manager_multi_device_tests.cpp b/unit_tests/memory_manager/memory_manager_multi_device_tests.cpp new file mode 100644 index 0000000000..c8eda05e24 --- /dev/null +++ b/unit_tests/memory_manager/memory_manager_multi_device_tests.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2019 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "core/memory_manager/memory_constants.h" +#include "runtime/mem_obj/image.h" +#include "runtime/mem_obj/mem_obj_helper.h" +#include "runtime/memory_manager/internal_allocation_storage.h" +#include "runtime/os_interface/os_context.h" +#include "runtime/os_interface/os_interface.h" +#include "runtime/platform/platform.h" +#include "test.h" +#include "unit_tests/fixtures/memory_allocator_multi_device_fixture.h" +#include "unit_tests/fixtures/memory_manager_fixture.h" +#include "unit_tests/helpers/execution_environment_helper.h" +#include "unit_tests/mocks/mock_execution_environment.h" +#include "unit_tests/mocks/mock_graphics_allocation.h" +#include "unit_tests/mocks/mock_memory_manager.h" +#include "unit_tests/mocks/mock_os_context.h" + +using namespace NEO; + +using MemoryManagerMultiDeviceTest = Test>; + +TEST_F(MemoryManagerMultiDeviceTest, givenRootDeviceIndexSpecifiedWhenAllocateGraphicsMemoryIsCalledThenGraphicsAllocationHasTheSameRootDeviceIndex) { + std::vector allocationTypes{GraphicsAllocation::AllocationType::BUFFER, + GraphicsAllocation::AllocationType::KERNEL_ISA}; + for (auto allocationType : allocationTypes) { + for (uint32_t rootDeviceIndex = 0; rootDeviceIndex < getNumRootDevices(); ++rootDeviceIndex) { + AllocationProperties properties{true, MemoryConstants::pageSize, allocationType, false, 0, rootDeviceIndex}; + + auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(properties); + ASSERT_NE(gfxAllocation, nullptr); + EXPECT_EQ(rootDeviceIndex, gfxAllocation->getRootDeviceIndex()); + memoryManager->freeGraphicsMemory(gfxAllocation); + + gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(properties, (void *)0x1234); + ASSERT_NE(gfxAllocation, nullptr); + EXPECT_EQ(rootDeviceIndex, gfxAllocation->getRootDeviceIndex()); + memoryManager->freeGraphicsMemory(gfxAllocation); + + gfxAllocation = memoryManager->allocateGraphicsMemoryInPreferredPool(properties, nullptr); + ASSERT_NE(gfxAllocation, nullptr); + EXPECT_EQ(rootDeviceIndex, gfxAllocation->getRootDeviceIndex()); + memoryManager->freeGraphicsMemory(gfxAllocation); + + gfxAllocation = memoryManager->allocateGraphicsMemoryInPreferredPool(properties, (void *)0x1234); + ASSERT_NE(gfxAllocation, nullptr); + EXPECT_EQ(rootDeviceIndex, gfxAllocation->getRootDeviceIndex()); + memoryManager->freeGraphicsMemory(gfxAllocation); + + gfxAllocation = memoryManager->createGraphicsAllocationFromSharedHandle((osHandle)1u, properties, false); + ASSERT_NE(gfxAllocation, nullptr); + EXPECT_EQ(rootDeviceIndex, gfxAllocation->getRootDeviceIndex()); + memoryManager->freeGraphicsMemory(gfxAllocation); + + gfxAllocation = memoryManager->createGraphicsAllocationFromSharedHandle((osHandle)1u, properties, true); + ASSERT_NE(gfxAllocation, nullptr); + EXPECT_EQ(rootDeviceIndex, gfxAllocation->getRootDeviceIndex()); + memoryManager->freeGraphicsMemory(gfxAllocation); + } + } +} diff --git a/unit_tests/memory_manager/memory_manager_tests.cpp b/unit_tests/memory_manager/memory_manager_tests.cpp index e7ab7fc451..3d30082e10 100644 --- a/unit_tests/memory_manager/memory_manager_tests.cpp +++ b/unit_tests/memory_manager/memory_manager_tests.cpp @@ -82,7 +82,7 @@ TEST(GraphicsAllocationTest, Ctor2) { void *cpuPtr = (void *)0x30000; size_t size = 0x1000; osHandle sharedHandle = Sharing::nonSharedResource; - GraphicsAllocation gfxAllocation(GraphicsAllocation::AllocationType::UNKNOWN, cpuPtr, size, sharedHandle, MemoryPool::MemoryNull, 0); + GraphicsAllocation gfxAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, cpuPtr, size, sharedHandle, MemoryPool::MemoryNull); uint64_t expectedGpuAddr = static_cast(reinterpret_cast(gfxAllocation.getUnderlyingBuffer())); EXPECT_EQ(expectedGpuAddr, gfxAllocation.getGpuAddress()); @@ -96,7 +96,7 @@ TEST(GraphicsAllocationTest, getGpuAddress) { uint64_t gpuBaseAddr = 0x10000; size_t size = 0x1000; - GraphicsAllocation gfxAllocation(GraphicsAllocation::AllocationType::UNKNOWN, cpuPtr, gpuAddr, gpuBaseAddr, size, MemoryPool::MemoryNull, 0); + GraphicsAllocation gfxAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, cpuPtr, gpuAddr, gpuBaseAddr, size, MemoryPool::MemoryNull); EXPECT_EQ(gpuAddr, gfxAllocation.getGpuAddress()); @@ -113,7 +113,7 @@ TEST(GraphicsAllocationTest, getGpuAddressToPatch) { uint64_t gpuBaseAddr = 0x10000; size_t size = 0x1000; - GraphicsAllocation gfxAllocation(GraphicsAllocation::AllocationType::UNKNOWN, cpuPtr, gpuAddr, gpuBaseAddr, size, MemoryPool::MemoryNull, 0); + GraphicsAllocation gfxAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, cpuPtr, gpuAddr, gpuBaseAddr, size, MemoryPool::MemoryNull); EXPECT_EQ(gpuAddr - gpuBaseAddr, gfxAllocation.getGpuAddressToPatch()); } @@ -124,7 +124,7 @@ TEST(GraphicsAllocationTest, setSize) { uint64_t gpuBaseAddr = 0x10000; size_t size = 0x2000; - GraphicsAllocation gfxAllocation(GraphicsAllocation::AllocationType::UNKNOWN, cpuPtr, gpuAddr, gpuBaseAddr, size, MemoryPool::MemoryNull, 0); + GraphicsAllocation gfxAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, cpuPtr, gpuAddr, gpuBaseAddr, size, MemoryPool::MemoryNull); EXPECT_EQ(size, gfxAllocation.getUnderlyingBufferSize()); size = 0x3000; @@ -1616,7 +1616,7 @@ TEST(GraphicsAllocation, givenSharedHandleBasedConstructorWhenGraphicsAllocation void *addressWithTrailingBitSet = reinterpret_cast(address); uint64_t expectedGpuAddress = 0xf0000000; osHandle sharedHandle{}; - GraphicsAllocation graphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN, addressWithTrailingBitSet, 1u, sharedHandle, MemoryPool::MemoryNull, 0); + GraphicsAllocation graphicsAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, addressWithTrailingBitSet, 1u, sharedHandle, MemoryPool::MemoryNull); EXPECT_EQ(expectedGpuAddress, graphicsAllocation.getGpuAddress()); } @@ -1783,35 +1783,35 @@ TEST(MemoryManagerTest, givenAllocationTypesThatMayNeedL3FlushWhenCallingGetAllo } TEST(HeapSelectorTest, given32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) { - GraphicsAllocation allocation{GraphicsAllocation::AllocationType::KERNEL_ISA, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; + GraphicsAllocation allocation{0, GraphicsAllocation::AllocationType::KERNEL_ISA, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; allocation.set32BitAllocation(true); EXPECT_EQ(internalHeapIndex, MemoryManager::selectHeap(&allocation, false, false)); } TEST(HeapSelectorTest, givenNon32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) { - GraphicsAllocation allocation{GraphicsAllocation::AllocationType::KERNEL_ISA, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; + GraphicsAllocation allocation{0, GraphicsAllocation::AllocationType::KERNEL_ISA, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; allocation.set32BitAllocation(false); EXPECT_EQ(internalHeapIndex, MemoryManager::selectHeap(&allocation, false, false)); } TEST(HeapSelectorTest, given32bitExternalAllocationWhenSelectingHeapThenExternalHeapIsUsed) { - GraphicsAllocation allocation{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; + GraphicsAllocation allocation{0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; allocation.set32BitAllocation(true); EXPECT_EQ(HeapIndex::HEAP_EXTERNAL, MemoryManager::selectHeap(&allocation, false, false)); } TEST(HeapSelectorTest, givenLimitedAddressSpaceWhenSelectingHeapForExternalAllocationThenStandardHeapIsUsed) { - GraphicsAllocation allocation{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; + GraphicsAllocation allocation{0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; EXPECT_EQ(HeapIndex::HEAP_STANDARD, MemoryManager::selectHeap(&allocation, true, false)); } TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithPtrThenSvmHeapIsUsed) { - GraphicsAllocation allocation{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; + GraphicsAllocation allocation{0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; EXPECT_EQ(HeapIndex::HEAP_SVM, MemoryManager::selectHeap(&allocation, true, true)); } TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrAndResourceIs64KSuitableThenStandard64kHeapIsUsed) { - GraphicsAllocation allocation{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; + GraphicsAllocation allocation{0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; auto gmm = std::make_unique(nullptr, 0, false); auto resourceInfo = static_cast(gmm->gmmResourceInfo.get()); resourceInfo->is64KBPageSuitableValue = true; @@ -1820,7 +1820,7 @@ TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocati } TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrAndResourceIsNot64KSuitableThenStandardHeapIsUsed) { - GraphicsAllocation allocation{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; + GraphicsAllocation allocation{0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; auto gmm = std::make_unique(nullptr, 0, false); auto resourceInfo = static_cast(gmm->gmmResourceInfo.get()); resourceInfo->is64KBPageSuitableValue = false; @@ -1837,14 +1837,14 @@ TEST(HeapSelectorTest, givenLimitedAddressSpaceWhenSelectingHeapForNullAllocatio } TEST(MemoryAllocationTest, givenAllocationTypeWhenPassedToMemoryAllocationConstructorThenAllocationTypeIsStored) { - MemoryAllocation allocation{GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, nullptr, 0, 0, 0, - MemoryPool::MemoryNull, 0, false, false}; + MemoryAllocation allocation{0, GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, nullptr, 0, 0, 0, + MemoryPool::MemoryNull, false, false}; EXPECT_EQ(GraphicsAllocation::AllocationType::COMMAND_BUFFER, allocation.getAllocationType()); } TEST(MemoryAllocationTest, givenMemoryPoolWhenPassedToMemoryAllocationConstructorThenMemoryPoolIsStored) { - MemoryAllocation allocation{GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, nullptr, 0, 0, 0, - MemoryPool::System64KBPages, 0, false, false}; + MemoryAllocation allocation{0, GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, nullptr, 0, 0, 0, + MemoryPool::System64KBPages, false, false}; EXPECT_EQ(MemoryPool::System64KBPages, allocation.getMemoryPool()); } diff --git a/unit_tests/mocks/linux/mock_drm_allocation.h b/unit_tests/mocks/linux/mock_drm_allocation.h index f082e4a429..f8fef3c89f 100644 --- a/unit_tests/mocks/linux/mock_drm_allocation.h +++ b/unit_tests/mocks/linux/mock_drm_allocation.h @@ -24,7 +24,7 @@ class MockDrmAllocation : public DrmAllocation { using DrmAllocation::bufferObjects; using DrmAllocation::memoryPool; - MockDrmAllocation(AllocationType allocationType, MemoryPool::Type pool) : DrmAllocation(allocationType, nullptr, nullptr, 0, static_cast(0), pool, 0) { + MockDrmAllocation(AllocationType allocationType, MemoryPool::Type pool) : DrmAllocation(0, allocationType, nullptr, nullptr, 0, static_cast(0), pool) { } }; diff --git a/unit_tests/mocks/mock_graphics_allocation.h b/unit_tests/mocks/mock_graphics_allocation.h index 6c5cd8e9c4..929ee53e4e 100644 --- a/unit_tests/mocks/mock_graphics_allocation.h +++ b/unit_tests/mocks/mock_graphics_allocation.h @@ -19,13 +19,13 @@ class MockGraphicsAllocation : public MemoryAllocation { using MemoryAllocation::usageInfos; MockGraphicsAllocation() - : MemoryAllocation(AllocationType::UNKNOWN, nullptr, 0u, 0, MemoryPool::MemoryNull, 0) {} + : MemoryAllocation(0, AllocationType::UNKNOWN, nullptr, 0u, 0, MemoryPool::MemoryNull) {} MockGraphicsAllocation(void *buffer, size_t sizeIn) - : MemoryAllocation(AllocationType::UNKNOWN, buffer, castToUint64(buffer), 0llu, sizeIn, MemoryPool::MemoryNull, 0) {} + : MemoryAllocation(0, AllocationType::UNKNOWN, buffer, castToUint64(buffer), 0llu, sizeIn, MemoryPool::MemoryNull) {} MockGraphicsAllocation(void *buffer, uint64_t gpuAddr, size_t sizeIn) - : MemoryAllocation(AllocationType::UNKNOWN, buffer, gpuAddr, 0llu, sizeIn, MemoryPool::MemoryNull, 0) {} + : MemoryAllocation(0, AllocationType::UNKNOWN, buffer, gpuAddr, 0llu, sizeIn, MemoryPool::MemoryNull) {} void resetInspectionIds() { for (auto &usageInfo : usageInfos) { diff --git a/unit_tests/os_interface/debug_settings_manager_tests.cpp b/unit_tests/os_interface/debug_settings_manager_tests.cpp index 75b0376dc2..80166b301b 100644 --- a/unit_tests/os_interface/debug_settings_manager_tests.cpp +++ b/unit_tests/os_interface/debug_settings_manager_tests.cpp @@ -942,7 +942,7 @@ TEST_P(AllocationTypeLogging, givenGraphicsAllocationTypeWhenConvertingToStringT FullyEnabledTestDebugManager debugManager; auto input = GetParam(); - GraphicsAllocation graphicsAllocation(input.type, nullptr, 0u, 0, MemoryPool::MemoryNull, true); + GraphicsAllocation graphicsAllocation(0, input.type, nullptr, 0ull, 0ull, 0, MemoryPool::MemoryNull); auto result = debugManager.getAllocationTypeString(&graphicsAllocation); @@ -956,7 +956,7 @@ INSTANTIATE_TEST_CASE_P(AllAllocationTypes, TEST(AllocationTypeLoggingSingle, givenGraphicsAllocationTypeWhenConvertingToStringIllegalValueThenILLEGAL_VALUEIsReturned) { FullyEnabledTestDebugManager debugManager; - GraphicsAllocation graphicsAllocation(static_cast(999), nullptr, 0u, 0, MemoryPool::MemoryNull, true); + GraphicsAllocation graphicsAllocation(0, static_cast(999), nullptr, 0ull, 0ull, 0, MemoryPool::MemoryNull); auto result = debugManager.getAllocationTypeString(&graphicsAllocation); @@ -966,7 +966,7 @@ TEST(AllocationTypeLoggingSingle, givenGraphicsAllocationTypeWhenConvertingToStr TEST(AllocationTypeLoggingSingle, givenGraphicsAllocationTypeWhenDebugManagerDisabledThennullptrReturned) { FullyDisabledTestDebugManager debugManager; - GraphicsAllocation graphicsAllocation(GraphicsAllocation::AllocationType::BUFFER, nullptr, 0u, 0, MemoryPool::MemoryNull, true); + GraphicsAllocation graphicsAllocation(0, GraphicsAllocation::AllocationType::BUFFER, nullptr, 0ull, 0ull, 0, MemoryPool::MemoryNull); auto result = debugManager.getAllocationTypeString(&graphicsAllocation); @@ -974,6 +974,6 @@ TEST(AllocationTypeLoggingSingle, givenGraphicsAllocationTypeWhenDebugManagerDis } TEST(AllocationInfoLogging, givenBaseGraphicsAllocationWhenGettingImplementationSpecificAllocationInfoThenReturnEmptyInfoString) { - GraphicsAllocation graphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0u, 0, MemoryPool::MemoryNull, true); + GraphicsAllocation graphicsAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0ull, 0ull, 0, MemoryPool::MemoryNull); EXPECT_STREQ(graphicsAllocation.getAllocationInfoString().c_str(), ""); } diff --git a/unit_tests/os_interface/linux/drm_command_stream_tests.cpp b/unit_tests/os_interface/linux/drm_command_stream_tests.cpp index f8373045d6..ce34966828 100644 --- a/unit_tests/os_interface/linux/drm_command_stream_tests.cpp +++ b/unit_tests/os_interface/linux/drm_command_stream_tests.cpp @@ -62,7 +62,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, makeResident) { .Times(0); EXPECT_CALL(*mock, ioctl(DRM_IOCTL_I915_GEM_WAIT, ::testing::_)) .Times(0); - DrmAllocation graphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 1024, MemoryPool::MemoryNull, 0, 1u); + DrmAllocation graphicsAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 1024, (osHandle)1u, MemoryPool::MemoryNull); csr->makeResident(graphicsAllocation); } @@ -76,7 +76,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, makeResidentTwiceTheSame) { EXPECT_CALL(*mock, ioctl(DRM_IOCTL_I915_GEM_WAIT, ::testing::_)) .Times(0); - DrmAllocation graphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 1024, MemoryPool::MemoryNull, 0, 1u); + DrmAllocation graphicsAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 1024, (osHandle)1u, MemoryPool::MemoryNull); csr->makeResident(graphicsAllocation); csr->makeResident(graphicsAllocation); @@ -92,7 +92,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, makeResidentSizeZero) { EXPECT_CALL(*mock, ioctl(DRM_IOCTL_I915_GEM_WAIT, ::testing::_)) .Times(0); - DrmAllocation graphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0, MemoryPool::MemoryNull, 0, 1u); + DrmAllocation graphicsAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0, (osHandle)1u, MemoryPool::MemoryNull); csr->makeResident(graphicsAllocation); } @@ -107,8 +107,8 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, makeResidentResized) { EXPECT_CALL(*mock, ioctl(DRM_IOCTL_I915_GEM_WAIT, ::testing::_)) .Times(0); - DrmAllocation graphicsAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 1024, MemoryPool::MemoryNull, 0, 1u); - DrmAllocation graphicsAllocation2(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 8192, MemoryPool::MemoryNull, 0, 1u); + DrmAllocation graphicsAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 1024, (osHandle)1u, MemoryPool::MemoryNull); + DrmAllocation graphicsAllocation2(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 8192, (osHandle)1u, MemoryPool::MemoryNull); csr->makeResident(graphicsAllocation); csr->makeResident(graphicsAllocation2); @@ -272,7 +272,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, FlushInvalidAddress) { //allocate command buffer manually char *commandBuffer = new (std::nothrow) char[1024]; ASSERT_NE(nullptr, commandBuffer); - DrmAllocation commandBufferAllocation(GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, commandBuffer, 1024, MemoryPool::MemoryNull, 0, 1u); + DrmAllocation commandBufferAllocation(0, GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, commandBuffer, 1024, (osHandle)1u, MemoryPool::MemoryNull); LinearStream cs(&commandBufferAllocation); CommandStreamReceiverHw::addBatchBufferEnd(cs, nullptr); @@ -410,8 +410,8 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, FlushCheckFlags) { .Times(1) .WillRepeatedly(::testing::Return(0)); - DrmAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, (void *)0x7FFFFFFF, 1024, (osHandle)0u, MemoryPool::MemoryNull, 0); - DrmAllocation allocation2(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, (void *)0x307FFFFFFF, 1024, (osHandle)0u, MemoryPool::MemoryNull, 0); + DrmAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, (void *)0x7FFFFFFF, 1024, (osHandle)0u, MemoryPool::MemoryNull); + DrmAllocation allocation2(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, (void *)0x307FFFFFFF, 1024, (osHandle)0u, MemoryPool::MemoryNull); csr->makeResident(allocation); csr->makeResident(allocation2); CommandStreamReceiverHw::addBatchBufferEnd(cs, nullptr); @@ -444,7 +444,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, CheckDrmFree) { EXPECT_CALL(*mock, ioctl(DRM_IOCTL_I915_GEM_WAIT, ::testing::_)) .Times(2); - DrmAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 1024, (osHandle)0u, MemoryPool::MemoryNull, 0); + DrmAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 1024, (osHandle)0u, MemoryPool::MemoryNull); csr->makeResident(allocation); CommandStreamReceiverHw::addBatchBufferEnd(cs, nullptr); @@ -485,7 +485,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, CheckDrmFreeCloseFailed) { .WillOnce(::testing::Return(-1)); EXPECT_CALL(*mock, ioctl(DRM_IOCTL_I915_GEM_WAIT, ::testing::_)) .Times(2); - DrmAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 1024, (osHandle)0u, MemoryPool::MemoryNull, 0); + DrmAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 1024, (osHandle)0u, MemoryPool::MemoryNull); csr->makeResident(allocation); CommandStreamReceiverHw::addBatchBufferEnd(cs, nullptr); @@ -810,7 +810,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamBatchingTests, givenRecordedCommandBufferWhen HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenDrmAllocationWhenGetBufferObjectToModifyIsCalledForAGivenHandleIdThenTheCorrespondingBufferObjectGetsModified) { auto size = 1024u; - auto allocation = new DrmAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, size, (osHandle)0u, MemoryPool::MemoryNull, 0); + auto allocation = new DrmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, size, (osHandle)0u, MemoryPool::MemoryNull); auto &bos = allocation->getBOs(); for (auto handleId = 0u; handleId < maxHandleCount; handleId++) { @@ -830,7 +830,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenDrmAllocationWhenGetBuffer HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, makeResident) { auto buffer = this->createBO(1024); - auto allocation = new DrmAllocation(GraphicsAllocation::AllocationType::UNKNOWN, buffer, nullptr, buffer->peekSize(), (osHandle)0u, MemoryPool::MemoryNull, 0); + auto allocation = new DrmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, buffer, nullptr, buffer->peekSize(), (osHandle)0u, MemoryPool::MemoryNull); EXPECT_EQ(nullptr, allocation->getUnderlyingBuffer()); csr->makeResident(*allocation); @@ -848,8 +848,8 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, makeResident) { HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, makeResidentOnly) { BufferObject *buffer1 = this->createBO(4096); BufferObject *buffer2 = this->createBO(4096); - auto allocation1 = new DrmAllocation(GraphicsAllocation::AllocationType::UNKNOWN, buffer1, nullptr, buffer1->peekSize(), (osHandle)0u, MemoryPool::MemoryNull, 0); - auto allocation2 = new DrmAllocation(GraphicsAllocation::AllocationType::UNKNOWN, buffer2, nullptr, buffer2->peekSize(), (osHandle)0u, MemoryPool::MemoryNull, 0); + auto allocation1 = new DrmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, buffer1, nullptr, buffer1->peekSize(), (osHandle)0u, MemoryPool::MemoryNull); + auto allocation2 = new DrmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, buffer2, nullptr, buffer2->peekSize(), (osHandle)0u, MemoryPool::MemoryNull); EXPECT_EQ(nullptr, allocation1->getUnderlyingBuffer()); EXPECT_EQ(nullptr, allocation2->getUnderlyingBuffer()); @@ -872,7 +872,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, makeResidentOnly) { HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, makeResidentTwice) { auto buffer = this->createBO(1024); - auto allocation = new DrmAllocation(GraphicsAllocation::AllocationType::UNKNOWN, buffer, nullptr, buffer->peekSize(), (osHandle)0u, MemoryPool::MemoryNull, 0); + auto allocation = new DrmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, buffer, nullptr, buffer->peekSize(), (osHandle)0u, MemoryPool::MemoryNull); csr->makeResident(*allocation); csr->processResidency(csr->getResidencyAllocations()); @@ -1098,7 +1098,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, GivenTwoAllocationsWhenBackingS HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, makeResidentSizeZero) { std::unique_ptr buffer(this->createBO(0)); - DrmAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, buffer.get(), nullptr, buffer->peekSize(), (osHandle)0u, MemoryPool::MemoryNull, 0); + DrmAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, buffer.get(), nullptr, buffer->peekSize(), (osHandle)0u, MemoryPool::MemoryNull); EXPECT_EQ(nullptr, allocation.getUnderlyingBuffer()); EXPECT_EQ(buffer->peekSize(), allocation.getUnderlyingBufferSize()); @@ -1322,7 +1322,7 @@ class DrmMockBuffer : public Buffer { public: static DrmMockBuffer *create() { char *data = static_cast(::alignedMalloc(128, 64)); - DrmAllocation *alloc = new (std::nothrow) DrmAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, &data, sizeof(data), MemoryPool::MemoryNull, 0, 1u); + DrmAllocation *alloc = new (std::nothrow) DrmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, &data, sizeof(data), (osHandle)0, MemoryPool::MemoryNull); return new DrmMockBuffer(data, 128, alloc); } @@ -1375,7 +1375,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, givenAllocationWithSingleBuffer auto size = 1024u; auto bo = this->createBO(size); BufferObjects bos{{bo}}; - auto allocation = new DrmAllocation(GraphicsAllocation::AllocationType::UNKNOWN, bos, nullptr, 0u, size, MemoryPool::LocalMemory, 0); + auto allocation = new DrmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, bos, nullptr, 0u, size, MemoryPool::LocalMemory); EXPECT_EQ(bo, allocation->getBO()); makeResidentBufferObjects(allocation); diff --git a/unit_tests/os_interface/linux/drm_gem_close_worker_tests.cpp b/unit_tests/os_interface/linux/drm_gem_close_worker_tests.cpp index b4a715e16b..de99fd5fa0 100644 --- a/unit_tests/os_interface/linux/drm_gem_close_worker_tests.cpp +++ b/unit_tests/os_interface/linux/drm_gem_close_worker_tests.cpp @@ -93,7 +93,7 @@ class DrmGemCloseWorkerFixture { class DrmAllocationWrapper : public DrmAllocation { public: DrmAllocationWrapper(BufferObject *bo) - : DrmAllocation(GraphicsAllocation::AllocationType::UNKNOWN, bo, nullptr, 0, (osHandle)0u, MemoryPool::MemoryNull, 0) { + : DrmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, bo, nullptr, 0, (osHandle)0u, MemoryPool::MemoryNull) { } }; MockExecutionEnvironment executionEnvironment; diff --git a/unit_tests/os_interface/linux/drm_memory_manager_allocate_in_device_pool_tests.cpp b/unit_tests/os_interface/linux/drm_memory_manager_allocate_in_device_pool_tests.cpp index 8eb05ca202..d24444542b 100644 --- a/unit_tests/os_interface/linux/drm_memory_manager_allocate_in_device_pool_tests.cpp +++ b/unit_tests/os_interface/linux/drm_memory_manager_allocate_in_device_pool_tests.cpp @@ -39,7 +39,7 @@ TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenLockResourceIsCalledOn MockExecutionEnvironment executionEnvironment(*platformDevices); executionEnvironment.osInterface = std::make_unique(); TestedDrmMemoryManager memoryManager(executionEnvironment); - DrmAllocation drmAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0u, 0u, MemoryPool::LocalMemory, 0); + DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0u, 0u, MemoryPool::LocalMemory); auto ptr = memoryManager.lockResourceInLocalMemoryImpl(drmAllocation.getBO()); EXPECT_EQ(nullptr, ptr); @@ -52,7 +52,7 @@ TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenFreeGraphicsMemoryIsCa executionEnvironment.osInterface = std::make_unique(); TestedDrmMemoryManager memoryManager(executionEnvironment); - auto drmAllocation = new DrmAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0u, 0u, MemoryPool::LocalMemory, 0); + auto drmAllocation = new DrmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0u, 0u, MemoryPool::LocalMemory); EXPECT_NE(nullptr, drmAllocation); memoryManager.freeGraphicsMemoryImpl(drmAllocation); @@ -61,7 +61,7 @@ TEST(DrmMemoryManagerSimpleTest, givenDrmMemoryManagerWhenFreeGraphicsMemoryIsCa using DrmMemoryManagerWithLocalMemoryTest = Test; TEST_F(DrmMemoryManagerWithLocalMemoryTest, givenDrmMemoryManagerWithLocalMemoryWhenLockResourceIsCalledOnAllocationInLocalMemoryThenReturnNullPtr) { - DrmAllocation drmAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0u, 0u, MemoryPool::LocalMemory, 0); + DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0u, 0u, MemoryPool::LocalMemory); auto ptr = memoryManager->lockResource(&drmAllocation); EXPECT_EQ(nullptr, ptr); diff --git a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp index e583d0c2f6..6d38f287c8 100644 --- a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp @@ -63,7 +63,7 @@ TEST_F(DrmMemoryManagerTest, GivenGraphicsAllocationWhenAddAndRemoveAllocationTo void *cpuPtr = (void *)0x30000; size_t size = 0x1000; - DrmAllocation gfxAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, cpuPtr, size, 1u, MemoryPool::MemoryNull, 0); + DrmAllocation gfxAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, cpuPtr, size, (osHandle)1u, MemoryPool::MemoryNull); memoryManager->addAllocationToHostPtrManager(&gfxAllocation); auto fragment = memoryManager->getHostPtrManager()->getFragment(gfxAllocation.getUnderlyingBuffer()); EXPECT_NE(fragment, nullptr); @@ -1981,7 +1981,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenLockUnlockIsCalledOnNullAl } TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAllocationWithoutBufferObjectThenReturnNullPtr) { - DrmAllocation drmAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0, (osHandle)0u, MemoryPool::MemoryNull, 0); + DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0, (osHandle)0u, MemoryPool::MemoryNull); EXPECT_EQ(nullptr, drmAllocation.getBO()); auto ptr = memoryManager->lockResource(&drmAllocation); @@ -2000,7 +2000,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenLockUnlockIsCalledButFails BufferObjectMock(Drm *drm) : BufferObject(drm, 1, 0) {} }; BufferObjectMock bo(&drmMock); - DrmAllocation drmAllocation(GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, (osHandle)0u, MemoryPool::MemoryNull, 0); + DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, (osHandle)0u, MemoryPool::MemoryNull); EXPECT_NE(nullptr, drmAllocation.getBO()); auto ptr = memoryManager->lockResource(&drmAllocation); @@ -2011,7 +2011,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenLockUnlockIsCalledButFails } TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSetDomainCpuIsCalledOnAllocationWithoutBufferObjectThenReturnFalse) { - DrmAllocation drmAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0, (osHandle)0u, MemoryPool::MemoryNull, 0); + DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0, (osHandle)0u, MemoryPool::MemoryNull); EXPECT_EQ(nullptr, drmAllocation.getBO()); auto success = memoryManager->setDomainCpu(drmAllocation, false); @@ -2028,7 +2028,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSetDomainCpuIsCalledButFai BufferObjectMock(Drm *drm) : BufferObject(drm, 1, 0) {} }; BufferObjectMock bo(&drmMock); - DrmAllocation drmAllocation(GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, (osHandle)0u, MemoryPool::MemoryNull, 0); + DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, (osHandle)0u, MemoryPool::MemoryNull); EXPECT_NE(nullptr, drmAllocation.getBO()); auto success = memoryManager->setDomainCpu(drmAllocation, false); @@ -2044,7 +2044,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenSetDomainCpuIsCalledOnAllo BufferObjectMock(Drm *drm) : BufferObject(drm, 1, 0) {} }; BufferObjectMock bo(&drmMock); - DrmAllocation drmAllocation(GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, (osHandle)0u, MemoryPool::MemoryNull, 0); + DrmAllocation drmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, &bo, nullptr, 0u, (osHandle)0u, MemoryPool::MemoryNull); EXPECT_NE(nullptr, drmAllocation.getBO()); auto success = memoryManager->setDomainCpu(drmAllocation, true); @@ -3059,18 +3059,18 @@ TEST_F(DrmMemoryManagerBasic, givenLocalMemoryDisabledWhenAllocateInDevicePoolIs } TEST(DrmAllocationTest, givenAllocationTypeWhenPassedToDrmAllocationConstructorThenAllocationTypeIsStored) { - DrmAllocation allocation{GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, nullptr, static_cast(0), 0u, MemoryPool::MemoryNull, 0}; + DrmAllocation allocation{0, GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, nullptr, static_cast(0), 0u, MemoryPool::MemoryNull}; EXPECT_EQ(GraphicsAllocation::AllocationType::COMMAND_BUFFER, allocation.getAllocationType()); - DrmAllocation allocation2{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0ULL, static_cast(0), MemoryPool::MemoryNull, 0}; + DrmAllocation allocation2{0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0ULL, static_cast(0), MemoryPool::MemoryNull}; EXPECT_EQ(GraphicsAllocation::AllocationType::UNKNOWN, allocation2.getAllocationType()); } TEST(DrmAllocationTest, givenMemoryPoolWhenPassedToDrmAllocationConstructorThenMemoryPoolIsStored) { - DrmAllocation allocation{GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, nullptr, static_cast(0), 0u, MemoryPool::System64KBPages, 0}; + DrmAllocation allocation{0, GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, nullptr, static_cast(0), 0u, MemoryPool::System64KBPages}; EXPECT_EQ(MemoryPool::System64KBPages, allocation.getMemoryPool()); - DrmAllocation allocation2{GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0ULL, static_cast(0), MemoryPool::SystemCpuInaccessible, 0}; + DrmAllocation allocation2{0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, nullptr, 0ULL, static_cast(0), MemoryPool::SystemCpuInaccessible}; EXPECT_EQ(MemoryPool::SystemCpuInaccessible, allocation2.getMemoryPool()); } diff --git a/unit_tests/os_interface/windows/mock_wddm_allocation.h b/unit_tests/os_interface/windows/mock_wddm_allocation.h index 4b9ec2e372..24e6809613 100644 --- a/unit_tests/os_interface/windows/mock_wddm_allocation.h +++ b/unit_tests/os_interface/windows/mock_wddm_allocation.h @@ -12,7 +12,7 @@ namespace NEO { class MockWddmAllocation : public WddmAllocation { public: - MockWddmAllocation() : WddmAllocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, nullptr, MemoryPool::MemoryNull, 0), gpuPtr(gpuAddress), handle(handles[0]) { + MockWddmAllocation() : WddmAllocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, nullptr, MemoryPool::MemoryNull), gpuPtr(gpuAddress), handle(handles[0]) { } using WddmAllocation::cpuPtr; using WddmAllocation::memoryPool; diff --git a/unit_tests/os_interface/windows/wddm20_tests.cpp b/unit_tests/os_interface/windows/wddm20_tests.cpp index 903359c63a..7d2bcb24ab 100644 --- a/unit_tests/os_interface/windows/wddm20_tests.cpp +++ b/unit_tests/os_interface/windows/wddm20_tests.cpp @@ -85,7 +85,7 @@ TEST_F(Wddm20Tests, givenNullPageTableManagerAndRenderCompressedResourceWhenMapp mockGmmRes->setUnifiedAuxTranslationCapable(); void *fakePtr = reinterpret_cast(0x100); - WddmAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, fakePtr, 0x2100, nullptr, MemoryPool::MemoryNull, 0); + WddmAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, fakePtr, 0x2100, nullptr, MemoryPool::MemoryNull); allocation.setDefaultGmm(gmm.get()); allocation.getHandleToModify(0u) = ALLOCATION_HANDLE; @@ -221,7 +221,7 @@ TEST_F(Wddm20Tests, whenInitializeWddmThenContextIsCreated) { TEST_F(Wddm20Tests, allocation) { OsAgnosticMemoryManager mm(*executionEnvironment); - WddmAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, mm.allocateSystemMemory(100, 0), 100, nullptr, MemoryPool::MemoryNull, 0); + WddmAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, mm.allocateSystemMemory(100, 0), 100, nullptr, MemoryPool::MemoryNull); Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize()); allocation.setDefaultGmm(gmm); @@ -245,7 +245,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenAllocationSmallerUnderlyingThanAlignedSiz size_t underlyingPages = underlyingSize / MemoryConstants::pageSize; size_t alignedPages = alignedSize / MemoryConstants::pageSize; - WddmAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, ptr, 0x2100, nullptr, MemoryPool::MemoryNull, 0); + WddmAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, ptr, 0x2100, nullptr, MemoryPool::MemoryNull); Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getAlignedCpuPtr(), allocation.getAlignedSize()); allocation.setDefaultGmm(gmm); @@ -286,7 +286,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenReserveCallWhenItIsCalledWithProperParamt TEST_F(Wddm20WithMockGdiDllTests, givenWddmAllocationWhenMappingGpuVaThenUseGmmSize) { void *fakePtr = reinterpret_cast(0x123); - WddmAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, fakePtr, 100, nullptr, MemoryPool::MemoryNull, 0); + WddmAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, fakePtr, 100, nullptr, MemoryPool::MemoryNull); std::unique_ptr gmm(GmmHelperFunctions::getGmm(allocation.getAlignedCpuPtr(), allocation.getAlignedSize())); allocation.setDefaultGmm(gmm.get()); @@ -353,7 +353,7 @@ TEST_F(Wddm20WithMockGdiDllTests, GivenThreeOsHandlesWhenAskedForDestroyAllocati TEST_F(Wddm20Tests, mapAndFreeGpuVa) { OsAgnosticMemoryManager mm(*executionEnvironment); - WddmAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, mm.allocateSystemMemory(100, 0), 100, nullptr, MemoryPool::MemoryNull, 0); + WddmAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, mm.allocateSystemMemory(100, 0), 100, nullptr, MemoryPool::MemoryNull); Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize()); allocation.setDefaultGmm(gmm); @@ -379,7 +379,7 @@ TEST_F(Wddm20Tests, mapAndFreeGpuVa) { TEST_F(Wddm20Tests, givenNullAllocationWhenCreateThenAllocateAndMap) { OsAgnosticMemoryManager mm(*executionEnvironment); - WddmAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 100, nullptr, MemoryPool::MemoryNull, 0); + WddmAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 100, nullptr, MemoryPool::MemoryNull); Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize()); allocation.setDefaultGmm(gmm); @@ -398,7 +398,7 @@ TEST_F(Wddm20Tests, givenNullAllocationWhenCreateThenAllocateAndMap) { TEST_F(Wddm20Tests, makeResidentNonResident) { OsAgnosticMemoryManager mm(*executionEnvironment); - WddmAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, mm.allocateSystemMemory(100, 0), 100, nullptr, MemoryPool::MemoryNull, 0); + WddmAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, mm.allocateSystemMemory(100, 0), 100, nullptr, MemoryPool::MemoryNull); Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize()); allocation.setDefaultGmm(gmm); @@ -758,7 +758,7 @@ TEST_F(Wddm20Tests, whenCreateAllocation64kFailsThenReturnFalse) { void *fakePtr = reinterpret_cast(0x123); auto gmm = std::make_unique(fakePtr, 100, false); - WddmAllocation allocation(GraphicsAllocation::AllocationType::UNKNOWN, fakePtr, 100, nullptr, MemoryPool::MemoryNull, 0); + WddmAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, fakePtr, 100, nullptr, MemoryPool::MemoryNull); allocation.setDefaultGmm(gmm.get()); EXPECT_FALSE(wddm->createAllocation64k(&allocation)); diff --git a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp index d8bfff0c04..7b3fcd65d4 100644 --- a/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp @@ -93,15 +93,15 @@ TEST(WddmAllocationTest, givenRequestedContextIdTooLargeWhenGettingTrimCandidate } TEST(WddmAllocationTest, givenAllocationTypeWhenPassedToWddmAllocationConstructorThenAllocationTypeIsStored) { - WddmAllocation allocation{GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, 0, nullptr, MemoryPool::MemoryNull, 0}; + WddmAllocation allocation{0, GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, 0, nullptr, MemoryPool::MemoryNull}; EXPECT_EQ(GraphicsAllocation::AllocationType::COMMAND_BUFFER, allocation.getAllocationType()); } TEST(WddmAllocationTest, givenMemoryPoolWhenPassedToWddmAllocationConstructorThenMemoryPoolIsStored) { - WddmAllocation allocation{GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, 0, nullptr, MemoryPool::System64KBPages, 0}; + WddmAllocation allocation{0, GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, 0, nullptr, MemoryPool::System64KBPages}; EXPECT_EQ(MemoryPool::System64KBPages, allocation.getMemoryPool()); - WddmAllocation allocation2{GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, 0, 0u, MemoryPool::SystemCpuInaccessible, 0}; + WddmAllocation allocation2{0, GraphicsAllocation::AllocationType::COMMAND_BUFFER, nullptr, 0, 0u, MemoryPool::SystemCpuInaccessible}; EXPECT_EQ(MemoryPool::SystemCpuInaccessible, allocation2.getMemoryPool()); } @@ -961,7 +961,7 @@ TEST_F(WddmMemoryManagerTest, givenManagerWithDisabledDeferredDeleterWhenMapGpuV memoryManager->setDeferredDeleter(nullptr); setMapGpuVaFailConfigFcn(0, 1); - WddmAllocation allocation(GraphicsAllocation::AllocationType::BUFFER, ptr, size, nullptr, MemoryPool::MemoryNull, 0); + WddmAllocation allocation(0, GraphicsAllocation::AllocationType::BUFFER, ptr, size, nullptr, MemoryPool::MemoryNull); allocation.setDefaultGmm(gmm.get()); bool ret = memoryManager->createWddmAllocation(&allocation, allocation.getAlignedCpuPtr()); EXPECT_FALSE(ret); @@ -977,7 +977,7 @@ TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstMap setMapGpuVaFailConfigFcn(0, 1); - WddmAllocation allocation(GraphicsAllocation::AllocationType::BUFFER, ptr, size, nullptr, MemoryPool::MemoryNull, 0); + WddmAllocation allocation(0, GraphicsAllocation::AllocationType::BUFFER, ptr, size, nullptr, MemoryPool::MemoryNull); allocation.setDefaultGmm(gmm.get()); bool ret = memoryManager->createWddmAllocation(&allocation, allocation.getAlignedCpuPtr()); EXPECT_TRUE(ret); @@ -993,7 +993,7 @@ TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstAnd setMapGpuVaFailConfigFcn(0, 2); - WddmAllocation allocation(GraphicsAllocation::AllocationType::BUFFER, ptr, size, nullptr, MemoryPool::MemoryNull, 0); + WddmAllocation allocation(0, GraphicsAllocation::AllocationType::BUFFER, ptr, size, nullptr, MemoryPool::MemoryNull); allocation.setDefaultGmm(gmm.get()); bool ret = memoryManager->createWddmAllocation(&allocation, allocation.getAlignedCpuPtr()); EXPECT_FALSE(ret); diff --git a/unit_tests/os_interface/windows/wddm_residency_controller_tests.cpp b/unit_tests/os_interface/windows/wddm_residency_controller_tests.cpp index bb450a47f1..3c29a01506 100644 --- a/unit_tests/os_interface/windows/wddm_residency_controller_tests.cpp +++ b/unit_tests/os_interface/windows/wddm_residency_controller_tests.cpp @@ -657,9 +657,9 @@ TEST_F(WddmResidencyControllerWithGdiTest, trimToBudgetReturnsFalseWhenNumBytesT } TEST_F(WddmResidencyControllerWithGdiTest, trimToBudgetStopsEvictingWhenNumBytesToTrimIsZero) { - WddmAllocation allocation1(GraphicsAllocation::AllocationType::UNKNOWN, reinterpret_cast(0x1000), 0x1000, nullptr, MemoryPool::MemoryNull, 0); - WddmAllocation allocation2(GraphicsAllocation::AllocationType::UNKNOWN, reinterpret_cast(0x1000), 0x3000, nullptr, MemoryPool::MemoryNull, 0); - WddmAllocation allocation3(GraphicsAllocation::AllocationType::UNKNOWN, reinterpret_cast(0x1000), 0x1000, nullptr, MemoryPool::MemoryNull, 0); + WddmAllocation allocation1(0, GraphicsAllocation::AllocationType::UNKNOWN, reinterpret_cast(0x1000), 0x1000, nullptr, MemoryPool::MemoryNull); + WddmAllocation allocation2(0, GraphicsAllocation::AllocationType::UNKNOWN, reinterpret_cast(0x1000), 0x3000, nullptr, MemoryPool::MemoryNull); + WddmAllocation allocation3(0, GraphicsAllocation::AllocationType::UNKNOWN, reinterpret_cast(0x1000), 0x1000, nullptr, MemoryPool::MemoryNull); allocation1.getResidencyData().resident[osContextId] = true; allocation1.getResidencyData().updateCompletionData(0, osContextId); @@ -752,8 +752,8 @@ TEST_F(WddmResidencyControllerWithGdiTest, trimToBudgetWaitsFromCpuWhenLastFence TEST_F(WddmResidencyControllerWithGdiAndMemoryManagerTest, trimToBudgetEvictsDoneFragmentsOnly) { gdi->setNonZeroNumBytesToTrimInEvict(); void *ptr = reinterpret_cast(wddm->virtualAllocAddress + 0x1000); - WddmAllocation allocation1(GraphicsAllocation::AllocationType::UNKNOWN, ptr, 0x1000, nullptr, MemoryPool::MemoryNull, 0); - WddmAllocation allocation2(GraphicsAllocation::AllocationType::UNKNOWN, ptr, 0x1000, nullptr, MemoryPool::MemoryNull, 0); + WddmAllocation allocation1(0, GraphicsAllocation::AllocationType::UNKNOWN, ptr, 0x1000, nullptr, MemoryPool::MemoryNull); + WddmAllocation allocation2(0, GraphicsAllocation::AllocationType::UNKNOWN, ptr, 0x1000, nullptr, MemoryPool::MemoryNull); allocation1.getResidencyData().resident[osContextId] = true; allocation1.getResidencyData().updateCompletionData(0, osContextId); @@ -811,9 +811,9 @@ TEST_F(WddmResidencyControllerWithGdiTest, givenThreeAllocationsAlignedSizeBigge void *ptr2 = reinterpret_cast(wddm->virtualAllocAddress + 0x3000); void *ptr3 = reinterpret_cast(wddm->virtualAllocAddress + 0x5000); - WddmAllocation allocation1(GraphicsAllocation::AllocationType::UNKNOWN, ptr1, underlyingSize, nullptr, MemoryPool::MemoryNull, 0); - WddmAllocation allocation2(GraphicsAllocation::AllocationType::UNKNOWN, ptr2, underlyingSize, nullptr, MemoryPool::MemoryNull, 0); - WddmAllocation allocation3(GraphicsAllocation::AllocationType::UNKNOWN, ptr3, underlyingSize, nullptr, MemoryPool::MemoryNull, 0); + WddmAllocation allocation1(0, GraphicsAllocation::AllocationType::UNKNOWN, ptr1, underlyingSize, nullptr, MemoryPool::MemoryNull); + WddmAllocation allocation2(0, GraphicsAllocation::AllocationType::UNKNOWN, ptr2, underlyingSize, nullptr, MemoryPool::MemoryNull); + WddmAllocation allocation3(0, GraphicsAllocation::AllocationType::UNKNOWN, ptr3, underlyingSize, nullptr, MemoryPool::MemoryNull); allocation1.getResidencyData().resident[osContextId] = true; allocation1.getResidencyData().updateCompletionData(0, osContextId); @@ -1013,7 +1013,7 @@ TEST_F(WddmResidencyControllerWithMockWddmTest, givenMakeResidentFailsAndTrimToB MockWddmAllocation allocation1; void *cpuPtr = reinterpret_cast(wddm->getWddmMinAddress() + 0x1000); size_t allocationSize = 0x1000; - WddmAllocation allocationToTrim(GraphicsAllocation::AllocationType::UNKNOWN, cpuPtr, allocationSize, nullptr, MemoryPool::MemoryNull, 0); + WddmAllocation allocationToTrim(0, GraphicsAllocation::AllocationType::UNKNOWN, cpuPtr, allocationSize, nullptr, MemoryPool::MemoryNull); allocationToTrim.getResidencyData().updateCompletionData(residencyController->getMonitoredFence().lastSubmittedFence, osContext->getContextId());