diff --git a/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.h b/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.h index 7150f01d10..a02945bca4 100644 --- a/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.h +++ b/level_zero/core/test/unit_tests/fixtures/memory_ipc_fixture.h @@ -429,7 +429,7 @@ class IpcImplicitScalingMockGraphicsAllocation : public NEO::MemoryAllocation { using MemoryAllocation::usageInfos; IpcImplicitScalingMockGraphicsAllocation() - : NEO::MemoryAllocation(0, AllocationType::UNKNOWN, nullptr, 0u, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount) {} + : NEO::MemoryAllocation(0, AllocationType::UNKNOWN, nullptr, 0u, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu) {} IpcImplicitScalingMockGraphicsAllocation(void *buffer, size_t sizeIn) : NEO::MemoryAllocation(0, AllocationType::UNKNOWN, buffer, castToUint64(buffer), 0llu, sizeIn, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount) {} @@ -454,13 +454,17 @@ class MemoryManagerOpenIpcMock : public MemoryManagerIpcMock { MemoryManagerOpenIpcMock(NEO::ExecutionEnvironment &executionEnvironment) : MemoryManagerIpcMock(executionEnvironment) {} NEO::GraphicsAllocation *allocateGraphicsMemoryWithProperties(const AllocationProperties &properties) override { + auto ptr = reinterpret_cast(sharedHandleAddress++); + auto gmmHelper = getGmmHelper(0); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); auto alloc = new IpcImplicitScalingMockGraphicsAllocation(properties.rootDeviceIndex, NEO::AllocationType::BUFFER, - reinterpret_cast(sharedHandleAddress++), + ptr, 0x1000, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); alloc->setGpuBaseAddress(0xabcd); return alloc; } @@ -469,13 +473,17 @@ class MemoryManagerOpenIpcMock : public MemoryManagerIpcMock { if (failOnCreateGraphicsAllocationFromSharedHandle) { return nullptr; } + auto ptr = reinterpret_cast(sharedHandleAddress++); + auto gmmHelper = getGmmHelper(0); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); auto alloc = new IpcImplicitScalingMockGraphicsAllocation(properties.rootDeviceIndex, NEO::AllocationType::BUFFER, - reinterpret_cast(sharedHandleAddress++), + ptr, 0x1000, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); alloc->setGpuBaseAddress(0xabcd); return alloc; } @@ -483,24 +491,32 @@ class MemoryManagerOpenIpcMock : public MemoryManagerIpcMock { if (failOnCreateGraphicsAllocationFromSharedHandle) { return nullptr; } + auto ptr = reinterpret_cast(sharedHandleAddress++); + auto gmmHelper = getGmmHelper(0); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); auto alloc = new IpcImplicitScalingMockGraphicsAllocation(properties.rootDeviceIndex, NEO::AllocationType::BUFFER, - reinterpret_cast(sharedHandleAddress++), + ptr, 0x1000, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); alloc->setGpuBaseAddress(0xabcd); return alloc; } NEO::GraphicsAllocation *createGraphicsAllocationFromNTHandle(void *handle, uint32_t rootDeviceIndex, AllocationType allocType) override { - auto alloc = new NEO::MockGraphicsAllocation(0u, - NEO::AllocationType::BUFFER, - reinterpret_cast(sharedHandleAddress++), - 0x1000, - 0u, - MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + auto ptr = reinterpret_cast(sharedHandleAddress++); + auto gmmHelper = getGmmHelper(0); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); + auto alloc = new IpcImplicitScalingMockGraphicsAllocation(0u, + NEO::AllocationType::BUFFER, + ptr, + 0x1000, + 0u, + MemoryPool::System4KBPages, + MemoryManager::maxOsContextCount, + canonizedGpuAddress); alloc->setGpuBaseAddress(0xabcd); return alloc; }; @@ -606,25 +622,33 @@ class MemoryManagerIpcImplicitScalingMock : public NEO::MemoryManager { void unlockResourceImpl(NEO::GraphicsAllocation &graphicsAllocation) override{}; NEO::GraphicsAllocation *allocateGraphicsMemoryInPreferredPool(const AllocationProperties &properties, const void *hostPtr) override { - auto alloc = new IpcImplicitScalingMockGraphicsAllocation(0, + auto ptr = reinterpret_cast(sharedHandleAddress++); + auto gmmHelper = getGmmHelper(0); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); + auto alloc = new IpcImplicitScalingMockGraphicsAllocation(0u, NEO::AllocationType::BUFFER, - reinterpret_cast(sharedHandleAddress++), + ptr, 0x1000, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); alloc->setGpuBaseAddress(0xabcd); return alloc; } NEO::GraphicsAllocation *allocateGraphicsMemoryWithProperties(const AllocationProperties &properties) override { - auto alloc = new IpcImplicitScalingMockGraphicsAllocation(0, + auto ptr = reinterpret_cast(sharedHandleAddress++); + auto gmmHelper = getGmmHelper(0); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); + auto alloc = new IpcImplicitScalingMockGraphicsAllocation(0u, NEO::AllocationType::BUFFER, - reinterpret_cast(sharedHandleAddress++), + ptr, 0x1000, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); alloc->setGpuBaseAddress(0xabcd); return alloc; } @@ -633,13 +657,17 @@ class MemoryManagerIpcImplicitScalingMock : public NEO::MemoryManager { if (failOnCreateGraphicsAllocationFromSharedHandle) { return nullptr; } - auto alloc = new IpcImplicitScalingMockGraphicsAllocation(0, + auto ptr = reinterpret_cast(sharedHandleAddress++); + auto gmmHelper = getGmmHelper(0); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); + auto alloc = new IpcImplicitScalingMockGraphicsAllocation(0u, NEO::AllocationType::BUFFER, - reinterpret_cast(sharedHandleAddress++), + ptr, 0x1000, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); alloc->setGpuBaseAddress(0xabcd); return alloc; } diff --git a/level_zero/core/test/unit_tests/fixtures/module_fixture.h b/level_zero/core/test/unit_tests/fixtures/module_fixture.h index c5fba2680c..cd122c5044 100644 --- a/level_zero/core/test/unit_tests/fixtures/module_fixture.h +++ b/level_zero/core/test/unit_tests/fixtures/module_fixture.h @@ -61,13 +61,18 @@ struct ModuleImmutableDataFixture : public DeviceFixture { device->getNEODevice()->getMemoryManager()->freeGraphicsMemory(&*isaGraphicsAllocation); isaGraphicsAllocation.release(); } + auto ptr = reinterpret_cast(0x1234); + auto gmmHelper = std::make_unique(nullptr, defaultHwInfo.get()); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); isaGraphicsAllocation.reset(new NEO::MockGraphicsAllocation(0, NEO::AllocationType::KERNEL_ISA, - reinterpret_cast(0x1234), + ptr, 0x1000, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount)); + MemoryManager::maxOsContextCount, + canonizedGpuAddress)); + kernelInfo->kernelAllocation = isaGraphicsAllocation.get(); } void setDevice(L0::Device *inDevice) { @@ -313,13 +318,17 @@ struct ModuleWithZebinFixture : public DeviceFixture { mockKernelDescriptor->kernelMetadata.kernelName = ZebinTestData::ValidEmptyProgram::kernelName; kernelDescriptor = mockKernelDescriptor; this->device = device; + auto ptr = reinterpret_cast(0x1234); + auto gmmHelper = device->getNEODevice()->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); isaGraphicsAllocation.reset(new NEO::MockGraphicsAllocation(0, NEO::AllocationType::KERNEL_ISA, - reinterpret_cast(0x1234), + ptr, 0x1000, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount)); + MemoryManager::maxOsContextCount, + canonizedGpuAddress)); } ~MockImmutableData() override { @@ -337,20 +346,25 @@ struct ModuleWithZebinFixture : public DeviceFixture { void addSegments() { kernelImmDatas.push_back(std::make_unique(device)); + auto ptr = reinterpret_cast(0x1234); + auto gmmHelper = device->getNEODevice()->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); translationUnit->globalVarBuffer = new NEO::MockGraphicsAllocation(0, NEO::AllocationType::GLOBAL_SURFACE, - reinterpret_cast(0x1234), + ptr, 0x1000, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); translationUnit->globalConstBuffer = new NEO::MockGraphicsAllocation(0, NEO::AllocationType::GLOBAL_SURFACE, - reinterpret_cast(0x1234), + ptr, 0x1000, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); translationUnit->programInfo.globalStrings.initData = &strings; translationUnit->programInfo.globalStrings.size = sizeof(strings); diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_2.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_2.cpp index 4858e8f125..323acaf319 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_2.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_2.cpp @@ -214,20 +214,25 @@ HWTEST2_F(CommandListCreate, givenCommandListWhenPageFaultCopyCalledThenappendPa MockCommandListHw cmdList; size_t size = (sizeof(uint32_t) * 4); cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u); + auto ptr = reinterpret_cast(0x1234); + auto gmmHelper = device->getNEODevice()->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); NEO::MockGraphicsAllocation mockAllocationSrc(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); NEO::MockGraphicsAllocation mockAllocationDst(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); cmdList.appendPageFaultCopy(&mockAllocationDst, &mockAllocationSrc, size, false); EXPECT_EQ(cmdList.appendMemoryCopyKernelWithGACalledTimes, 1u); EXPECT_EQ(cmdList.appendMemoryCopyKernelWithGAStatelessCalledTimes, 0u); @@ -237,20 +242,25 @@ HWTEST2_F(CommandListCreate, givenCommandListWhenPageFaultCopyCalledWithCopyEngi MockCommandListHw cmdList; size_t size = (sizeof(uint32_t) * 4); cmdList.initialize(device, NEO::EngineGroupType::Copy, 0u); + auto ptr = reinterpret_cast(0x1234); + auto gmmHelper = device->getNEODevice()->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); NEO::MockGraphicsAllocation mockAllocationSrc(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); NEO::MockGraphicsAllocation mockAllocationDst(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); cmdList.appendPageFaultCopy(&mockAllocationDst, &mockAllocationSrc, size, false); EXPECT_EQ(cmdList.appendMemoryCopyBlitCalledTimes, 1u); } @@ -259,20 +269,25 @@ HWTEST2_F(CommandListCreate, givenCommandListWhenPageFaultCopyCalledThenappendPa MockCommandListHw cmdList; size_t size = ((sizeof(uint32_t) * 4) + 1); cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u); + auto ptr = reinterpret_cast(0x1234); + auto gmmHelper = device->getNEODevice()->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); NEO::MockGraphicsAllocation mockAllocationSrc(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); NEO::MockGraphicsAllocation mockAllocationDst(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); cmdList.appendPageFaultCopy(&mockAllocationDst, &mockAllocationSrc, size, false); EXPECT_EQ(cmdList.appendMemoryCopyKernelWithGACalledTimes, 2u); EXPECT_EQ(cmdList.appendMemoryCopyKernelWithGAStatelessCalledTimes, 0u); @@ -282,20 +297,25 @@ HWTEST2_F(CommandListCreate, givenCommandListWhenPageFaultCopyCalledAndErrorOnMi MockCommandListHw cmdList(true); size_t size = ((sizeof(uint32_t) * 4) + 1); cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u); + auto ptr = reinterpret_cast(0x1234); + auto gmmHelper = device->getNEODevice()->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); NEO::MockGraphicsAllocation mockAllocationSrc(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); NEO::MockGraphicsAllocation mockAllocationDst(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); cmdList.appendPageFaultCopy(&mockAllocationDst, &mockAllocationSrc, size, false); EXPECT_EQ(cmdList.appendMemoryCopyKernelWithGACalledTimes, 1u); EXPECT_EQ(cmdList.appendMemoryCopyKernelWithGAStatelessCalledTimes, 0u); @@ -305,20 +325,25 @@ HWTEST2_F(CommandListCreate, givenCommandListWhenPageFaultCopyCalledWithCopyEngi MockCommandListHw cmdList; size_t size = ((sizeof(uint32_t) * 4) + 1); cmdList.initialize(device, NEO::EngineGroupType::Copy, 0u); + auto ptr = reinterpret_cast(0x1234); + auto gmmHelper = device->getNEODevice()->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); NEO::MockGraphicsAllocation mockAllocationSrc(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); NEO::MockGraphicsAllocation mockAllocationDst(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); cmdList.appendPageFaultCopy(&mockAllocationDst, &mockAllocationSrc, size, false); EXPECT_EQ(cmdList.appendMemoryCopyBlitCalledTimes, 1u); } @@ -327,20 +352,25 @@ HWTEST2_F(CommandListCreate, givenCommandListWhenPageFaultCopyCalledWithCopyEngi MockCommandListHw cmdList(true); size_t size = ((sizeof(uint32_t) * 4) + 1); cmdList.initialize(device, NEO::EngineGroupType::Copy, 0u); + auto ptr = reinterpret_cast(0x1234); + auto gmmHelper = device->getNEODevice()->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); NEO::MockGraphicsAllocation mockAllocationSrc(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); NEO::MockGraphicsAllocation mockAllocationDst(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); cmdList.appendPageFaultCopy(&mockAllocationDst, &mockAllocationSrc, size, false); EXPECT_EQ(cmdList.appendMemoryCopyBlitCalledTimes, 1u); } @@ -349,20 +379,25 @@ HWTEST2_F(CommandListCreate, givenCommandListWhen4GBytePageFaultCopyCalledThenPa MockCommandListHw cmdList; size_t size = 0x100000000; cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u); + auto ptr = reinterpret_cast(0x1234); + auto gmmHelper = device->getNEODevice()->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); NEO::MockGraphicsAllocation mockAllocationSrc(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); NEO::MockGraphicsAllocation mockAllocationDst(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); cmdList.appendPageFaultCopy(&mockAllocationDst, &mockAllocationSrc, size, false); EXPECT_EQ(cmdList.appendMemoryCopyKernelWithGACalledTimes, 1u); EXPECT_EQ(cmdList.appendMemoryCopyKernelWithGAStatelessCalledTimes, 1u); @@ -372,20 +407,25 @@ HWTEST2_F(CommandListCreate, givenCommandListWhen4GBytePageFaultCopyCalledThenPa MockCommandListHw cmdList; size_t size = 0x100000001; cmdList.initialize(device, NEO::EngineGroupType::RenderCompute, 0u); + auto ptr = reinterpret_cast(0x1234); + auto gmmHelper = device->getNEODevice()->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); NEO::MockGraphicsAllocation mockAllocationSrc(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); NEO::MockGraphicsAllocation mockAllocationDst(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); cmdList.appendPageFaultCopy(&mockAllocationDst, &mockAllocationSrc, size, false); EXPECT_EQ(cmdList.appendMemoryCopyKernelWithGACalledTimes, 2u); EXPECT_EQ(cmdList.appendMemoryCopyKernelWithGAStatelessCalledTimes, 2u); @@ -978,20 +1018,25 @@ HWTEST2_F(CommandListCreate, givenCopyCommandListWhenCopyRegionWithinMaxBlitSize Vec3 srcSize = {0x1000, 0x100, 1}; Vec3 dstSize = {0x100, 0x100, 1}; auto size = 0x1000; + auto ptr = reinterpret_cast(0x1234); + auto gmmHelper = device->getNEODevice()->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); NEO::MockGraphicsAllocation mockAllocationSrc(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); NEO::MockGraphicsAllocation mockAllocationDst(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); size_t rowPitch = copySize.x; size_t slicePitch = copySize.x * copySize.y; @@ -1021,20 +1066,25 @@ HWTEST2_F(CommandListCreate, givenCopyCommandListWhenCopyRegionWithinMaxBlitSize Vec3 srcSize = {0x1000, 0x100, 1}; Vec3 dstSize = {0x100, 0x100, 1}; auto size = 0x1000; + auto ptr = reinterpret_cast(0x1234); + auto gmmHelper = device->getNEODevice()->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); NEO::MockGraphicsAllocation mockAllocationSrc(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); NEO::MockGraphicsAllocation mockAllocationDst(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); size_t rowPitch = copySize.x; size_t slicePitch = copySize.x * copySize.y; commandList->appendMemoryCopyBlitRegion(&mockAllocationDst, &mockAllocationSrc, 0, 0, srcRegion, dstRegion, copySize, rowPitch, slicePitch, rowPitch, slicePitch, srcSize, dstSize, nullptr, 0, nullptr); @@ -1062,20 +1112,25 @@ HWTEST2_F(CommandListCreate, givenCopyCommandListWhenCopyRegionGreaterThanMaxBli Vec3 srcSize = {2 * BlitterConstants::maxBlitWidth, 2 * BlitterConstants::maxBlitHeight, 1}; Vec3 dstSize = srcSize; auto size = 0x1000; + auto ptr = reinterpret_cast(0x1234); + auto gmmHelper = device->getNEODevice()->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); NEO::MockGraphicsAllocation mockAllocationSrc(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); NEO::MockGraphicsAllocation mockAllocationDst(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); size_t rowPitch = copySize.x; size_t slicePitch = copySize.x * copySize.y; commandList->appendMemoryCopyBlitRegion(&mockAllocationDst, &mockAllocationSrc, 0, 0, srcRegion, dstRegion, copySize, rowPitch, slicePitch, rowPitch, slicePitch, srcSize, dstSize, nullptr, 0, nullptr); @@ -1177,21 +1232,26 @@ HWTEST2_F(CommandListAppendMemoryCopyBlit, whenAppendMemoryCopyBlitIsAppendedAnd useSize -= sizeof(MI_BATCH_BUFFER_END); commandList->commandContainer.getCommandStream()->getSpace(useSize); + auto ptr = reinterpret_cast(0x1234); + auto gmmHelper = device->getNEODevice()->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); NEO::MockGraphicsAllocation mockAllocationSrc(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); void *srcPtr = reinterpret_cast(mockAllocationSrc.getGpuAddress()); NEO::MockGraphicsAllocation mockAllocationDst(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); void *dstPtr = reinterpret_cast(mockAllocationDst.getGpuAddress()); auto result = commandList->appendMemoryCopy(dstPtr, diff --git a/level_zero/core/test/unit_tests/sources/helper/heap_assigner_l0_tests.cpp b/level_zero/core/test/unit_tests/sources/helper/heap_assigner_l0_tests.cpp index 6f7fa36dfa..207ec55617 100644 --- a/level_zero/core/test/unit_tests/sources/helper/heap_assigner_l0_tests.cpp +++ b/level_zero/core/test/unit_tests/sources/helper/heap_assigner_l0_tests.cpp @@ -73,7 +73,7 @@ TEST_F(AlocationHelperTests, givenLinearStreamAllocationWhenSelectingHeapWithUse DebugManagerStateRestore dbgRestorer; DebugManager.flags.UseExternalAllocatorForSshAndDsh.set(true); std::unique_ptr mockMemoryManager(new MockMemoryManagerAllocationHelper(*device->getNEODevice()->getExecutionEnvironment())); - GraphicsAllocation allocation{0, AllocationType::LINEAR_STREAM, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount}; + GraphicsAllocation allocation{0, AllocationType::LINEAR_STREAM, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu}; allocation.set32BitAllocation(false); EXPECT_EQ(MemoryManager::selectExternalHeap(allocation.isAllocatedInLocalMemoryPool()), mockMemoryManager->selectHeap(&allocation, false, false, false)); diff --git a/opencl/test/unit_test/command_queue/enqueue_read_buffer_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_read_buffer_tests.cpp index 339ca8c4bd..eab3648819 100644 --- a/opencl/test/unit_test/command_queue/enqueue_read_buffer_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_read_buffer_tests.cpp @@ -556,7 +556,7 @@ HWTEST_F(EnqueueReadBufferTypeTest, givenCommandQueueWhenEnqueueReadBufferIsCall HWTEST_F(EnqueueReadBufferTypeTest, givenCommandQueueWhenEnqueueReadBufferWithMapAllocationIsCalledThenItDoesntCallNotifyFunction) { auto mockCmdQ = std::make_unique>(context, pClDevice, nullptr); void *ptr = nonZeroCopyBuffer->getCpuAddressForMemoryTransfer(); - GraphicsAllocation mapAllocation{0, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount}; + GraphicsAllocation mapAllocation{0, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu}; auto retVal = mockCmdQ->enqueueReadBuffer(srcBuffer.get(), CL_TRUE, 0, diff --git a/opencl/test/unit_test/command_queue/enqueue_read_image_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_read_image_tests.cpp index 4192cda3d3..60acbdf7b7 100644 --- a/opencl/test/unit_test/command_queue/enqueue_read_image_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_read_image_tests.cpp @@ -910,7 +910,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{0, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount}; + GraphicsAllocation mapAllocation{0, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu}; EnqueueReadImageHelper<>::enqueueReadImage(mockCmdQ.get(), srcImage.get(), CL_TRUE, origin, region, rowPitch, slicePitch, dstPtr, &mapAllocation); diff --git a/opencl/test/unit_test/kernel/kernel_tests.cpp b/opencl/test/unit_test/kernel/kernel_tests.cpp index ac234f1cca..ddb715dab2 100644 --- a/opencl/test/unit_test/kernel/kernel_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_tests.cpp @@ -845,8 +845,9 @@ TEST_F(KernelGlobalSurfaceTest, givenNDRangeKernelWhenKernelIsCreatedThenGlobalS pKernelInfo->kernelDescriptor.kernelAttributes.simdSize = 32; char buffer[16]; - - GraphicsAllocation gfxAlloc(0, AllocationType::UNKNOWN, buffer, (uint64_t)buffer - 8u, 8, MemoryPool::MemoryNull, 0u); + auto gmmHelper = pDevice->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(buffer)); + GraphicsAllocation gfxAlloc(0, AllocationType::UNKNOWN, buffer, (uint64_t)buffer - 8u, 8, MemoryPool::MemoryNull, 0u, canonizedGpuAddress); uint64_t bufferAddress = gfxAlloc.getGpuAddress(); // create kernel @@ -964,8 +965,9 @@ TEST_F(KernelConstantSurfaceTest, givenNDRangeKernelWhenKernelIsCreatedThenConst pKernelInfo->kernelDescriptor.kernelAttributes.simdSize = 32; char buffer[16]; - - GraphicsAllocation gfxAlloc(0, AllocationType::UNKNOWN, buffer, (uint64_t)buffer - 8u, 8, MemoryPool::MemoryNull, 0u); + auto gmmHelper = pDevice->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(buffer)); + GraphicsAllocation gfxAlloc(0, AllocationType::UNKNOWN, buffer, (uint64_t)buffer - 8u, 8, MemoryPool::MemoryNull, 0u, canonizedGpuAddress); uint64_t bufferAddress = gfxAlloc.getGpuAddress(); // create kernel @@ -2952,8 +2954,10 @@ HWTEST2_F(KernelConstantSurfaceTest, givenKernelWithConstantSurfaceWhenKernelIsC pKernelInfo->setGlobalConstantsSurface(8, 0, 0); char buffer[MemoryConstants::pageSize64k]; - GraphicsAllocation gfxAlloc(0, AllocationType::CONSTANT_SURFACE, buffer, - MemoryConstants::pageSize64k, static_cast(8), MemoryPool::MemoryNull, MemoryManager::maxOsContextCount); + auto gmmHelper = pDevice->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(buffer)); + GraphicsAllocation gfxAlloc(0, AllocationType::CONSTANT_SURFACE, buffer, MemoryConstants::pageSize64k, + static_cast(8), MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, canonizedGpuAddress); MockContext context(pClDevice); MockProgram program(&context, false, toClDeviceVector(*pClDevice)); diff --git a/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp b/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp index e3f597853d..f82d2463fd 100644 --- a/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp +++ b/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp @@ -124,8 +124,10 @@ TEST(GraphicsAllocationTest, WhenAllocationIsCreatedThenItsAddressIsCorrect) { TEST(GraphicsAllocationTest, GivenNonSharedResourceHandleWhenAllocationIsCreatedThenItsAddressIsCorrect) { void *cpuPtr = (void *)0x30000; size_t size = 0x1000; + GmmHelper gmmHelper(nullptr, defaultHwInfo.get()); + auto canonizedGpuAddress = gmmHelper.canonize(castToUint64(cpuPtr)); osHandle sharedHandle = Sharing::nonSharedResource; - GraphicsAllocation gfxAllocation(0, AllocationType::UNKNOWN, cpuPtr, size, sharedHandle, MemoryPool::MemoryNull, 0u); + GraphicsAllocation gfxAllocation(0, AllocationType::UNKNOWN, cpuPtr, size, sharedHandle, MemoryPool::MemoryNull, 0u, canonizedGpuAddress); uint64_t expectedGpuAddr = static_cast(reinterpret_cast(gfxAllocation.getUnderlyingBuffer())); EXPECT_EQ(expectedGpuAddr, gfxAllocation.getGpuAddress()); @@ -2210,7 +2212,9 @@ TEST(GraphicsAllocation, givenSharedHandleBasedConstructorWhenGraphicsAllocation void *addressWithTrailingBitSet = reinterpret_cast(address); uint64_t expectedGpuAddress = 0xf0000000; osHandle sharedHandle{}; - GraphicsAllocation graphicsAllocation(0, AllocationType::UNKNOWN, addressWithTrailingBitSet, 1u, sharedHandle, MemoryPool::MemoryNull, 0u); + GmmHelper gmmHelper(nullptr, defaultHwInfo.get()); + auto canonizedGpuAddress = gmmHelper.canonize(castToUint64(addressWithTrailingBitSet)); + GraphicsAllocation graphicsAllocation(0, AllocationType::UNKNOWN, addressWithTrailingBitSet, 1u, sharedHandle, MemoryPool::MemoryNull, 0u, canonizedGpuAddress); EXPECT_EQ(expectedGpuAddress, graphicsAllocation.getGpuAddress()); } @@ -2575,43 +2579,43 @@ class HeapSelectorTest : public Test { }; TEST_F(HeapSelectorTest, given32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) { - GraphicsAllocation allocation{0, AllocationType::KERNEL_ISA, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount}; + GraphicsAllocation allocation{0, AllocationType::KERNEL_ISA, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu}; allocation.set32BitAllocation(true); EXPECT_EQ(MemoryManager::selectInternalHeap(allocation.isAllocatedInLocalMemoryPool()), memoryManager->selectHeap(&allocation, false, false, false)); - GraphicsAllocation allocation2{0, AllocationType::KERNEL_ISA_INTERNAL, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount}; + GraphicsAllocation allocation2{0, AllocationType::KERNEL_ISA_INTERNAL, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu}; allocation2.set32BitAllocation(true); EXPECT_EQ(MemoryManager::selectInternalHeap(allocation2.isAllocatedInLocalMemoryPool()), memoryManager->selectHeap(&allocation2, false, false, false)); } TEST_F(HeapSelectorTest, givenNon32bitInternalAllocationWhenSelectingHeapThenInternalHeapIsUsed) { - GraphicsAllocation allocation{0, AllocationType::KERNEL_ISA, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount}; + GraphicsAllocation allocation{0, AllocationType::KERNEL_ISA, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu}; allocation.set32BitAllocation(false); EXPECT_EQ(MemoryManager::selectInternalHeap(allocation.isAllocatedInLocalMemoryPool()), memoryManager->selectHeap(&allocation, false, false, false)); - GraphicsAllocation allocation2{0, AllocationType::KERNEL_ISA_INTERNAL, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount}; + GraphicsAllocation allocation2{0, AllocationType::KERNEL_ISA_INTERNAL, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu}; allocation2.set32BitAllocation(false); EXPECT_EQ(MemoryManager::selectInternalHeap(allocation2.isAllocatedInLocalMemoryPool()), memoryManager->selectHeap(&allocation2, false, false, false)); } TEST_F(HeapSelectorTest, given32bitExternalAllocationWhenSelectingHeapThenExternalHeapIsUsed) { - GraphicsAllocation allocation{0, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount}; + GraphicsAllocation allocation{0, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu}; allocation.set32BitAllocation(true); EXPECT_EQ(MemoryManager::selectExternalHeap(allocation.isAllocatedInLocalMemoryPool()), memoryManager->selectHeap(&allocation, false, false, false)); } TEST_F(HeapSelectorTest, givenLimitedAddressSpaceWhenSelectingHeapForExternalAllocationThenStandardHeapIsUsed) { - GraphicsAllocation allocation{0, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount}; + GraphicsAllocation allocation{0, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu}; EXPECT_EQ(HeapIndex::HEAP_STANDARD, memoryManager->selectHeap(&allocation, true, false, false)); } TEST_F(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithPtrThenSvmHeapIsUsed) { - GraphicsAllocation allocation{0, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount}; + GraphicsAllocation allocation{0, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu}; EXPECT_EQ(HeapIndex::HEAP_SVM, memoryManager->selectHeap(&allocation, true, true, false)); } TEST_F(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrAndResourceIs64KSuitableThenStandard64kHeapIsUsed) { - GraphicsAllocation allocation{0, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount}; + GraphicsAllocation allocation{0, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu}; auto rootDeviceEnvironment = platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0].get(); auto gmm = std::make_unique(rootDeviceEnvironment->getGmmHelper(), nullptr, 0, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, StorageInfo{}, true); auto resourceInfo = static_cast(gmm->gmmResourceInfo.get()); @@ -2621,7 +2625,7 @@ TEST_F(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAlloca } TEST_F(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrAndResourceIsNot64KSuitableThenStandardHeapIsUsed) { - GraphicsAllocation allocation{0, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount}; + GraphicsAllocation allocation{0, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu}; auto rootDeviceEnvironment = platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0].get(); auto gmm = std::make_unique(rootDeviceEnvironment->getGmmHelper(), nullptr, 0, 0, GMM_RESOURCE_USAGE_OCL_BUFFER, false, StorageInfo{}, true); auto resourceInfo = static_cast(gmm->gmmResourceInfo.get()); @@ -2889,7 +2893,7 @@ HWTEST_F(PageTableManagerTest, givenPageTableManagerWhenMapAuxGpuVaThenForAllEng memoryManager->getRegisteredEngines()[0].commandStreamReceiver->pageTableManager.reset(mockMngr); memoryManager->getRegisteredEngines()[1].commandStreamReceiver->pageTableManager.reset(mockMngr2); - MockGraphicsAllocation allocation(1u, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount); + MockGraphicsAllocation allocation(1u, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu); MockGmm gmm(executionEnvironment->rootDeviceEnvironments[allocation.getRootDeviceIndex()]->getGmmHelper()); gmm.isCompressionEnabled = true; allocation.setDefaultGmm(&gmm); @@ -2933,7 +2937,7 @@ HWTEST_F(PageTableManagerTest, givenPageTableManagerWhenUpdateAuxTableGmmErrorTh memoryManager->getRegisteredEngines()[0].commandStreamReceiver->pageTableManager.reset(mockMngr); - MockGraphicsAllocation allocation(1u, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount); + MockGraphicsAllocation allocation(1u, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu); MockGmm gmm(executionEnvironment->rootDeviceEnvironments[allocation.getRootDeviceIndex()]->getGmmHelper()); gmm.isCompressionEnabled = true; allocation.setDefaultGmm(&gmm); @@ -2965,7 +2969,7 @@ HWTEST_F(PageTableManagerTest, givenNullPageTableManagerWhenMapAuxGpuVaThenNoThr memoryManager->getRegisteredEngines()[0].commandStreamReceiver->pageTableManager.reset(nullptr); - MockGraphicsAllocation allocation(1u, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount); + MockGraphicsAllocation allocation(1u, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu); MockGmm gmm(executionEnvironment->rootDeviceEnvironments[allocation.getRootDeviceIndex()]->getGmmHelper()); gmm.isCompressionEnabled = true; allocation.setDefaultGmm(&gmm); @@ -2993,7 +2997,7 @@ HWTEST_F(PageTableManagerTest, givenNullPageTableManagerWhenMapAuxGpuVaThenRetur engine.commandStreamReceiver->pageTableManager.reset(nullptr); } - MockGraphicsAllocation allocation(1u, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount); + MockGraphicsAllocation allocation(1u, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu); bool result = memoryManager->mapAuxGpuVA(&allocation); EXPECT_FALSE(result); @@ -3008,7 +3012,7 @@ HWTEST_F(PageTableManagerTest, givenMemoryManagerThatSupportsPageTableManagerWhe } auto memoryManager = new MockMemoryManager(false, false, *executionEnvironment); executionEnvironment->memoryManager.reset(memoryManager); - MockGraphicsAllocation allocation(1u, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount); + MockGraphicsAllocation allocation(1u, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu); MockGmm gmm(executionEnvironment->rootDeviceEnvironments[allocation.getRootDeviceIndex()]->getGmmHelper()); allocation.setDefaultGmm(&gmm); bool mapped = memoryManager->mapAuxGpuVA(&allocation); diff --git a/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp b/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp index 9a65ca88e3..4abe922bac 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_command_stream_tests_1.cpp @@ -232,7 +232,10 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, GivenInvalidAddressWhenFlushingThenSucc //allocate command buffer manually char *commandBuffer = new (std::nothrow) char[1024]; ASSERT_NE(nullptr, commandBuffer); // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks) - DrmAllocation commandBufferAllocation(0, AllocationType::COMMAND_BUFFER, nullptr, commandBuffer, 1024, static_cast(1u), MemoryPool::MemoryNull); + + GmmHelper gmmHelper(nullptr, defaultHwInfo.get()); + auto canonizedGpuAddress = gmmHelper.canonize(castToUint64(commandBuffer)); + DrmAllocation commandBufferAllocation(0, AllocationType::COMMAND_BUFFER, nullptr, commandBuffer, 1024, static_cast(1u), MemoryPool::MemoryNull, canonizedGpuAddress); LinearStream cs(&commandBufferAllocation); CommandStreamReceiverHw::addBatchBufferEnd(cs, nullptr); diff --git a/shared/source/memory_manager/graphics_allocation.cpp b/shared/source/memory_manager/graphics_allocation.cpp index 1fd583c219..b10746e0b6 100644 --- a/shared/source/memory_manager/graphics_allocation.cpp +++ b/shared/source/memory_manager/graphics_allocation.cpp @@ -35,9 +35,9 @@ GraphicsAllocation::GraphicsAllocation(uint32_t rootDeviceIndex, size_t numGmms, } GraphicsAllocation::GraphicsAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, - osHandle sharedHandleIn, MemoryPool pool, size_t maxOsContextCount) + osHandle sharedHandleIn, MemoryPool pool, size_t maxOsContextCount, uint64_t canonizedGpuAddress) : rootDeviceIndex(rootDeviceIndex), - gpuAddress(GmmHelper::canonize(castToUint64(cpuPtrIn))), + gpuAddress(canonizedGpuAddress), size(sizeIn), cpuPtr(cpuPtrIn), memoryPool(pool), diff --git a/shared/source/memory_manager/graphics_allocation.h b/shared/source/memory_manager/graphics_allocation.h index 1d324f3c0b..ceeda5cba9 100644 --- a/shared/source/memory_manager/graphics_allocation.h +++ b/shared/source/memory_manager/graphics_allocation.h @@ -71,14 +71,14 @@ class GraphicsAllocation : public IDNode { : GraphicsAllocation(rootDeviceIndex, 1, allocationType, cpuPtrIn, gpuAddress, baseAddress, sizeIn, pool, maxOsContextCount) {} GraphicsAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, - size_t sizeIn, osHandle sharedHandleIn, MemoryPool pool, size_t maxOsContextCount) - : GraphicsAllocation(rootDeviceIndex, 1, allocationType, cpuPtrIn, sizeIn, sharedHandleIn, pool, maxOsContextCount) {} + size_t sizeIn, osHandle sharedHandleIn, MemoryPool pool, size_t maxOsContextCount, uint64_t canonizedGpuAddress) + : GraphicsAllocation(rootDeviceIndex, 1, allocationType, cpuPtrIn, sizeIn, sharedHandleIn, pool, maxOsContextCount, canonizedGpuAddress) {} GraphicsAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, uint64_t canonizedGpuAddress, uint64_t baseAddress, size_t sizeIn, MemoryPool pool, size_t maxOsContextCount); GraphicsAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, - size_t sizeIn, osHandle sharedHandleIn, MemoryPool pool, size_t maxOsContextCount); + size_t sizeIn, osHandle sharedHandleIn, MemoryPool pool, size_t maxOsContextCount, uint64_t canonizedGpuAddress); uint32_t getRootDeviceIndex() const { return rootDeviceIndex; } void *getUnderlyingBuffer() const { return cpuPtr; } diff --git a/shared/source/memory_manager/os_agnostic_memory_manager.h b/shared/source/memory_manager/os_agnostic_memory_manager.h index 697b17c581..217f7dd485 100644 --- a/shared/source/memory_manager/os_agnostic_memory_manager.h +++ b/shared/source/memory_manager/os_agnostic_memory_manager.h @@ -27,11 +27,11 @@ class MemoryAllocation : public GraphicsAllocation { : GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, cpuPtrIn, canonizedGpuAddress, baseAddress, sizeIn, pool, maxOsContextCount), id(0), uncacheable(false) {} - MemoryAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, MemoryPool pool, size_t maxOsContextCount) - : MemoryAllocation(rootDeviceIndex, 1, allocationType, cpuPtrIn, sizeIn, sharedHandleIn, pool, maxOsContextCount) {} + MemoryAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, MemoryPool pool, size_t maxOsContextCount, uint64_t canonizedGpuAddress) + : MemoryAllocation(rootDeviceIndex, 1, allocationType, cpuPtrIn, sizeIn, sharedHandleIn, pool, maxOsContextCount, canonizedGpuAddress) {} - MemoryAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, MemoryPool pool, size_t maxOsContextCount) - : GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, cpuPtrIn, sizeIn, sharedHandleIn, pool, maxOsContextCount), + MemoryAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandleIn, MemoryPool pool, size_t maxOsContextCount, uint64_t canonizedGpuAddress) + : GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, cpuPtrIn, sizeIn, sharedHandleIn, pool, maxOsContextCount, canonizedGpuAddress), id(0), uncacheable(false) {} MemoryAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *driverAllocatedCpuPointer, void *pMem, uint64_t canonizedGpuAddress, size_t memSize, diff --git a/shared/source/os_interface/linux/drm_allocation.h b/shared/source/os_interface/linux/drm_allocation.h index 9de71e2747..f29e062b98 100644 --- a/shared/source/os_interface/linux/drm_allocation.h +++ b/shared/source/os_interface/linux/drm_allocation.h @@ -33,11 +33,11 @@ class DrmAllocation : public GraphicsAllocation { MemoryUnmapFunction unmapFunction; }; - DrmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObject *bo, void *ptrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool pool) - : DrmAllocation(rootDeviceIndex, 1, allocationType, bo, ptrIn, sizeIn, sharedHandle, pool) {} + DrmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, BufferObject *bo, void *ptrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool pool, uint64_t canonizedGpuAddress) + : DrmAllocation(rootDeviceIndex, 1, allocationType, bo, ptrIn, sizeIn, sharedHandle, pool, canonizedGpuAddress) {} - DrmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, BufferObject *bo, void *ptrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool pool) - : GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, ptrIn, sizeIn, sharedHandle, pool, MemoryManager::maxOsContextCount), bufferObjects(EngineLimits::maxHandleCount) { + DrmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, BufferObject *bo, void *ptrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool pool, uint64_t canonizedGpuAddress) + : GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, ptrIn, sizeIn, sharedHandle, pool, MemoryManager::maxOsContextCount, canonizedGpuAddress), bufferObjects(EngineLimits::maxHandleCount) { bufferObjects[0] = bo; } diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index f7140a2afe..bb5e6dec19 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -809,8 +809,10 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o lock.unlock(); + auto gmmHelper = getGmmHelper(properties.rootDeviceIndex); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(reinterpret_cast(bo->peekAddress()))); auto drmAllocation = new DrmAllocation(properties.rootDeviceIndex, properties.allocationType, bo, reinterpret_cast(bo->peekAddress()), bo->peekSize(), - handle, MemoryPool::SystemCpuInaccessible); + handle, MemoryPool::SystemCpuInaccessible, canonizedGpuAddress); if (requireSpecificBitness && this->force32bitAllocations) { drmAllocation->set32BitAllocation(true); @@ -1904,8 +1906,10 @@ DrmAllocation *DrmMemoryManager::createUSMHostAllocationFromSharedHandle(osHandl auto bo = new BufferObject(&drm, patIndex, openFd.handle, properties.size, maxOsContextCount); bo->setAddress(properties.gpuAddress); + auto gmmHelper = getGmmHelper(properties.rootDeviceIndex); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(reinterpret_cast(bo->peekAddress()))); return new DrmAllocation(properties.rootDeviceIndex, properties.allocationType, bo, reinterpret_cast(bo->peekAddress()), bo->peekSize(), - handle, MemoryPool::SystemCpuInaccessible); + handle, MemoryPool::SystemCpuInaccessible, canonizedGpuAddress); } const bool useBooMmap = drm.getMemoryInfo() && properties.useMmapObject; @@ -1913,8 +1917,10 @@ DrmAllocation *DrmMemoryManager::createUSMHostAllocationFromSharedHandle(osHandl auto bo = new BufferObject(&drm, patIndex, openFd.handle, properties.size, maxOsContextCount); bo->setAddress(properties.gpuAddress); + auto gmmHelper = getGmmHelper(properties.rootDeviceIndex); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(reinterpret_cast(bo->peekAddress()))); return new DrmAllocation(properties.rootDeviceIndex, properties.allocationType, bo, reinterpret_cast(bo->peekAddress()), bo->peekSize(), - handle, MemoryPool::SystemCpuInaccessible); + handle, MemoryPool::SystemCpuInaccessible, canonizedGpuAddress); } auto boHandle = openFd.handle; @@ -1965,8 +1971,10 @@ DrmAllocation *DrmMemoryManager::createUSMHostAllocationFromSharedHandle(osHandl return drmAllocation; } + auto gmmHelper = getGmmHelper(properties.rootDeviceIndex); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(reinterpret_cast(bo->peekAddress()))); return new DrmAllocation(properties.rootDeviceIndex, properties.allocationType, bo, reinterpret_cast(bo->peekAddress()), bo->peekSize(), - handle, MemoryPool::SystemCpuInaccessible); + handle, MemoryPool::SystemCpuInaccessible, canonizedGpuAddress); } } // namespace NEO diff --git a/shared/source/os_interface/windows/wddm_allocation.h b/shared/source/os_interface/windows/wddm_allocation.h index eb0c237f47..8d28dc30d0 100644 --- a/shared/source/os_interface/windows/wddm_allocation.h +++ b/shared/source/os_interface/windows/wddm_allocation.h @@ -36,12 +36,13 @@ class WddmAllocation : public GraphicsAllocation { handles.resize(gmms.size()); } - WddmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandle, MemoryPool pool, size_t maxOsContextCount) - : WddmAllocation(rootDeviceIndex, 1, allocationType, cpuPtrIn, sizeIn, sharedHandle, pool, maxOsContextCount) {} + WddmAllocation(uint32_t rootDeviceIndex, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, osHandle sharedHandle, + MemoryPool pool, size_t maxOsContextCount, uint64_t canonizedGpuAddress) + : WddmAllocation(rootDeviceIndex, 1, allocationType, cpuPtrIn, sizeIn, sharedHandle, pool, maxOsContextCount, canonizedGpuAddress) {} WddmAllocation(uint32_t rootDeviceIndex, size_t numGmms, AllocationType allocationType, void *cpuPtrIn, size_t sizeIn, - osHandle sharedHandle, MemoryPool pool, size_t maxOsContextCount) - : GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, cpuPtrIn, sizeIn, sharedHandle, pool, maxOsContextCount), + osHandle sharedHandle, MemoryPool pool, size_t maxOsContextCount, uint64_t canonizedGpuAddress) + : GraphicsAllocation(rootDeviceIndex, numGmms, allocationType, cpuPtrIn, sizeIn, sharedHandle, pool, maxOsContextCount, canonizedGpuAddress), trimCandidateListPositions(maxOsContextCount, trimListUnusedPosition) { handles.resize(gmms.size()); } diff --git a/shared/source/os_interface/windows/wddm_memory_manager.cpp b/shared/source/os_interface/windows/wddm_memory_manager.cpp index 503a01ebbd..9c09e19e9c 100644 --- a/shared/source/os_interface/windows/wddm_memory_manager.cpp +++ b/shared/source/os_interface/windows/wddm_memory_manager.cpp @@ -431,7 +431,7 @@ bool WddmMemoryManager::isNTHandle(osHandle handle, uint32_t rootDeviceIndex) { } GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handle, bool requireSpecificBitness, bool ntHandle, AllocationType allocationType, uint32_t rootDeviceIndex) { - auto allocation = std::make_unique(rootDeviceIndex, allocationType, nullptr, 0, handle, MemoryPool::SystemCpuInaccessible, maxOsContextCount); + auto allocation = std::make_unique(rootDeviceIndex, allocationType, nullptr, 0, handle, MemoryPool::SystemCpuInaccessible, maxOsContextCount, 0llu); bool status = ntHandle ? getWddm(rootDeviceIndex).openNTHandle(reinterpret_cast(static_cast(handle)), allocation.get()) : getWddm(rootDeviceIndex).openSharedHandle(handle, allocation.get()); diff --git a/shared/test/common/debug_settings/debug_settings_manager_tests.cpp b/shared/test/common/debug_settings/debug_settings_manager_tests.cpp index 41629310bb..dd0acfd019 100644 --- a/shared/test/common/debug_settings/debug_settings_manager_tests.cpp +++ b/shared/test/common/debug_settings/debug_settings_manager_tests.cpp @@ -155,7 +155,7 @@ TEST(DebugSettingsManager, givenPrintDebugSettingsEnabledOnDisabledDebugManagerW } TEST(AllocationInfoLogging, givenBaseGraphicsAllocationWhenGettingImplementationSpecificAllocationInfoThenReturnEmptyInfoString) { - GraphicsAllocation graphicsAllocation(0, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount); + GraphicsAllocation graphicsAllocation(0, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu); EXPECT_STREQ(graphicsAllocation.getAllocationInfoString().c_str(), ""); } diff --git a/shared/test/common/helpers/blit_commands_helper_tests.inl b/shared/test/common/helpers/blit_commands_helper_tests.inl index 921fa9b324..7971e5aecb 100644 --- a/shared/test/common/helpers/blit_commands_helper_tests.inl +++ b/shared/test/common/helpers/blit_commands_helper_tests.inl @@ -33,13 +33,17 @@ class GivenLinearStreamWhenCallDispatchBlitMemoryColorFillThenCorrectDepthIsProg uint32_t streamBuffer[100] = {}; LinearStream stream(streamBuffer, sizeof(streamBuffer)); auto size = 0x1000; + auto ptr = reinterpret_cast(0x1234); + auto gmmHelper = device->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr)); MockGraphicsAllocation mockAllocation(0, AllocationType::INTERNAL_HOST_MEMORY, - reinterpret_cast(0x1234), + ptr, size, 0u, MemoryPool::System4KBPages, - MemoryManager::maxOsContextCount); + MemoryManager::maxOsContextCount, + canonizedGpuAddress); uint32_t patternToCommand[4]; memset(patternToCommand, 4, patternSize); BlitCommandsHelper::dispatchBlitMemoryColorFill(&mockAllocation, 0, patternToCommand, patternSize, stream, mockAllocation.getUnderlyingBufferSize(), *device->getExecutionEnvironment()->rootDeviceEnvironments[device->getRootDeviceIndex()]); diff --git a/shared/test/common/mocks/mock_graphics_allocation.h b/shared/test/common/mocks/mock_graphics_allocation.h index 373782da21..f4234ff702 100644 --- a/shared/test/common/mocks/mock_graphics_allocation.h +++ b/shared/test/common/mocks/mock_graphics_allocation.h @@ -29,7 +29,7 @@ class MockGraphicsAllocation : public MemoryAllocation { using MemoryAllocation::usageInfos; MockGraphicsAllocation() - : MemoryAllocation(0, AllocationType::UNKNOWN, nullptr, 0u, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount) {} + : MemoryAllocation(0, AllocationType::UNKNOWN, nullptr, 0u, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu) {} MockGraphicsAllocation(void *buffer, size_t sizeIn) : MemoryAllocation(0, AllocationType::UNKNOWN, buffer, castToUint64(buffer), 0llu, sizeIn, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount) {} diff --git a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp index fc85adfaec..fe3e81a523 100644 --- a/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp +++ b/shared/test/unit_test/command_stream/command_stream_receiver_tests.cpp @@ -361,8 +361,10 @@ HWTEST_F(CommandStreamReceiverTest, givenGpuHangAndNonEmptyAllocationsListWhenCa auto hostPtr = reinterpret_cast(0x1234); size_t size = 100; - - auto temporaryAllocation = std::make_unique(0, AllocationType::EXTERNAL_HOST_PTR, hostPtr, size, 0, MemoryPool::System4KBPages, MemoryManager::maxOsContextCount); + auto gmmHelper = pDevice->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(hostPtr)); + auto temporaryAllocation = std::make_unique(0, AllocationType::EXTERNAL_HOST_PTR, hostPtr, size, 0, + MemoryPool::System4KBPages, MemoryManager::maxOsContextCount, canonizedGpuAddress); temporaryAllocation->updateTaskCount(0u, 0u); csr.getInternalAllocationStorage()->storeAllocationWithTaskCount(std::move(temporaryAllocation), TEMPORARY_ALLOCATION, 2u); @@ -1382,7 +1384,10 @@ TEST(CommandStreamReceiverSimpleTest, givenMultipleActivePartitionsWhenWaitingFo auto hostPtr = reinterpret_cast(0x1234); size_t size = 100; - auto temporaryAllocation = std::make_unique(0, AllocationType::EXTERNAL_HOST_PTR, hostPtr, size, 0, MemoryPool::System4KBPages, MemoryManager::maxOsContextCount); + auto gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(hostPtr)); + auto temporaryAllocation = std::make_unique(0, AllocationType::EXTERNAL_HOST_PTR, hostPtr, size, 0, + MemoryPool::System4KBPages, MemoryManager::maxOsContextCount, canonizedGpuAddress); temporaryAllocation->updateTaskCount(0u, 0u); csr.getInternalAllocationStorage()->storeAllocationWithTaskCount(std::move(temporaryAllocation), TEMPORARY_ALLOCATION, 2u); @@ -1489,8 +1494,10 @@ struct CreateAllocationForHostSurfaceTest : public ::testing::Test { TEST_F(CreateAllocationForHostSurfaceTest, givenTemporaryAllocationWhenCreateAllocationForHostSurfaceThenReuseTemporaryAllocationWhenSizeAndAddressMatch) { auto hostPtr = reinterpret_cast(0x1234); size_t size = 100; - auto temporaryAllocation = std::make_unique(0, - AllocationType::EXTERNAL_HOST_PTR, hostPtr, size, 0, MemoryPool::System4KBPages, MemoryManager::maxOsContextCount); + auto gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(hostPtr)); + auto temporaryAllocation = std::make_unique(0, AllocationType::EXTERNAL_HOST_PTR, hostPtr, size, 0, + MemoryPool::System4KBPages, MemoryManager::maxOsContextCount, canonizedGpuAddress); auto allocationPtr = temporaryAllocation.get(); temporaryAllocation->updateTaskCount(0u, 0u); commandStreamReceiver->getInternalAllocationStorage()->storeAllocation(std::move(temporaryAllocation), TEMPORARY_ALLOCATION); @@ -1517,8 +1524,10 @@ TEST_F(CreateAllocationForHostSurfaceTest, givenTemporaryAllocationWhenCreateAll mockCsr->osContext = &commandStreamReceiver->getOsContext(); auto hostPtr = reinterpret_cast(0x1234); size_t size = 100; - auto temporaryAllocation = std::make_unique(0, - AllocationType::EXTERNAL_HOST_PTR, hostPtr, size, 0, MemoryPool::System4KBPages, MemoryManager::maxOsContextCount); + auto gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(hostPtr)); + auto temporaryAllocation = std::make_unique(0, AllocationType::EXTERNAL_HOST_PTR, hostPtr, size, 0, + MemoryPool::System4KBPages, MemoryManager::maxOsContextCount, canonizedGpuAddress); auto allocationPtr = temporaryAllocation.get(); temporaryAllocation->updateTaskCount(0u, 0u); mockCsr->getInternalAllocationStorage()->storeAllocation(std::move(temporaryAllocation), TEMPORARY_ALLOCATION); @@ -1534,8 +1543,10 @@ TEST_F(CreateAllocationForHostSurfaceTest, givenTemporaryAllocationWhenCreateAll TEST_F(CreateAllocationForHostSurfaceTest, givenTemporaryAllocationWhenCreateAllocationForHostSurfaceThenAllocTaskCountEqualZero) { auto hostPtr = reinterpret_cast(0x1234); size_t size = 100; - auto temporaryAllocation = std::make_unique(0, - AllocationType::EXTERNAL_HOST_PTR, hostPtr, size, 0, MemoryPool::System4KBPages, MemoryManager::maxOsContextCount); + auto gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper(); + auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(hostPtr)); + auto temporaryAllocation = std::make_unique(0, AllocationType::EXTERNAL_HOST_PTR, hostPtr, size, 0, + MemoryPool::System4KBPages, MemoryManager::maxOsContextCount, canonizedGpuAddress); auto allocationPtr = temporaryAllocation.get(); temporaryAllocation->updateTaskCount(10u, 0u); commandStreamReceiver->getInternalAllocationStorage()->storeAllocation(std::move(temporaryAllocation), TEMPORARY_ALLOCATION); diff --git a/shared/test/unit_test/memory_manager/multi_graphics_allocation_tests.cpp b/shared/test/unit_test/memory_manager/multi_graphics_allocation_tests.cpp index af02c1cfbb..66f06455bf 100644 --- a/shared/test/unit_test/memory_manager/multi_graphics_allocation_tests.cpp +++ b/shared/test/unit_test/memory_manager/multi_graphics_allocation_tests.cpp @@ -21,7 +21,7 @@ using namespace NEO; TEST(MultiGraphicsAllocationTest, whenCreatingMultiGraphicsAllocationThenTheAllocationIsObtainableAsADefault) { GraphicsAllocation graphicsAllocation(1, // rootDeviceIndex AllocationType::BUFFER, - nullptr, 0, 0, MemoryPool::System4KBPages, 0); + nullptr, 0, 0, MemoryPool::System4KBPages, 0, 0llu); MockMultiGraphicsAllocation multiGraphicsAllocation(1); EXPECT_EQ(2u, multiGraphicsAllocation.graphicsAllocations.size()); @@ -37,10 +37,10 @@ TEST(MultiGraphicsAllocationTest, whenCreatingMultiGraphicsAllocationThenTheAllo TEST(MultiGraphicsAllocationTest, givenMultiGraphicsAllocationWhenAddingMultipleGraphicsAllocationsThenTheyAreObtainableByRootDeviceIndex) { GraphicsAllocation graphicsAllocation0(0, // rootDeviceIndex AllocationType::BUFFER, - nullptr, 0, 0, MemoryPool::System4KBPages, 0); + nullptr, 0, 0, MemoryPool::System4KBPages, 0, 0llu); GraphicsAllocation graphicsAllocation1(1, // rootDeviceIndex AllocationType::BUFFER, - nullptr, 0, 0, MemoryPool::System4KBPages, 0); + nullptr, 0, 0, MemoryPool::System4KBPages, 0, 0llu); MockMultiGraphicsAllocation multiGraphicsAllocation(1); @@ -56,7 +56,7 @@ TEST(MultiGraphicsAllocationTest, givenMultiGraphicsAllocationWhenGettingAllocat auto expectedAllocationType = AllocationType::BUFFER; GraphicsAllocation graphicsAllocation(1, // rootDeviceIndex expectedAllocationType, - nullptr, 0, 0, MemoryPool::System4KBPages, 0); + nullptr, 0, 0, MemoryPool::System4KBPages, 0, 0llu); MockMultiGraphicsAllocation multiGraphicsAllocation(1); multiGraphicsAllocation.addAllocation(&graphicsAllocation); @@ -69,7 +69,7 @@ TEST(MultiGraphicsAllocationTest, givenMultiGraphicsAllocationWhenGettingCoheren auto expectedAllocationType = AllocationType::BUFFER; GraphicsAllocation graphicsAllocation(1, // rootDeviceIndex expectedAllocationType, - nullptr, 0, 0, MemoryPool::System4KBPages, 0); + nullptr, 0, 0, MemoryPool::System4KBPages, 0, 0llu); MockMultiGraphicsAllocation multiGraphicsAllocation(1); multiGraphicsAllocation.addAllocation(&graphicsAllocation); @@ -90,7 +90,7 @@ TEST(MultiGraphicsAllocationTest, givenMultiGraphicsAllocationWhenRemovingGraphi uint32_t rootDeviceIndex = 1u; GraphicsAllocation graphicsAllocation(rootDeviceIndex, AllocationType::BUFFER, - nullptr, 0, 0, MemoryPool::System4KBPages, 0); + nullptr, 0, 0, MemoryPool::System4KBPages, 0, 0llu); MockMultiGraphicsAllocation multiGraphicsAllocation(rootDeviceIndex); EXPECT_EQ(2u, multiGraphicsAllocation.graphicsAllocations.size()); diff --git a/shared/test/unit_test/utilities/logger_tests.cpp b/shared/test/unit_test/utilities/logger_tests.cpp index 87eded2b5c..76fbbb403e 100644 --- a/shared/test/unit_test/utilities/logger_tests.cpp +++ b/shared/test/unit_test/utilities/logger_tests.cpp @@ -443,7 +443,7 @@ TEST(AllocationTypeLogging, givenGraphicsAllocationTypeWhenConvertingToStringThe {AllocationType::SW_TAG_BUFFER, "SW_TAG_BUFFER"}}}; for (const auto &[type, str] : allocationTypeValues) { - GraphicsAllocation graphicsAllocation(0, type, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount); + GraphicsAllocation graphicsAllocation(0, type, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu); auto result = getAllocationTypeString(&graphicsAllocation); EXPECT_STREQ(result, str); @@ -455,7 +455,7 @@ TEST(AllocationTypeLoggingSingle, givenGraphicsAllocationTypeWhenConvertingToStr DebugVariables flags; FullyEnabledFileLogger fileLogger(testFile, flags); - GraphicsAllocation graphicsAllocation(0, static_cast(999), nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount); + GraphicsAllocation graphicsAllocation(0, static_cast(999), nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu); auto result = getAllocationTypeString(&graphicsAllocation); @@ -467,7 +467,7 @@ TEST(AllocationTypeLoggingSingle, givenAllocationTypeWhenConvertingToStringThenS DebugVariables flags; FullyEnabledFileLogger fileLogger(testFile, flags); - GraphicsAllocation graphicsAllocation(0, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount); + GraphicsAllocation graphicsAllocation(0, AllocationType::UNKNOWN, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu); for (uint32_t i = 0; i < static_cast(AllocationType::COUNT); i++) { graphicsAllocation.setAllocationType(static_cast(i)); @@ -485,7 +485,7 @@ TEST(AllocationTypeLoggingSingle, givenDebugVariableToCaptureAllocationTypeWhenF FullyEnabledFileLogger fileLogger(testFile, flags); - GraphicsAllocation graphicsAllocation(0, AllocationType::COMMAND_BUFFER, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount); + GraphicsAllocation graphicsAllocation(0, AllocationType::COMMAND_BUFFER, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu); testing::internal::CaptureStdout(); fileLogger.logAllocation(&graphicsAllocation); @@ -503,7 +503,7 @@ TEST(AllocationTypeLoggingSingle, givenLogAllocationTypeWhenLoggingAllocationThe FullyEnabledFileLogger fileLogger(testFile, flags); - GraphicsAllocation graphicsAllocation(0, AllocationType::COMMAND_BUFFER, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount); + GraphicsAllocation graphicsAllocation(0, AllocationType::COMMAND_BUFFER, nullptr, 0, 0, MemoryPool::MemoryNull, MemoryManager::maxOsContextCount, 0llu); // Log file not created bool logFileCreated = fileExists(fileLogger.getLogFileName()); @@ -540,7 +540,7 @@ TEST(MemoryPoolLogging, givenGraphicsMemoryPoolWhenConvertingToStringThenCorrect {MemoryPool::SystemCpuInaccessible, "SystemCpuInaccessible"}}}; for (const auto &[pool, str] : memoryPoolValues) { - GraphicsAllocation graphicsAllocation(0, AllocationType::UNKNOWN, nullptr, 0, 0, pool, MemoryManager::maxOsContextCount); + GraphicsAllocation graphicsAllocation(0, AllocationType::UNKNOWN, nullptr, 0, 0, pool, MemoryManager::maxOsContextCount, 0llu); auto result = getMemoryPoolString(&graphicsAllocation); EXPECT_STREQ(result, str);