From 2fcda0a5287f15850bdf1216ff5276f5461140aa Mon Sep 17 00:00:00 2001 From: Krzysztof Gibala Date: Mon, 25 Apr 2022 19:34:32 +0000 Subject: [PATCH] Refactor: Change decanonize method accessing point Accessing decanonize method as a member of GmmHelper class object Signed-off-by: Krzysztof Gibala --- .../core/source/debugger/debugger_l0.inl | 16 ++++++++------- .../debugger/debugger_l0_tgllp_and_later.inl | 15 +++++++------- level_zero/core/source/kernel/kernel_imp.cpp | 3 ++- .../aub_tests/debugger/debugger_aub_tests.cpp | 7 ++++--- .../test_l0_debugger_sba_tracking.cpp | 20 +++++++++++-------- .../tools/source/debug/debug_session_imp.cpp | 9 +++++---- .../sources/debug/debug_session_tests.cpp | 3 ++- opencl/source/kernel/kernel.cpp | 3 ++- .../aub_mem_dump/aub_alloc_dump_tests.cpp | 7 ++++--- ...and_stream_receiver_flush_task_2_tests.cpp | 16 ++++++++++----- ...ceiver_flush_task_tests_xehp_and_later.cpp | 3 ++- .../unit_test/gen12lp/image_tests_gen12lp.inl | 9 ++++++--- .../unit_test/gmm_helper/gmm_helper_tests.cpp | 8 ++++---- opencl/test/unit_test/kernel/kernel_tests.cpp | 4 +++- .../mem_obj/buffer_tests_pvc_and_later.cpp | 8 +++++--- .../mem_obj/image_tests_xehp_and_later.cpp | 8 ++++++-- .../memory_manager/memory_manager_tests.cpp | 13 +++++++----- ...ory_manager_debug_surface_prelim_tests.cpp | 6 ++++-- .../linux/drm_memory_manager_tests.cpp | 6 ++++-- .../windows/wddm_kmdaf_listener_tests.cpp | 8 ++++++-- .../windows/wddm_memory_manager_tests.cpp | 16 ++++++++++----- .../test/unit_test/program/program_tests.cpp | 3 ++- .../compression_params_tgllp_and_later.inl | 6 ++++-- .../aub_command_stream_receiver_hw.h | 1 + ...mand_stream_receiver_simulated_common_hw.h | 4 +++- ...ream_receiver_simulated_common_hw_base.inl | 4 ++-- .../tbx_command_stream_receiver_hw.h | 1 + .../source/gen8/state_base_address_gen8.cpp | 4 ++-- shared/source/gmm_helper/gmm_helper.cpp | 2 +- .../helpers/state_base_address_base.inl | 2 +- .../state_base_address_xehp_and_later.inl | 2 +- .../os_agnostic_memory_manager.cpp | 7 +++---- .../os_interface/linux/drm_memory_manager.cpp | 9 ++++++--- .../source/os_interface/windows/wddm/wddm.cpp | 3 +-- .../windows/wddm_memory_manager.cpp | 2 +- 35 files changed, 147 insertions(+), 91 deletions(-) diff --git a/level_zero/core/source/debugger/debugger_l0.inl b/level_zero/core/source/debugger/debugger_l0.inl index 633b205526..b32444112d 100644 --- a/level_zero/core/source/debugger/debugger_l0.inl +++ b/level_zero/core/source/debugger/debugger_l0.inl @@ -22,7 +22,9 @@ void DebuggerL0Hw::programSbaTrackingCommands(NEO::LinearStream &cmdS using MI_STORE_REGISTER_MEM = typename GfxFamily::MI_STORE_REGISTER_MEM; using MI_BATCH_BUFFER_START = typename GfxFamily::MI_BATCH_BUFFER_START; using MI_ARB_CHECK = typename GfxFamily::MI_ARB_CHECK; - const auto gpuAddress = NEO::GmmHelper::decanonize(sbaTrackingGpuVa.address); + + const auto gmmHelper = device->getGmmHelper(); + const auto gpuAddress = gmmHelper->decanonize(sbaTrackingGpuVa.address); PRINT_DEBUGGER_INFO_LOG("Debugger: SBA stored ssh = %" SCNx64 " gsba = %" SCNx64 @@ -37,7 +39,7 @@ void DebuggerL0Hw::programSbaTrackingCommands(NEO::LinearStream &cmdS programSbaTrackingCommandsSingleAddressSpace(cmdStream, sba); } else { if (sba.GeneralStateBaseAddress) { - auto generalStateBaseAddress = NEO::GmmHelper::decanonize(sba.GeneralStateBaseAddress); + auto generalStateBaseAddress = gmmHelper->decanonize(sba.GeneralStateBaseAddress); NEO::EncodeStoreMemory::programStoreDataImm(cmdStream, gpuAddress + offsetof(SbaTrackedAddresses, GeneralStateBaseAddress), static_cast(generalStateBaseAddress & 0x0000FFFFFFFFULL), @@ -46,7 +48,7 @@ void DebuggerL0Hw::programSbaTrackingCommands(NEO::LinearStream &cmdS false); } if (sba.SurfaceStateBaseAddress) { - auto surfaceStateBaseAddress = NEO::GmmHelper::decanonize(sba.SurfaceStateBaseAddress); + auto surfaceStateBaseAddress = gmmHelper->decanonize(sba.SurfaceStateBaseAddress); NEO::EncodeStoreMemory::programStoreDataImm(cmdStream, gpuAddress + offsetof(SbaTrackedAddresses, SurfaceStateBaseAddress), static_cast(surfaceStateBaseAddress & 0x0000FFFFFFFFULL), @@ -55,7 +57,7 @@ void DebuggerL0Hw::programSbaTrackingCommands(NEO::LinearStream &cmdS false); } if (sba.DynamicStateBaseAddress) { - auto dynamicStateBaseAddress = NEO::GmmHelper::decanonize(sba.DynamicStateBaseAddress); + auto dynamicStateBaseAddress = gmmHelper->decanonize(sba.DynamicStateBaseAddress); NEO::EncodeStoreMemory::programStoreDataImm(cmdStream, gpuAddress + offsetof(SbaTrackedAddresses, DynamicStateBaseAddress), static_cast(dynamicStateBaseAddress & 0x0000FFFFFFFFULL), @@ -64,7 +66,7 @@ void DebuggerL0Hw::programSbaTrackingCommands(NEO::LinearStream &cmdS false); } if (sba.IndirectObjectBaseAddress) { - auto indirectObjectBaseAddress = NEO::GmmHelper::decanonize(sba.IndirectObjectBaseAddress); + auto indirectObjectBaseAddress = gmmHelper->decanonize(sba.IndirectObjectBaseAddress); NEO::EncodeStoreMemory::programStoreDataImm(cmdStream, gpuAddress + offsetof(SbaTrackedAddresses, IndirectObjectBaseAddress), static_cast(indirectObjectBaseAddress & 0x0000FFFFFFFFULL), @@ -73,7 +75,7 @@ void DebuggerL0Hw::programSbaTrackingCommands(NEO::LinearStream &cmdS false); } if (sba.InstructionBaseAddress) { - auto instructionBaseAddress = NEO::GmmHelper::decanonize(sba.InstructionBaseAddress); + auto instructionBaseAddress = gmmHelper->decanonize(sba.InstructionBaseAddress); NEO::EncodeStoreMemory::programStoreDataImm(cmdStream, gpuAddress + offsetof(SbaTrackedAddresses, InstructionBaseAddress), static_cast(instructionBaseAddress & 0x0000FFFFFFFFULL), @@ -82,7 +84,7 @@ void DebuggerL0Hw::programSbaTrackingCommands(NEO::LinearStream &cmdS false); } if (sba.BindlessSurfaceStateBaseAddress) { - auto bindlessSurfaceStateBaseAddress = NEO::GmmHelper::decanonize(sba.BindlessSurfaceStateBaseAddress); + auto bindlessSurfaceStateBaseAddress = gmmHelper->decanonize(sba.BindlessSurfaceStateBaseAddress); NEO::EncodeStoreMemory::programStoreDataImm(cmdStream, gpuAddress + offsetof(SbaTrackedAddresses, BindlessSurfaceStateBaseAddress), static_cast(bindlessSurfaceStateBaseAddress & 0x0000FFFFFFFFULL), diff --git a/level_zero/core/source/debugger/debugger_l0_tgllp_and_later.inl b/level_zero/core/source/debugger/debugger_l0_tgllp_and_later.inl index 117814515a..93993ed372 100644 --- a/level_zero/core/source/debugger/debugger_l0_tgllp_and_later.inl +++ b/level_zero/core/source/debugger/debugger_l0_tgllp_and_later.inl @@ -34,24 +34,25 @@ void DebuggerL0Hw::programSbaTrackingCommandsSingleAddressSpace(NEO:: UNRECOVERABLE_IF(!singleAddressSpaceSbaTracking); std::vector> fieldOffsetAndValue; + auto gmmHelper = device->getGmmHelper(); if (sba.GeneralStateBaseAddress) { - fieldOffsetAndValue.push_back({offsetof(SbaTrackedAddresses, GeneralStateBaseAddress), NEO::GmmHelper::decanonize(sba.GeneralStateBaseAddress)}); + fieldOffsetAndValue.push_back({offsetof(SbaTrackedAddresses, GeneralStateBaseAddress), gmmHelper->decanonize(sba.GeneralStateBaseAddress)}); } if (sba.SurfaceStateBaseAddress) { - fieldOffsetAndValue.push_back({offsetof(SbaTrackedAddresses, SurfaceStateBaseAddress), NEO::GmmHelper::decanonize(sba.SurfaceStateBaseAddress)}); + fieldOffsetAndValue.push_back({offsetof(SbaTrackedAddresses, SurfaceStateBaseAddress), gmmHelper->decanonize(sba.SurfaceStateBaseAddress)}); } if (sba.DynamicStateBaseAddress) { - fieldOffsetAndValue.push_back({offsetof(SbaTrackedAddresses, DynamicStateBaseAddress), NEO::GmmHelper::decanonize(sba.DynamicStateBaseAddress)}); + fieldOffsetAndValue.push_back({offsetof(SbaTrackedAddresses, DynamicStateBaseAddress), gmmHelper->decanonize(sba.DynamicStateBaseAddress)}); } if (sba.IndirectObjectBaseAddress) { - fieldOffsetAndValue.push_back({offsetof(SbaTrackedAddresses, IndirectObjectBaseAddress), NEO::GmmHelper::decanonize(sba.IndirectObjectBaseAddress)}); + fieldOffsetAndValue.push_back({offsetof(SbaTrackedAddresses, IndirectObjectBaseAddress), gmmHelper->decanonize(sba.IndirectObjectBaseAddress)}); } if (sba.InstructionBaseAddress) { - fieldOffsetAndValue.push_back({offsetof(SbaTrackedAddresses, InstructionBaseAddress), NEO::GmmHelper::decanonize(sba.InstructionBaseAddress)}); + fieldOffsetAndValue.push_back({offsetof(SbaTrackedAddresses, InstructionBaseAddress), gmmHelper->decanonize(sba.InstructionBaseAddress)}); } if (sba.BindlessSurfaceStateBaseAddress) { - fieldOffsetAndValue.push_back({offsetof(SbaTrackedAddresses, BindlessSurfaceStateBaseAddress), NEO::GmmHelper::decanonize(sba.BindlessSurfaceStateBaseAddress)}); + fieldOffsetAndValue.push_back({offsetof(SbaTrackedAddresses, BindlessSurfaceStateBaseAddress), gmmHelper->decanonize(sba.BindlessSurfaceStateBaseAddress)}); } const auto cmdStreamGpuBase = cmdStream.getGpuBase(); const auto cmdStreamCpuBase = reinterpret_cast(cmdStream.getCpuBase()); @@ -156,4 +157,4 @@ void DebuggerL0Hw::programSbaTrackingCommandsSingleAddressSpace(NEO:: } } -} // namespace L0 \ No newline at end of file +} // namespace L0 diff --git a/level_zero/core/source/kernel/kernel_imp.cpp b/level_zero/core/source/kernel/kernel_imp.cpp index 2b6b4b3225..2d86d16030 100644 --- a/level_zero/core/source/kernel/kernel_imp.cpp +++ b/level_zero/core/source/kernel/kernel_imp.cpp @@ -215,7 +215,8 @@ void KernelImmutableData::createRelocatedDebugData(NEO::GraphicsAllocation *glob ze_result_t KernelImp::getBaseAddress(uint64_t *baseAddress) { if (baseAddress) { - *baseAddress = NEO::GmmHelper::decanonize(this->kernelImmData->getKernelInfo()->kernelAllocation->getGpuAddress()); + auto gmmHelper = module->getDevice()->getNEODevice()->getGmmHelper(); + *baseAddress = gmmHelper->decanonize(this->kernelImmData->getKernelInfo()->kernelAllocation->getGpuAddress()); } return ZE_RESULT_SUCCESS; } diff --git a/level_zero/core/test/aub_tests/debugger/debugger_aub_tests.cpp b/level_zero/core/test/aub_tests/debugger/debugger_aub_tests.cpp index 3c137ec34d..d5cc9795f6 100644 --- a/level_zero/core/test/aub_tests/debugger/debugger_aub_tests.cpp +++ b/level_zero/core/test/aub_tests/debugger/debugger_aub_tests.cpp @@ -126,8 +126,9 @@ HWTEST2_F(DebuggerSingleAddressSpaceAub, GivenSingleAddressSpaceWhenCmdListIsExe expectMMIO(CS_GPR_R15 + 4, high); auto instructionHeapBaseAddress = neoDevice->getMemoryManager()->getInternalHeapBaseAddress(device->getRootDeviceIndex(), neoDevice->getMemoryManager()->isLocalMemoryUsedForIsa(neoDevice->getRootDeviceIndex())); - auto dynamicStateBaseAddress = NEO::GmmHelper::decanonize(commandList->commandContainer.getIndirectHeap(HeapType::DYNAMIC_STATE)->getGraphicsAllocation()->getGpuAddress()); - auto surfaceStateBaseAddress = NEO::GmmHelper::decanonize(commandList->commandContainer.getIndirectHeap(HeapType::SURFACE_STATE)->getGraphicsAllocation()->getGpuAddress()); + auto gmmHelper = neoDevice->getGmmHelper(); + auto dynamicStateBaseAddress = gmmHelper->decanonize(commandList->commandContainer.getIndirectHeap(HeapType::DYNAMIC_STATE)->getGraphicsAllocation()->getGpuAddress()); + auto surfaceStateBaseAddress = gmmHelper->decanonize(commandList->commandContainer.getIndirectHeap(HeapType::SURFACE_STATE)->getGraphicsAllocation()->getGpuAddress()); expectMemory(reinterpret_cast(sbaAddress + offsetof(SbaTrackedAddresses, SurfaceStateBaseAddress)), &surfaceStateBaseAddress, sizeof(surfaceStateBaseAddress)); @@ -146,4 +147,4 @@ HWTEST2_F(DebuggerSingleAddressSpaceAub, GivenSingleAddressSpaceWhenCmdListIsExe } } // namespace ult -} // namespace L0 \ No newline at end of file +} // namespace L0 diff --git a/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_sba_tracking.cpp b/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_sba_tracking.cpp index 7675487cbb..b4a7e3d9a0 100644 --- a/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_sba_tracking.cpp +++ b/level_zero/core/test/unit_tests/sources/debugger/test_l0_debugger_sba_tracking.cpp @@ -207,7 +207,8 @@ HWTEST2_F(L0DebuggerTest, givenDebuggingEnabledAndRequiredGsbaWhenCommandListIsE EXPECT_EQ(static_cast(gsbaGpuVa & 0x0000FFFFFFFFULL), cmdSdi->getDataDword0()); EXPECT_EQ(static_cast(gsbaGpuVa >> 32), cmdSdi->getDataDword1()); - auto expectedGpuVa = GmmHelper::decanonize(device->getL0Debugger()->getSbaTrackingGpuVa()) + offsetof(SbaTrackedAddresses, GeneralStateBaseAddress); + auto gmmHelper = neoDevice->getGmmHelper(); + auto expectedGpuVa = gmmHelper->decanonize(device->getL0Debugger()->getSbaTrackingGpuVa()) + offsetof(SbaTrackedAddresses, GeneralStateBaseAddress); EXPECT_EQ(expectedGpuVa, cmdSdi->getAddress()); for (auto i = 0u; i < numCommandLists; i++) { @@ -425,7 +426,8 @@ HWTEST_F(L0DebuggerSimpleTest, givenNonZeroGpuVasWhenProgrammingSbaTrackingThenC expectedGpuVa = debugger->sbaTrackingGpuVa.address + offsetof(SbaTrackedAddresses, DynamicStateBaseAddress); - auto decanonizedAddress = GmmHelper::decanonize(dsba); + auto gmmHelper = neoDevice->getGmmHelper(); + auto decanonizedAddress = gmmHelper->decanonize(dsba); EXPECT_EQ(static_cast(decanonizedAddress & 0x0000FFFFFFFFULL), cmdSdi->getDataDword0()); EXPECT_EQ(static_cast(decanonizedAddress >> 32), cmdSdi->getDataDword1()); EXPECT_EQ(expectedGpuVa, cmdSdi->getAddress()); @@ -493,7 +495,8 @@ HWTEST_F(L0DebuggerSimpleTest, givenCanonizedGpuVasWhenProgrammingSbaTrackingThe ASSERT_NE(cmdList.end(), sdiItor); auto cmdSdi = genCmdCast(*sdiItor); - auto decanonizedAddress = GmmHelper::decanonize(gsba); + auto gmmHelper = neoDevice->getGmmHelper(); + auto decanonizedAddress = gmmHelper->decanonize(gsba); EXPECT_EQ(static_cast(decanonizedAddress & 0x0000FFFFFFFFULL), cmdSdi->getDataDword0()); EXPECT_EQ(static_cast(decanonizedAddress >> 32), cmdSdi->getDataDword1()); EXPECT_EQ(expectedGpuVa, cmdSdi->getAddress()); @@ -503,7 +506,8 @@ HWTEST_F(L0DebuggerSimpleTest, givenCanonizedGpuVasWhenProgrammingSbaTrackingThe cmdSdi = genCmdCast(*sdiItor); expectedGpuVa = debugger->sbaTrackingGpuVa.address + offsetof(SbaTrackedAddresses, SurfaceStateBaseAddress); - decanonizedAddress = GmmHelper::decanonize(ssba); + + decanonizedAddress = gmmHelper->decanonize(ssba); EXPECT_EQ(static_cast(decanonizedAddress & 0x0000FFFFFFFFULL), cmdSdi->getDataDword0()); EXPECT_EQ(static_cast(decanonizedAddress >> 32), cmdSdi->getDataDword1()); EXPECT_EQ(expectedGpuVa, cmdSdi->getAddress()); @@ -513,7 +517,7 @@ HWTEST_F(L0DebuggerSimpleTest, givenCanonizedGpuVasWhenProgrammingSbaTrackingThe cmdSdi = genCmdCast(*sdiItor); expectedGpuVa = debugger->sbaTrackingGpuVa.address + offsetof(SbaTrackedAddresses, DynamicStateBaseAddress); - decanonizedAddress = GmmHelper::decanonize(dsba); + decanonizedAddress = gmmHelper->decanonize(dsba); EXPECT_EQ(static_cast(decanonizedAddress & 0x0000FFFFFFFFULL), cmdSdi->getDataDword0()); EXPECT_EQ(static_cast(decanonizedAddress >> 32), cmdSdi->getDataDword1()); EXPECT_EQ(expectedGpuVa, cmdSdi->getAddress()); @@ -523,7 +527,7 @@ HWTEST_F(L0DebuggerSimpleTest, givenCanonizedGpuVasWhenProgrammingSbaTrackingThe cmdSdi = genCmdCast(*sdiItor); expectedGpuVa = debugger->sbaTrackingGpuVa.address + offsetof(SbaTrackedAddresses, IndirectObjectBaseAddress); - decanonizedAddress = GmmHelper::decanonize(ioba); + decanonizedAddress = gmmHelper->decanonize(ioba); EXPECT_EQ(static_cast(decanonizedAddress & 0x0000FFFFFFFFULL), cmdSdi->getDataDword0()); EXPECT_EQ(static_cast(decanonizedAddress >> 32), cmdSdi->getDataDword1()); EXPECT_EQ(expectedGpuVa, cmdSdi->getAddress()); @@ -533,7 +537,7 @@ HWTEST_F(L0DebuggerSimpleTest, givenCanonizedGpuVasWhenProgrammingSbaTrackingThe cmdSdi = genCmdCast(*sdiItor); expectedGpuVa = debugger->sbaTrackingGpuVa.address + offsetof(SbaTrackedAddresses, InstructionBaseAddress); - decanonizedAddress = GmmHelper::decanonize(iba); + decanonizedAddress = gmmHelper->decanonize(iba); EXPECT_EQ(static_cast(decanonizedAddress & 0x0000FFFFFFFFULL), cmdSdi->getDataDword0()); EXPECT_EQ(static_cast(decanonizedAddress >> 32), cmdSdi->getDataDword1()); EXPECT_EQ(expectedGpuVa, cmdSdi->getAddress()); @@ -543,7 +547,7 @@ HWTEST_F(L0DebuggerSimpleTest, givenCanonizedGpuVasWhenProgrammingSbaTrackingThe cmdSdi = genCmdCast(*sdiItor); expectedGpuVa = debugger->sbaTrackingGpuVa.address + offsetof(SbaTrackedAddresses, BindlessSurfaceStateBaseAddress); - decanonizedAddress = GmmHelper::decanonize(ssba); + decanonizedAddress = gmmHelper->decanonize(ssba); EXPECT_EQ(static_cast(decanonizedAddress & 0x0000FFFFFFFFULL), cmdSdi->getDataDword0()); EXPECT_EQ(static_cast(decanonizedAddress >> 32), cmdSdi->getDataDword1()); EXPECT_EQ(expectedGpuVa, cmdSdi->getAddress()); diff --git a/level_zero/tools/source/debug/debug_session_imp.cpp b/level_zero/tools/source/debug/debug_session_imp.cpp index 0373e91f24..032e4beacf 100644 --- a/level_zero/tools/source/debug/debug_session_imp.cpp +++ b/level_zero/tools/source/debug/debug_session_imp.cpp @@ -802,7 +802,8 @@ ze_result_t DebugSessionImp::readSbaRegisters(ze_device_thread_t thread, uint32_ auto scratchSpacePTSize = hwHelper.getRenderSurfaceStatePitch(renderSurfaceState.data()); auto threadOffset = getPerThreadScratchOffset(scratchSpacePTSize, convertToThreadId(thread)); - auto scratchAllocationBase = NEO::GmmHelper::decanonize(hwHelper.getRenderSurfaceStateBaseAddress(renderSurfaceState.data())); + auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper(); + auto scratchAllocationBase = gmmHelper->decanonize(hwHelper.getRenderSurfaceStateBaseAddress(renderSurfaceState.data())); if (scratchAllocationBase != 0) { ScratchSpaceBaseAddress = threadOffset + scratchAllocationBase; } @@ -987,9 +988,9 @@ ze_result_t DebugSessionImp::writeRegistersImp(ze_device_thread_t thread, uint32 } bool DebugSessionImp::isValidGpuAddress(uint64_t address) { - auto decanonizedAddress = NEO::GmmHelper::decanonize(address); - auto gmm = connectedDevice->getNEODevice()->getGmmHelper(); - bool validAddress = gmm->isValidCanonicalGpuAddress(address); + auto gmmHelper = connectedDevice->getNEODevice()->getGmmHelper(); + auto decanonizedAddress = gmmHelper->decanonize(address); + bool validAddress = gmmHelper->isValidCanonicalGpuAddress(address); if (address == decanonizedAddress || validAddress) { return true; diff --git a/level_zero/tools/test/unit_tests/sources/debug/debug_session_tests.cpp b/level_zero/tools/test/unit_tests/sources/debug/debug_session_tests.cpp index a20505f50d..2ab1f9941e 100644 --- a/level_zero/tools/test/unit_tests/sources/debug/debug_session_tests.cpp +++ b/level_zero/tools/test/unit_tests/sources/debug/debug_session_tests.cpp @@ -2044,7 +2044,8 @@ TEST(DebugSessionTest, givenCanonicalOrDecanonizedAddressWhenCheckingValidAddres EXPECT_TRUE(sessionMock->isValidGpuAddress(address)); - auto decanonized = NEO::GmmHelper::decanonize(address); + auto gmmHelper = neoDevice->getGmmHelper(); + auto decanonized = gmmHelper->decanonize(address); EXPECT_TRUE(sessionMock->isValidGpuAddress(decanonized)); } diff --git a/opencl/source/kernel/kernel.cpp b/opencl/source/kernel/kernel.cpp index d058eb5107..a612d2f947 100644 --- a/opencl/source/kernel/kernel.cpp +++ b/opencl/source/kernel/kernel.cpp @@ -402,6 +402,7 @@ cl_int Kernel::getInfo(cl_kernel_info paramName, size_t paramValueSize, const _cl_context *ctxt; cl_uint refCount = 0; uint64_t nonCannonizedGpuAddress = 0llu; + auto gmmHelper = clDevice.getDevice().getGmmHelper(); switch (paramName) { case CL_KERNEL_FUNCTION_NAME: @@ -443,7 +444,7 @@ cl_int Kernel::getInfo(cl_kernel_info paramName, size_t paramValueSize, srcSize = getKernelHeapSize(); break; case CL_KERNEL_BINARY_GPU_ADDRESS_INTEL: - nonCannonizedGpuAddress = GmmHelper::decanonize(kernelInfo.kernelAllocation->getGpuAddress()); + nonCannonizedGpuAddress = gmmHelper->decanonize(kernelInfo.kernelAllocation->getGpuAddress()); pSrc = &nonCannonizedGpuAddress; srcSize = sizeof(nonCannonizedGpuAddress); break; diff --git a/opencl/test/unit_test/aub_mem_dump/aub_alloc_dump_tests.cpp b/opencl/test/unit_test/aub_mem_dump/aub_alloc_dump_tests.cpp index 9305563e6b..596b088a37 100644 --- a/opencl/test/unit_test/aub_mem_dump/aub_alloc_dump_tests.cpp +++ b/opencl/test/unit_test/aub_mem_dump/aub_alloc_dump_tests.cpp @@ -409,18 +409,19 @@ struct AubSurfaceDumpTests : public AubAllocDumpTests, HWTEST_P(AubSurfaceDumpTests, givenGraphicsAllocationWhenGetDumpSurfaceIsCalledAndDumpFormatIsSpecifiedThenSurfaceInfoIsReturned) { ExecutionEnvironment *executionEnvironment = pDevice->executionEnvironment; MockMemoryManager memoryManager(*executionEnvironment); + auto gmmHelper = pDevice->getRootDeviceEnvironment().getGmmHelper(); if (AubAllocDump::isBufferDumpFormat(dumpFormat)) { auto bufferAllocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize}); ASSERT_NE(nullptr, bufferAllocation); - MockBuffer::setAllocationType(bufferAllocation, pDevice->getRootDeviceEnvironment().getGmmHelper(), isCompressed); + MockBuffer::setAllocationType(bufferAllocation, gmmHelper, isCompressed); std::unique_ptr surfaceInfo(AubAllocDump::getDumpSurfaceInfo(*bufferAllocation, dumpFormat)); if (nullptr != surfaceInfo) { using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; using SURFACE_FORMAT = typename RENDER_SURFACE_STATE::SURFACE_FORMAT; - EXPECT_EQ(GmmHelper::decanonize(bufferAllocation->getGpuAddress()), surfaceInfo->address); + EXPECT_EQ(gmmHelper->decanonize(bufferAllocation->getGpuAddress()), surfaceInfo->address); EXPECT_EQ(static_cast(bufferAllocation->getUnderlyingBufferSize()), surfaceInfo->width); EXPECT_EQ(1u, surfaceInfo->height); EXPECT_EQ(static_cast(bufferAllocation->getUnderlyingBufferSize()), surfaceInfo->pitch); @@ -450,7 +451,7 @@ HWTEST_P(AubSurfaceDumpTests, givenGraphicsAllocationWhenGetDumpSurfaceIsCalledA std::unique_ptr surfaceInfo(AubAllocDump::getDumpSurfaceInfo(*imageAllocation, dumpFormat)); if (nullptr != surfaceInfo) { - EXPECT_EQ(GmmHelper::decanonize(imageAllocation->getGpuAddress()), surfaceInfo->address); + EXPECT_EQ(gmmHelper->decanonize(imageAllocation->getGpuAddress()), surfaceInfo->address); EXPECT_EQ(static_cast(gmm->gmmResourceInfo->getBaseWidth()), surfaceInfo->width); EXPECT_EQ(static_cast(gmm->gmmResourceInfo->getBaseHeight()), surfaceInfo->height); EXPECT_EQ(static_cast(gmm->gmmResourceInfo->getRenderPitch()), surfaceInfo->pitch); diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp index 4c1174c821..218e5d8aff 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_2_tests.cpp @@ -712,7 +712,9 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenTwoConsecu if (sharedDeviceInfo.force32BitAddressess && is64bit) { EXPECT_TRUE(graphicsAllocationScratch->is32BitAllocation()); - EXPECT_EQ(GmmHelper::decanonize(graphicsAllocationScratch->getGpuAddress()) - GSHaddress, graphicsAddress); + + auto gmmHelper = pDevice->getGmmHelper(); + EXPECT_EQ(gmmHelper->decanonize(graphicsAllocationScratch->getGpuAddress()) - GSHaddress, graphicsAddress); } else if (!deviceInfo.svmCapabilities && is64bit) { EXPECT_EQ(ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, mediaVfeState->getScratchSpaceBasePointer()); EXPECT_EQ(GSHaddress + ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, graphicsAllocationScratch->getGpuAddressToPatch()); @@ -824,7 +826,9 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenNdRangeKer if (sharedDeviceInfo.force32BitAddressess && is64bit) { EXPECT_TRUE(graphicsAllocationScratch->is32BitAllocation()); - EXPECT_EQ(GmmHelper::decanonize(graphicsAllocationScratch->getGpuAddress()) - GSHaddress, graphicsAddress); + + auto gmmHelper = pDevice->getGmmHelper(); + EXPECT_EQ(gmmHelper->decanonize(graphicsAllocationScratch->getGpuAddress()) - GSHaddress, graphicsAddress); } else if (!deviceInfo.svmCapabilities && is64bit) { EXPECT_EQ(ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, mediaVfeState->getScratchSpaceBasePointer()); EXPECT_EQ(GSHaddress + ScratchSpaceConstants::scratchSpaceOffsetFor64Bit, graphicsAllocationScratch->getGpuAddressToPatch()); @@ -1203,6 +1207,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenCsrWhenGen uint64_t generalStateBaseAddress = 0xffff800400010000ull; DispatchFlags dispatchFlags = DispatchFlagsHelper::createDefaultDispatchFlags(); + auto gmmHelper = pDevice->getGmmHelper(); typename FamilyType::STATE_BASE_ADDRESS sbaCmd; StateBaseAddressHelper::programStateBaseAddress(&sbaCmd, @@ -1217,14 +1222,14 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenCsrWhenGen 0, true, false, - pDevice->getGmmHelper(), + gmmHelper, false, MemoryCompressionState::NotApplicable, false, 1u); EXPECT_NE(generalStateBaseAddress, sbaCmd.getGeneralStateBaseAddress()); - EXPECT_EQ(GmmHelper::decanonize(generalStateBaseAddress), sbaCmd.getGeneralStateBaseAddress()); + EXPECT_EQ(gmmHelper->decanonize(generalStateBaseAddress), sbaCmd.getGeneralStateBaseAddress()); } HWTEST_F(CommandStreamReceiverFlushTaskTests, givenNonZeroGeneralStateBaseAddressWhenProgrammingIsDisabledThenExpectCommandValueZero) { @@ -1330,7 +1335,8 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, givenSbaProgram EXPECT_TRUE(sbaCmd.getGeneralStateBaseAddressModifyEnable()); EXPECT_TRUE(sbaCmd.getGeneralStateBufferSizeModifyEnable()); - EXPECT_EQ(GmmHelper::decanonize(generalStateBase), sbaCmd.getGeneralStateBaseAddress()); + auto gmmHelper = pDevice->getGmmHelper(); + EXPECT_EQ(gmmHelper->decanonize(generalStateBase), sbaCmd.getGeneralStateBaseAddress()); EXPECT_EQ(0xfffffu, sbaCmd.getGeneralStateBufferSize()); } diff --git a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_tests_xehp_and_later.cpp b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_tests_xehp_and_later.cpp index b3f4f10d43..30587cae7c 100644 --- a/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/command_stream/command_stream_receiver_flush_task_tests_xehp_and_later.cpp @@ -359,7 +359,8 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandStreamReceiverFlushTaskXeHPAndLaterTests, gi EXPECT_TRUE(sbaCmd.getGeneralStateBaseAddressModifyEnable()); EXPECT_TRUE(sbaCmd.getGeneralStateBufferSizeModifyEnable()); if constexpr (is64bit) { - EXPECT_EQ(GmmHelper::decanonize(internalHeapBase), sbaCmd.getGeneralStateBaseAddress()); + auto gmmHelper = pDevice->getGmmHelper(); + EXPECT_EQ(gmmHelper->decanonize(internalHeapBase), sbaCmd.getGeneralStateBaseAddress()); } else { EXPECT_EQ(generalStateBase, sbaCmd.getGeneralStateBaseAddress()); } diff --git a/opencl/test/unit_test/gen12lp/image_tests_gen12lp.inl b/opencl/test/unit_test/gen12lp/image_tests_gen12lp.inl index cd36bc1b03..b4c6d10291 100644 --- a/opencl/test/unit_test/gen12lp/image_tests_gen12lp.inl +++ b/opencl/test/unit_test/gen12lp/image_tests_gen12lp.inl @@ -75,7 +75,8 @@ GEN12LPTEST_F(ImageClearColorFixture, givenImageForGen12LpWhenCanonicalAddresFor EXPECT_NO_THROW(EncodeSurfaceState::setClearColorParams(&surfaceState, gmm)); uint64_t nonCanonicalAddress = ((static_cast(surfaceState.getClearColorAddressHigh()) << 32) | surfaceState.getClearColorAddress()); - EXPECT_EQ(GmmHelper::decanonize(canonicalAddress), nonCanonicalAddress); + auto gmmHelper = context.getDevice(0)->getGmmHelper(); + EXPECT_EQ(gmmHelper->decanonize(canonicalAddress), nonCanonicalAddress); } GEN12LPTEST_F(ImageClearColorFixture, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapabilityAndMCSThenProgramAuxFieldsForCcs) { @@ -119,7 +120,8 @@ GEN12LPTEST_F(gen12LpImageTests, givenCompressionThenSurfaceStateParamsAreSetFor auto surfaceState = FamilyType::cmdInitRenderSurfaceState; auto imageHw = static_cast *>(image.get()); imageHw->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getDefaultGmm()->gmmResourceInfo->getResourceFlags()->Info.RenderCompressed = true; - EncodeSurfaceState::setImageAuxParamsForCCS(&surfaceState, imageHw->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getDefaultGmm()); + EncodeSurfaceState::setImageAuxParamsForCCS(&surfaceState, + imageHw->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getDefaultGmm()); EXPECT_FALSE(surfaceState.getMemoryCompressionEnable()); EXPECT_EQ(surfaceState.getAuxiliarySurfaceMode(), RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E); @@ -151,7 +153,8 @@ GEN12LPTEST_F(gen12LpImageTests, givenMediaCompressionThenSurfaceStateParamsAreS auto imageHw = static_cast *>(image.get()); imageHw->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getDefaultGmm()->gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true; surfaceState.setAuxiliarySurfaceMode(RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E); - EncodeSurfaceState::setImageAuxParamsForCCS(&surfaceState, imageHw->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getDefaultGmm()); + EncodeSurfaceState::setImageAuxParamsForCCS(&surfaceState, + imageHw->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getDefaultGmm()); EXPECT_TRUE(surfaceState.getMemoryCompressionEnable()); EXPECT_EQ(surfaceState.getAuxiliarySurfaceMode(), RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_NONE); diff --git a/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp b/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp index fb710bc9f3..d809dba5e9 100644 --- a/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp +++ b/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp @@ -402,18 +402,18 @@ TEST_F(GmmCanonizeTests, WhenDecanonizingThenCorrectAddressIsReturned) { uint64_t testAddr1 = 0x7777777777777777; uint64_t goodAddr1 = 0x0000777777777777; - EXPECT_EQ(GmmHelper::decanonize(testAddr1), goodAddr1); + EXPECT_EQ(gmmHelper->decanonize(testAddr1), goodAddr1); uint64_t testAddr2 = 0x7FFFFFFFFFFFFFFF; uint64_t goodAddr2 = 0x0000FFFFFFFFFFFF; - EXPECT_EQ(GmmHelper::decanonize(testAddr2), goodAddr2); + EXPECT_EQ(gmmHelper->decanonize(testAddr2), goodAddr2); // 36 bit - also decanonize to 48 bit hwInfo.capabilityTable.gpuAddressSpace = maxNBitValue(36); // 0x0000000FFFFFFFFF; gmmHelper = std::make_unique(nullptr, &hwInfo); - EXPECT_EQ(GmmHelper::decanonize(testAddr1), goodAddr1); - EXPECT_EQ(GmmHelper::decanonize(testAddr2), goodAddr2); + EXPECT_EQ(gmmHelper->decanonize(testAddr1), goodAddr1); + EXPECT_EQ(gmmHelper->decanonize(testAddr2), goodAddr2); } TEST_F(GmmCanonizeTests, WhenCheckingIsValidCanonicalGpuAddressThenOnlyValidAddressesReturnTrue) { diff --git a/opencl/test/unit_test/kernel/kernel_tests.cpp b/opencl/test/unit_test/kernel/kernel_tests.cpp index f9ec3f9c64..5d1e1d6a08 100644 --- a/opencl/test/unit_test/kernel/kernel_tests.cpp +++ b/opencl/test/unit_test/kernel/kernel_tests.cpp @@ -213,7 +213,9 @@ TEST_F(KernelTests, givenBinaryWhenItIsQueriedForGpuAddressThenAbsoluteAddressIs ¶mValueSizeRet); EXPECT_EQ(CL_SUCCESS, retVal); - auto expectedGpuAddress = GmmHelper::decanonize(pKernel->getKernelInfo().kernelAllocation->getGpuAddress()); + + auto gmmHelper = pDevice->getGmmHelper(); + auto expectedGpuAddress = gmmHelper->decanonize(pKernel->getKernelInfo().kernelAllocation->getGpuAddress()); EXPECT_EQ(expectedGpuAddress, paramValue); EXPECT_EQ(paramValueSize, paramValueSizeRet); } diff --git a/opencl/test/unit_test/mem_obj/buffer_tests_pvc_and_later.cpp b/opencl/test/unit_test/mem_obj/buffer_tests_pvc_and_later.cpp index f8e88962d3..95ecb1be9a 100644 --- a/opencl/test/unit_test/mem_obj/buffer_tests_pvc_and_later.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_tests_pvc_and_later.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -51,7 +51,8 @@ HWTEST2_F(PvcAndLaterBufferTests, WhenAllocatingBufferThenGpuAddressIsFromHeapEx auto graphicsAllocation = buffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex()); ASSERT_NE(nullptr, graphicsAllocation); - auto gpuAddress = GmmHelper::decanonize(graphicsAllocation->getGpuAddress()); + auto gmmHelper = context.getDevice(0)->getGmmHelper(); + auto gpuAddress = gmmHelper->decanonize(graphicsAllocation->getGpuAddress()); auto extendedHeapBase = context.memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_EXTENDED); auto extendedHeapLimit = context.memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_EXTENDED); @@ -91,7 +92,8 @@ HWTEST2_F(PvcAndLaterBufferTests, WhenAllocatingRtBufferThenGpuAddressFromHeapSt auto graphicsAllocation = rtBuffer->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex()); ASSERT_NE(nullptr, graphicsAllocation); - auto gpuAddress = GmmHelper::decanonize(graphicsAllocation->getGpuAddress()); + auto gmmHelper = context.getDevice(0)->getGmmHelper(); + auto gpuAddress = gmmHelper->decanonize(graphicsAllocation->getGpuAddress()); auto standard64KbHeapBase = context.memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD64KB); auto standard64KbHeapLimit = context.memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD64KB); diff --git a/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp b/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp index 4ea282e504..a823aaa78f 100644 --- a/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/mem_obj/image_tests_xehp_and_later.cpp @@ -233,8 +233,11 @@ HWTEST2_F(ImageClearColorFixture, givenImageForXeHPAndLaterWhenCanonicalAddresFo auto gmm = imageHw->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getDefaultGmm(); gmm->gmmResourceInfo->getResourceFlags()->Gpu.IndirectClearColor = 1; EXPECT_NO_THROW(EncodeSurfaceState::setClearColorParams(&surfaceState, gmm)); + uint64_t nonCanonicalAddress = ((static_cast(surfaceState.getClearColorAddressHigh()) << 32) | surfaceState.getClearColorAddress()); - EXPECT_EQ(GmmHelper::decanonize(canonicalAddress), nonCanonicalAddress); + auto gmmHelper = context.getDevice(0)->getGmmHelper(); + + EXPECT_EQ(gmmHelper->decanonize(canonicalAddress), nonCanonicalAddress); } HWTEST2_F(XeHPAndLaterImageTests, givenMediaCompressionWhenAppendingNewAllocationThenNotZeroIsSetAsCompressionType, CompressionParamsSupportedMatcher) { @@ -249,7 +252,8 @@ HWTEST2_F(XeHPAndLaterImageTests, givenMediaCompressionWhenAppendingNewAllocatio imageHw->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getDefaultGmm()->gmmResourceInfo->getResourceFlags()->Info.MediaCompressed = true; surfaceState.setAuxiliarySurfaceMode(RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E); - EncodeSurfaceState::setImageAuxParamsForCCS(&surfaceState, imageHw->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getDefaultGmm()); + EncodeSurfaceState::setImageAuxParamsForCCS(&surfaceState, + imageHw->getGraphicsAllocation(context.getDevice(0)->getRootDeviceIndex())->getDefaultGmm()); imageHw->setImageArg(&surfaceState, false, 0, context.getDevice(0)->getRootDeviceIndex(), false); 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 81136840df..687bb81602 100644 --- a/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp +++ b/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp @@ -1371,7 +1371,8 @@ TEST(OsAgnosticMemoryManager, givenEnabledLocalMemoryWhenAllocatingGraphicsMemor auto instructionHeapBaseAddress = memoryManager.getInternalHeapBaseAddress(0, false); - EXPECT_EQ(instructionHeapBaseAddress, GmmHelper::decanonize(allocation->getGpuBaseAddress())); + auto gmmHelper = memoryManager.getGmmHelper(allocation->getRootDeviceIndex()); + EXPECT_EQ(instructionHeapBaseAddress, gmmHelper->decanonize(allocation->getGpuBaseAddress())); memoryManager.freeGraphicsMemory(allocation); } @@ -1391,8 +1392,8 @@ TEST(OsAgnosticMemoryManager, givenForcedSystemMemoryForIsaAndEnabledLocalMemory ASSERT_NE(nullptr, allocation); auto instructionHeapBaseAddress = memoryManager.getInternalHeapBaseAddress(0, false); - - EXPECT_EQ(instructionHeapBaseAddress, GmmHelper::decanonize(allocation->getGpuBaseAddress())); + auto gmmHelper = memoryManager.getGmmHelper(allocation->getRootDeviceIndex()); + EXPECT_EQ(instructionHeapBaseAddress, gmmHelper->decanonize(allocation->getGpuBaseAddress())); memoryManager.freeGraphicsMemory(allocation); } @@ -1644,8 +1645,10 @@ TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerWhenGpuAddressIsReserv OsAgnosticMemoryManager memoryManager(executionEnvironment); auto addressRange = memoryManager.reserveGpuAddress(MemoryConstants::pageSize, 0); - EXPECT_LE(memoryManager.getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD), GmmHelper::decanonize(addressRange.address)); - EXPECT_GT(memoryManager.getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD), GmmHelper::decanonize(addressRange.address)); + auto gmmHelper = memoryManager.getGmmHelper(0); + EXPECT_LE(memoryManager.getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address)); + EXPECT_GT(memoryManager.getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address)); + memoryManager.freeGpuAddress(addressRange, 0); } diff --git a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_debug_surface_prelim_tests.cpp b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_debug_surface_prelim_tests.cpp index 0e2c259ee3..d7a4be273b 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_debug_surface_prelim_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_debug_surface_prelim_tests.cpp @@ -60,8 +60,10 @@ TEST_F(DrmMemoryManagerLocalMemoryWithCustomPrelimMockTest, givenCreateDebugSurf auto gpuAddress = debugSurface->getGpuAddress(); auto gfxPartition = memoryManager->getGfxPartition(0); EXPECT_NE(reinterpret_cast(debugSurface->getUnderlyingBuffer()), gpuAddress); - EXPECT_GE(GmmHelper::decanonize(gpuAddress), gfxPartition->getHeapBase(HeapIndex::HEAP_STANDARD)); - EXPECT_LT(GmmHelper::decanonize(gpuAddress), gfxPartition->getHeapLimit(HeapIndex::HEAP_STANDARD)); + + auto gmmHelper = device.get()->getGmmHelper(); + EXPECT_GE(gmmHelper->decanonize(gpuAddress), gfxPartition->getHeapBase(HeapIndex::HEAP_STANDARD)); + EXPECT_LT(gmmHelper->decanonize(gpuAddress), gfxPartition->getHeapLimit(HeapIndex::HEAP_STANDARD)); auto &storageInfo = debugSurface->storageInfo; auto &bos = debugSurface->getBOs(); diff --git a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp index 8c8ebcbf1c..a787d7b286 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp @@ -255,8 +255,10 @@ TEST_F(DrmMemoryManagerTest, GivenGraphicsAllocationWhenAddAndRemoveAllocationTo TEST_F(DrmMemoryManagerWithExplicitExpectationsTest, givenDrmMemoryManagerWhenGpuAddressIsReservedAndFreedThenAddressFromGfxPartitionIsUsed) { auto memoryManager = std::make_unique(false, true, false, *executionEnvironment); auto addressRange = memoryManager->reserveGpuAddress(MemoryConstants::pageSize, 0); - EXPECT_LE(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD), GmmHelper::decanonize(addressRange.address)); - EXPECT_GT(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD), GmmHelper::decanonize(addressRange.address)); + auto gmmHelper = memoryManager->getGmmHelper(0); + + EXPECT_LE(memoryManager->getGfxPartition(0)->getHeapBase(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address)); + EXPECT_GT(memoryManager->getGfxPartition(0)->getHeapLimit(HeapIndex::HEAP_STANDARD), gmmHelper->decanonize(addressRange.address)); memoryManager->freeGpuAddress(addressRange, 0); } diff --git a/opencl/test/unit_test/os_interface/windows/wddm_kmdaf_listener_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm_kmdaf_listener_tests.cpp index 5fe326003d..b563ae71d6 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm_kmdaf_listener_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm_kmdaf_listener_tests.cpp @@ -93,7 +93,9 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenMapGpuVirtualAddressIsCalledThenKmDaf EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hAdapter); EXPECT_EQ(wddmWithKmDafMock->getDeviceHandle(), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hDevice); EXPECT_EQ(ALLOCATION_HANDLE, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hAllocation); - EXPECT_EQ(GmmHelper::decanonize(gpuPtr), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.gpuVirtualAddress); + + auto gmmHelper = rootDeviceEnvironment->gmmHelper.get(); + EXPECT_EQ(gmmHelper->decanonize(gpuPtr), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.gpuVirtualAddress); EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.pfnEscape); } @@ -184,7 +186,9 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationsAndMapGpuVaIsCalledT EXPECT_EQ(wddmWithKmDafMock->getAdapter(), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hAdapter); EXPECT_EQ(wddmWithKmDafMock->getDeviceHandle(), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hDevice); EXPECT_EQ(osHandle.handle, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.hAllocation); - EXPECT_EQ(GmmHelper::decanonize(osHandle.gpuPtr), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.gpuVirtualAddress); + + auto gmmHelper = rootDeviceEnvironment->gmmHelper.get(); + EXPECT_EQ(gmmHelper->decanonize(osHandle.gpuPtr), wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.gpuVirtualAddress); EXPECT_EQ(wddmWithKmDafMock->getGdi()->escape, wddmWithKmDafMock->getKmDafListenerMock().notifyMapGpuVAParametrization.pfnEscape); } diff --git a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp index 4c12e04a80..86c68deeaa 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp @@ -550,8 +550,11 @@ TEST_F(WddmMemoryManagerSimpleTest, givenNonZeroFenceValueOnSomeOfMultipleEngine TEST_F(WddmMemoryManagerSimpleTest, givenWddmMemoryManagerWhenGpuAddressIsReservedAndFreedThenAddressRangeIsZero) { auto addressRange = memoryManager->reserveGpuAddress(MemoryConstants::pageSize, 0); - EXPECT_EQ(0u, GmmHelper::decanonize(addressRange.address)); + auto gmmHelper = memoryManager->getGmmHelper(0); + + EXPECT_EQ(0u, gmmHelper->decanonize(addressRange.address)); EXPECT_EQ(0u, addressRange.size); + memoryManager->freeGpuAddress(addressRange, 0); } @@ -852,8 +855,10 @@ HWTEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenAllocateGraphicsMemory EXPECT_TRUE(allocation->getDefaultGmm()->isCompressionEnabled); if ((is32bit || rootDeviceEnvironment->isFullRangeSvm()) && allocation->getDefaultGmm()->gmmResourceInfo->is64KBPageSuitable()) { - EXPECT_GE(GmmHelper::decanonize(allocation->getGpuAddress()), standard64kbRangeMinimumAddress); - EXPECT_LE(GmmHelper::decanonize(allocation->getGpuAddress()), standard64kbRangeMaximumAddress); + auto gmmHelper = memoryManager->getGmmHelper(0); + + EXPECT_GE(gmmHelper->decanonize(allocation->getGpuAddress()), standard64kbRangeMinimumAddress); + EXPECT_LE(gmmHelper->decanonize(allocation->getGpuAddress()), standard64kbRangeMaximumAddress); } memoryManager->freeGraphicsMemory(allocation); @@ -908,9 +913,10 @@ HWTEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenAllocateGraphicsMemory EXPECT_FALSE(memoryManager->allocationGraphicsMemory64kbCreated); EXPECT_FALSE(allocation->getDefaultGmm()->isCompressionEnabled); if (is32bit || rootDeviceEnvironment->isFullRangeSvm()) { + auto gmmHelper = memoryManager->getGmmHelper(0); - EXPECT_GE(GmmHelper::decanonize(allocation->getGpuAddress()), svmRangeMinimumAddress); - EXPECT_LE(GmmHelper::decanonize(allocation->getGpuAddress()), svmRangeMaximumAddress); + EXPECT_GE(gmmHelper->decanonize(allocation->getGpuAddress()), svmRangeMinimumAddress); + EXPECT_LE(gmmHelper->decanonize(allocation->getGpuAddress()), svmRangeMaximumAddress); } memoryManager->freeGraphicsMemory(allocation); } diff --git a/opencl/test/unit_test/program/program_tests.cpp b/opencl/test/unit_test/program/program_tests.cpp index 9b8c4e32e6..ee0677e21a 100644 --- a/opencl/test/unit_test/program/program_tests.cpp +++ b/opencl/test/unit_test/program/program_tests.cpp @@ -592,7 +592,8 @@ TEST_F(ProgramFromBinaryTest, givenProgramWhenItIsBeingBuildThenItContainsGraphi EXPECT_NE(kernelInfo->heapInfo.pKernelHeap, kernelIsa); EXPECT_EQ(0, memcmp(kernelIsa, kernelInfo->heapInfo.pKernelHeap, kernelInfo->heapInfo.KernelHeapSize)); auto rootDeviceIndex = graphicsAllocation->getRootDeviceIndex(); - EXPECT_EQ(GmmHelper::decanonize(graphicsAllocation->getGpuBaseAddress()), pDevice->getMemoryManager()->getInternalHeapBaseAddress(rootDeviceIndex, graphicsAllocation->isAllocatedInLocalMemoryPool())); + auto gmmHelper = pDevice->getGmmHelper(); + EXPECT_EQ(gmmHelper->decanonize(graphicsAllocation->getGpuBaseAddress()), pDevice->getMemoryManager()->getInternalHeapBaseAddress(rootDeviceIndex, graphicsAllocation->isAllocatedInLocalMemoryPool())); } TEST_F(ProgramFromBinaryTest, whenProgramIsBeingRebuildThenOutdatedGlobalBuffersAreFreed) { diff --git a/shared/source/command_container/image_surface_state/compression_params_tgllp_and_later.inl b/shared/source/command_container/image_surface_state/compression_params_tgllp_and_later.inl index 5d09916b22..b5e5291cff 100644 --- a/shared/source/command_container/image_surface_state/compression_params_tgllp_and_later.inl +++ b/shared/source/command_container/image_surface_state/compression_params_tgllp_and_later.inl @@ -16,8 +16,10 @@ void EncodeSurfaceState::setClearColorParams(R_SURFACE_STATE *surfaceSta if (gmm->gmmResourceInfo->getResourceFlags()->Gpu.IndirectClearColor) { surfaceState->setClearValueAddressEnable(true); - uint64_t clearColorAddress = gmm->getGmmHelper()->decanonize(surfaceState->getSurfaceBaseAddress() + - gmm->gmmResourceInfo->getUnifiedAuxSurfaceOffset(GMM_UNIFIED_AUX_TYPE::GMM_AUX_CC)); + auto gmmHelper = gmm->getGmmHelper(); + uint64_t clearColorAddress = gmmHelper->decanonize(surfaceState->getSurfaceBaseAddress() + + gmm->gmmResourceInfo->getUnifiedAuxSurfaceOffset(GMM_UNIFIED_AUX_TYPE::GMM_AUX_CC)); + surfaceState->setClearColorAddress(static_cast(clearColorAddress & 0xFFFFFFFFULL)); surfaceState->setClearColorAddressHigh(static_cast(clearColorAddress >> 32)); } diff --git a/shared/source/command_stream/aub_command_stream_receiver_hw.h b/shared/source/command_stream/aub_command_stream_receiver_hw.h index f8748755fd..a9889f4bd7 100644 --- a/shared/source/command_stream/aub_command_stream_receiver_hw.h +++ b/shared/source/command_stream/aub_command_stream_receiver_hw.h @@ -33,6 +33,7 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw::initAdditionalMMIO; using CommandStreamReceiverSimulatedCommonHw::aubManager; using CommandStreamReceiverSimulatedCommonHw::hardwareContextController; diff --git a/shared/source/command_stream/command_stream_receiver_simulated_common_hw.h b/shared/source/command_stream/command_stream_receiver_simulated_common_hw.h index 0b19697850..6dd78bcf60 100644 --- a/shared/source/command_stream/command_stream_receiver_simulated_common_hw.h +++ b/shared/source/command_stream/command_stream_receiver_simulated_common_hw.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -33,6 +33,8 @@ class CommandStreamReceiverSimulatedCommonHw : public CommandStreamReceiverHw::peekExecutionEnvironment; + CommandStreamReceiverSimulatedCommonHw(ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex, const DeviceBitfield deviceBitfield); diff --git a/shared/source/command_stream/command_stream_receiver_simulated_common_hw_base.inl b/shared/source/command_stream/command_stream_receiver_simulated_common_hw_base.inl index 99d574a372..25ab86ab14 100644 --- a/shared/source/command_stream/command_stream_receiver_simulated_common_hw_base.inl +++ b/shared/source/command_stream/command_stream_receiver_simulated_common_hw_base.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2021 Intel Corporation + * Copyright (C) 2019-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -47,7 +47,7 @@ void CommandStreamReceiverSimulatedCommonHw::setupContext(OsContext & template bool CommandStreamReceiverSimulatedCommonHw::getParametersForWriteMemory(GraphicsAllocation &graphicsAllocation, uint64_t &gpuAddress, void *&cpuAddress, size_t &size) const { cpuAddress = graphicsAllocation.getUnderlyingBuffer(); - gpuAddress = GmmHelper::decanonize(graphicsAllocation.getGpuAddress()); + gpuAddress = peekExecutionEnvironment().rootDeviceEnvironments[graphicsAllocation.getRootDeviceIndex()].get()->gmmHelper.get()->decanonize(graphicsAllocation.getGpuAddress()); size = graphicsAllocation.getUnderlyingBufferSize(); if (graphicsAllocation.isCompressionEnabled()) { diff --git a/shared/source/command_stream/tbx_command_stream_receiver_hw.h b/shared/source/command_stream/tbx_command_stream_receiver_hw.h index a03b193a22..5a5cbd1fcd 100644 --- a/shared/source/command_stream/tbx_command_stream_receiver_hw.h +++ b/shared/source/command_stream/tbx_command_stream_receiver_hw.h @@ -40,6 +40,7 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw::hardwareContextController; using CommandStreamReceiverSimulatedCommonHw::engineInfo; using CommandStreamReceiverSimulatedCommonHw::stream; + using CommandStreamReceiverSimulatedCommonHw::peekExecutionEnvironment; SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override; diff --git a/shared/source/gen8/state_base_address_gen8.cpp b/shared/source/gen8/state_base_address_gen8.cpp index 0813a3c7eb..2f4af702d2 100644 --- a/shared/source/gen8/state_base_address_gen8.cpp +++ b/shared/source/gen8/state_base_address_gen8.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -64,7 +64,7 @@ void StateBaseAddressHelper::programStateBaseAddress( stateBaseAddress->setGeneralStateBaseAddressModifyEnable(true); stateBaseAddress->setGeneralStateBufferSizeModifyEnable(true); // GSH must be set to 0 for stateless - stateBaseAddress->setGeneralStateBaseAddress(GmmHelper::decanonize(generalStateBase)); + stateBaseAddress->setGeneralStateBaseAddress(gmmHelper->decanonize(generalStateBase)); stateBaseAddress->setGeneralStateBufferSize(0xfffff); } diff --git a/shared/source/gmm_helper/gmm_helper.cpp b/shared/source/gmm_helper/gmm_helper.cpp index e99ecfcf97..e56c44c2f6 100644 --- a/shared/source/gmm_helper/gmm_helper.cpp +++ b/shared/source/gmm_helper/gmm_helper.cpp @@ -48,7 +48,7 @@ GmmHelper::GmmHelper(OSInterface *osInterface, const HardwareInfo *pHwInfo) : hw } bool GmmHelper::isValidCanonicalGpuAddress(uint64_t address) { - auto decanonizedAddress = NEO::GmmHelper::decanonize(address); + auto decanonizedAddress = this->decanonize(address); auto canonizedAddress = this->canonize(decanonizedAddress); if (address == canonizedAddress) { diff --git a/shared/source/helpers/state_base_address_base.inl b/shared/source/helpers/state_base_address_base.inl index 7195dfc3f8..91e0723ab5 100644 --- a/shared/source/helpers/state_base_address_base.inl +++ b/shared/source/helpers/state_base_address_base.inl @@ -86,7 +86,7 @@ void StateBaseAddressHelper::programStateBaseAddress( stateBaseAddress->setGeneralStateBaseAddressModifyEnable(true); stateBaseAddress->setGeneralStateBufferSizeModifyEnable(true); // GSH must be set to 0 for stateless - stateBaseAddress->setGeneralStateBaseAddress(GmmHelper::decanonize(generalStateBase)); + stateBaseAddress->setGeneralStateBaseAddress(gmmHelper->decanonize(generalStateBase)); stateBaseAddress->setGeneralStateBufferSize(0xfffff); } diff --git a/shared/source/helpers/state_base_address_xehp_and_later.inl b/shared/source/helpers/state_base_address_xehp_and_later.inl index 88368c46a7..f4aced81b6 100644 --- a/shared/source/helpers/state_base_address_xehp_and_later.inl +++ b/shared/source/helpers/state_base_address_xehp_and_later.inl @@ -41,7 +41,7 @@ void StateBaseAddressHelper::appendStateBaseAddressParameters( using STATE_BASE_ADDRESS = typename GfxFamily::STATE_BASE_ADDRESS; if (setGeneralStateBaseAddress && is64bit) { - stateBaseAddress->setGeneralStateBaseAddress(GmmHelper::decanonize(internalHeapBase)); + stateBaseAddress->setGeneralStateBaseAddress(gmmHelper->decanonize(internalHeapBase)); } if (overrideBindlessSurfaceStateBase && ssh) { diff --git a/shared/source/memory_manager/os_agnostic_memory_manager.cpp b/shared/source/memory_manager/os_agnostic_memory_manager.cpp index fe3f2ab5bb..459beb4397 100644 --- a/shared/source/memory_manager/os_agnostic_memory_manager.cpp +++ b/shared/source/memory_manager/os_agnostic_memory_manager.cpp @@ -288,9 +288,9 @@ void OsAgnosticMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllo delete gfxAllocation; return; } - auto memoryAllocation = static_cast(gfxAllocation); auto sizeToFree = memoryAllocation->sizeToFree; + auto rootDeviceIndex = gfxAllocation->getRootDeviceIndex(); if (sizeToFree) { auto gpuAddressToFree = GmmHelper::decanonize(memoryAllocation->getGpuAddress()) & ~MemoryConstants::pageMask; @@ -303,8 +303,6 @@ void OsAgnosticMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllo releaseReservedCpuAddressRange(gfxAllocation->getReservedAddressPtr(), gfxAllocation->getReservedAddressSize(), gfxAllocation->getRootDeviceIndex()); } - auto rootDeviceIndex = gfxAllocation->getRootDeviceIndex(); - if (executionEnvironment.rootDeviceEnvironments.size() > rootDeviceIndex) { auto aubCenter = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->aubCenter.get(); if (aubCenter && aubCenter->getAubManager() && DebugManager.flags.EnableFreeMemory.get()) { @@ -453,7 +451,8 @@ AddressRange OsAgnosticMemoryManager::reserveGpuAddress(size_t size, uint32_t ro void OsAgnosticMemoryManager::freeGpuAddress(AddressRange addressRange, uint32_t rootDeviceIndex) { uint64_t graphicsAddress = addressRange.address; - graphicsAddress = GmmHelper::decanonize(graphicsAddress); + auto gmmHelper = getGmmHelper(rootDeviceIndex); + graphicsAddress = gmmHelper->decanonize(graphicsAddress); auto gfxPartition = getGfxPartition(rootDeviceIndex); gfxPartition->freeGpuAddressRange(graphicsAddress, addressRange.size); } diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index 253ad0146e..378f1925cb 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -209,7 +209,8 @@ uint64_t DrmMemoryManager::acquireGpuRange(size_t &size, uint32_t rootDeviceInde void DrmMemoryManager::releaseGpuRange(void *address, size_t unmapSize, uint32_t rootDeviceIndex) { uint64_t graphicsAddress = static_cast(reinterpret_cast(address)); - graphicsAddress = GmmHelper::decanonize(graphicsAddress); + auto gmmHelper = getGmmHelper(rootDeviceIndex); + graphicsAddress = gmmHelper->decanonize(graphicsAddress); auto gfxPartition = getGfxPartition(rootDeviceIndex); gfxPartition->freeGpuAddressRange(graphicsAddress, unmapSize); } @@ -1415,7 +1416,8 @@ void DrmMemoryManager::cleanupBeforeReturn(const AllocationData &allocationData, for (auto handleId = 0u; handleId < allocationData.storageInfo.getNumBanks(); handleId++) { delete graphicsAllocation->getGmm(handleId); } - gfxPartition->freeGpuAddressRange(GmmHelper::decanonize(gpuAddress), sizeAllocated); + auto gmmHelper = getGmmHelper(allocationData.rootDeviceIndex); + gfxPartition->freeGpuAddressRange(gmmHelper->decanonize(gpuAddress), sizeAllocated); } GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const AllocationData &allocationData, AllocationStatus &status) { @@ -1492,7 +1494,8 @@ GraphicsAllocation *DrmMemoryManager::allocateGraphicsMemoryInDevicePool(const A for (auto handleId = 0u; handleId < allocationData.storageInfo.getNumBanks(); handleId++) { delete allocation->getGmm(handleId); } - gfxPartition->freeGpuAddressRange(GmmHelper::decanonize(gpuAddress), sizeAllocated); + auto gmmHelper = getGmmHelper(allocationData.rootDeviceIndex); + gfxPartition->freeGpuAddressRange(gmmHelper->decanonize(gpuAddress), sizeAllocated); status = AllocationStatus::Error; return nullptr; } diff --git a/shared/source/os_interface/windows/wddm/wddm.cpp b/shared/source/os_interface/windows/wddm/wddm.cpp index 5d86a72ea9..3c714db1e7 100644 --- a/shared/source/os_interface/windows/wddm/wddm.cpp +++ b/shared/source/os_interface/windows/wddm/wddm.cpp @@ -487,9 +487,8 @@ bool Wddm::freeGpuVirtualAddress(D3DGPU_VIRTUAL_ADDRESS &gpuPtr, uint64_t size) NTSTATUS status = STATUS_SUCCESS; D3DKMT_FREEGPUVIRTUALADDRESS FreeGPUVA = {}; FreeGPUVA.hAdapter = getAdapter(); - FreeGPUVA.BaseAddress = GmmHelper::decanonize(gpuPtr); + FreeGPUVA.BaseAddress = rootDeviceEnvironment.getGmmHelper()->decanonize(gpuPtr); FreeGPUVA.Size = size; - status = getGdi()->freeGpuVirtualAddress(&FreeGPUVA); gpuPtr = static_cast(0); diff --git a/shared/source/os_interface/windows/wddm_memory_manager.cpp b/shared/source/os_interface/windows/wddm_memory_manager.cpp index 1c60ade51b..f42d1fb962 100644 --- a/shared/source/os_interface/windows/wddm_memory_manager.cpp +++ b/shared/source/os_interface/windows/wddm_memory_manager.cpp @@ -797,7 +797,7 @@ bool WddmMemoryManager::mapMultiHandleAllocationWithRetry(WddmAllocation *alloca wddm.destroyAllocations(&allocation->getHandles()[0], allocation->getNumGmms(), allocation->resourceHandle); return false; } - gpuAddress = GmmHelper::decanonize(gpuAddress); + gpuAddress = getGmmHelper(allocation->getRootDeviceIndex())->decanonize(gpuAddress); UNRECOVERABLE_IF(addressToMap != gpuAddress); addressToMap += allocation->getGmm(currentHandle)->gmmResourceInfo->getSizeAllocation(); }