diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.h b/level_zero/core/source/cmdlist/cmdlist_hw.h index 7159adcda0..742d1fe56a 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.h +++ b/level_zero/core/source/cmdlist/cmdlist_hw.h @@ -374,13 +374,7 @@ struct CommandListCoreFamily : public CommandListImp { bool isAllocationImported(NEO::GraphicsAllocation *gpuAllocation, NEO::SVMAllocsManager *svmManager) const; static constexpr bool checkIfAllocationImportedRequired(); - bool isKernelUncachedMocsRequired(bool kernelState) { - this->containsStatelessUncachedResource |= kernelState; - if (this->stateBaseAddressTracking) { - return false; - } - return this->containsStatelessUncachedResource; - } + bool isKernelUncachedMocsRequired(bool kernelState); bool isUsingSystemAllocation(const NEO::AllocationType &allocType) const { return ((allocType == NEO::AllocationType::bufferHostMemory) || diff --git a/level_zero/core/source/cmdlist/cmdlist_hw.inl b/level_zero/core/source/cmdlist/cmdlist_hw.inl index b3c50a3959..16101b4c63 100644 --- a/level_zero/core/source/cmdlist/cmdlist_hw.inl +++ b/level_zero/core/source/cmdlist/cmdlist_hw.inl @@ -4757,4 +4757,16 @@ bool CommandListCoreFamily::isAllocationImported(NEO::GraphicsAll return false; } +template +bool CommandListCoreFamily::isKernelUncachedMocsRequired(bool kernelState) { + this->containsStatelessUncachedResource |= kernelState; + auto &productHelper = this->device->getNEODevice()->getProductHelper(); + auto &rootDeviceEnvironment = this->device->getNEODevice()->getRootDeviceEnvironment(); + + if (this->stateBaseAddressTracking || productHelper.deferMOCSToPatIndex(rootDeviceEnvironment.isWddmOnLinux())) { + return false; + } + return this->containsStatelessUncachedResource; +} + } // namespace L0 diff --git a/level_zero/core/test/unit_tests/mocks/mock_cmdlist.h b/level_zero/core/test/unit_tests/mocks/mock_cmdlist.h index d9da94ac61..eacc920ec5 100644 --- a/level_zero/core/test/unit_tests/mocks/mock_cmdlist.h +++ b/level_zero/core/test/unit_tests/mocks/mock_cmdlist.h @@ -641,6 +641,7 @@ class MockCommandListCoreFamily : public CommandListCoreFamily { using BaseClass::enableInOrderExecution; using BaseClass::encodeMiFlush; using BaseClass::getDeviceCounterAllocForResidency; + using BaseClass::isKernelUncachedMocsRequired; using BaseClass::ownedPrivateAllocations; using BaseClass::setAdditionalBlitProperties; using BaseClass::taskCountUpdateFenceRequired; diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_8.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_8.cpp index 0b2e01ad51..773f3d435c 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_8.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_8.cpp @@ -1934,5 +1934,29 @@ HWTEST_F(CommandListCreate, givenNullptrPeerAllocationWhenGetDeviceCounterAllocF EXPECT_ANY_THROW(commandList->getDeviceCounterAllocForResidency(&counterDeviceAlloc)); } +HWTEST_F(CommandListCreate, givenCommandListWhenIsKernelUncachedMocsRequiredCalledThenReturnCorrectValue) { + DebugManagerStateRestore restore; + debugManager.flags.EnableStateBaseAddressTracking.set(0); + + auto commandList = std::make_unique>(); + commandList->initialize(device, NEO::EngineGroupType::renderCompute, 0u); + EXPECT_FALSE(commandList->isKernelUncachedMocsRequired(false)); + + auto &rootDeviceEnvironment = neoDevice->executionEnvironment->rootDeviceEnvironments[0]; + auto deferMOCSToPatIndex = device->getProductHelper().deferMOCSToPatIndex(rootDeviceEnvironment->isWddmOnLinux()); + EXPECT_EQ(!deferMOCSToPatIndex, commandList->isKernelUncachedMocsRequired(true)); + EXPECT_TRUE(commandList->getContainsStatelessUncachedResource()); +} + +HWTEST_F(CommandListCreate, givenSbaTrackingEnabledWhenIsKernelUncachedMocsRequiredCalledThenReturnFalse) { + DebugManagerStateRestore restore; + debugManager.flags.EnableStateBaseAddressTracking.set(1); + + auto commandList = std::make_unique>(); + commandList->initialize(device, NEO::EngineGroupType::renderCompute, 0u); + EXPECT_FALSE(commandList->isKernelUncachedMocsRequired(true)); + EXPECT_TRUE(commandList->getContainsStatelessUncachedResource()); +} + } // namespace ult } // namespace L0