diff --git a/level_zero/core/source/device/device_imp.cpp b/level_zero/core/source/device/device_imp.cpp index dd3bccc9be..3205150bef 100644 --- a/level_zero/core/source/device/device_imp.cpp +++ b/level_zero/core/source/device/device_imp.cpp @@ -1904,7 +1904,7 @@ ze_result_t DeviceImp::getCsrForHighPriority(NEO::CommandStreamReceiver **csr, b } bool DeviceImp::isSuitableForLowPriority(ze_command_queue_priority_t priority, bool copyOnly) { - bool engineSuitable = copyOnly ? getGfxCoreHelper().getContextGroupContextsCount() > 0 : !this->implicitScalingCapable; + bool engineSuitable = copyOnly ? getGfxCoreHelper().areSecondaryContextsSupported() : !this->implicitScalingCapable; return (priority == ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_LOW && engineSuitable); } diff --git a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_5.cpp b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_5.cpp index 22e27f7aa5..d27b36fd22 100644 --- a/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_5.cpp +++ b/level_zero/core/test/unit_tests/sources/cmdlist/test_cmdlist_5.cpp @@ -3252,18 +3252,24 @@ HWTEST2_F(CommandListStateBaseAddressPrivateHeapTest, HWTEST2_F(CommandListStateBaseAddressPrivateHeapTest, givenCommandListUsingPrivateSurfaceHeapWhenTaskCountZeroAndCommandListDestroyedThenCsrDoNotDispatchesStateCacheFlush, HeapfulSupportedMatch) { - auto &csr = neoDevice->getUltCommandStreamReceiver(); + + DebugManagerStateRestore restorer; + debugManager.flags.ContextGroupSize.set(0); + NEO::MockDevice *mockNeoDevice(NEO::MockDevice::createWithNewExecutionEnvironment(NEO::defaultHwInfo.get(), 0)); + MockDeviceImp l0Device(mockNeoDevice, mockNeoDevice->getExecutionEnvironment()); + + auto &csr = mockNeoDevice->getUltCommandStreamReceiver(); auto &csrStream = csr.commandStream; ze_result_t returnValue; - L0::ult::CommandList *cmdListObject = CommandList::whiteboxCast(CommandList::create(productFamily, device, engineGroupType, 0u, returnValue, false)); + L0::ult::CommandList *cmdListObject = CommandList::whiteboxCast(CommandList::create(productFamily, &l0Device, engineGroupType, 0u, returnValue, false)); auto sizeBeforeDestroy = csrStream.getUsed(); returnValue = cmdListObject->destroy(); EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); - cmdListObject = CommandList::whiteboxCast(CommandList::create(productFamily, device, engineGroupType, 0u, returnValue, false)); + cmdListObject = CommandList::whiteboxCast(CommandList::create(productFamily, &l0Device, engineGroupType, 0u, returnValue, false)); returnValue = cmdListObject->destroy(); EXPECT_EQ(ZE_RESULT_SUCCESS, returnValue); diff --git a/opencl/test/unit_test/aub_tests/command_queue/large_grf_aub_tests_xehp_and_later.cpp b/opencl/test/unit_test/aub_tests/command_queue/large_grf_aub_tests_xehp_and_later.cpp index e25b9c0eae..a2bd0c3c15 100644 --- a/opencl/test/unit_test/aub_tests/command_queue/large_grf_aub_tests_xehp_and_later.cpp +++ b/opencl/test/unit_test/aub_tests/command_queue/large_grf_aub_tests_xehp_and_later.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Intel Corporation + * Copyright (C) 2024-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -458,8 +458,17 @@ HWTEST2_P(LargeGrfTest, givenMixedLargeGrfAndSmallGrfKernelsWhenExecutedThenResu EXPECT_FALSE(largeGrfValues[3]); } } else { - ASSERT_EQ(1u, largeGrfValues.size()); - EXPECT_FALSE(largeGrfValues[0]); + auto &gfxCoreHelper = executionEnvironment->rootDeviceEnvironments[0]->getHelper(); + if (gfxCoreHelper.areSecondaryContextsSupported() == false) { + ASSERT_EQ(1u, largeGrfValues.size()); + EXPECT_FALSE(largeGrfValues[0]); + } else { + EXPECT_EQ(0u, largeGrfValues.size()); + largeGrfValues = NEO::UnitTestHelper::getProgrammedLargeGrfValues(*this->csr, + this->csr->getCS(0)); + ASSERT_NE(0u, largeGrfValues.size()); + EXPECT_FALSE(largeGrfValues[0]); + } } expectMemory( diff --git a/shared/source/execution_environment/execution_environment.cpp b/shared/source/execution_environment/execution_environment.cpp index e9634e8fa8..405d5b11f7 100644 --- a/shared/source/execution_environment/execution_environment.cpp +++ b/shared/source/execution_environment/execution_environment.cpp @@ -115,7 +115,7 @@ void ExecutionEnvironment::calculateMaxOsContextCount() { uint32_t numRootContexts = hasRootCsr ? 1 : 0; uint32_t numSecondaryContexts = 0; - if (gfxCoreHelper.getContextGroupContextsCount() > 0) { + if (gfxCoreHelper.areSecondaryContextsSupported()) { numSecondaryContexts += numRegularEngines * gfxCoreHelper.getContextGroupContextsCount(); numSecondaryContexts += numHpEngines * gfxCoreHelper.getContextGroupContextsCount(); osContextCount -= (numRegularEngines + numHpEngines); diff --git a/shared/source/execution_environment/root_device_environment.cpp b/shared/source/execution_environment/root_device_environment.cpp index 53288acbd1..a567893171 100644 --- a/shared/source/execution_environment/root_device_environment.cpp +++ b/shared/source/execution_environment/root_device_environment.cpp @@ -158,6 +158,7 @@ CompilerInterface *RootDeviceEnvironment::getCompilerInterface() { void RootDeviceEnvironment::initHelpers() { initProductHelper(); initGfxCoreHelper(); + initializeGfxCoreHelperFromProductHelper(); initializeGfxCoreHelperFromHwInfo(); initApiGfxCoreHelper(); initCompilerProductHelper(); @@ -171,6 +172,12 @@ void RootDeviceEnvironment::initializeGfxCoreHelperFromHwInfo() { } } +void RootDeviceEnvironment::initializeGfxCoreHelperFromProductHelper() { + if (this->productHelper) { + gfxCoreHelper->initializeFromProductHelper(*this->productHelper.get()); + } +} + void RootDeviceEnvironment::initGfxCoreHelper() { if (gfxCoreHelper == nullptr) { gfxCoreHelper = GfxCoreHelper::create(this->getHardwareInfo()->platform.eRenderCoreFamily); diff --git a/shared/source/execution_environment/root_device_environment.h b/shared/source/execution_environment/root_device_environment.h index 752e5acd5e..cbf41c0a28 100644 --- a/shared/source/execution_environment/root_device_environment.h +++ b/shared/source/execution_environment/root_device_environment.h @@ -84,6 +84,7 @@ struct RootDeviceEnvironment : NonCopyableClass { void initHelpers(); void initGfxCoreHelper(); void initializeGfxCoreHelperFromHwInfo(); + void initializeGfxCoreHelperFromProductHelper(); void initApiGfxCoreHelper(); void initCompilerProductHelper(); void initReleaseHelper(); diff --git a/shared/source/helpers/gfx_core_helper.h b/shared/source/helpers/gfx_core_helper.h index 7aa0a50157..c6ccc52762 100644 --- a/shared/source/helpers/gfx_core_helper.h +++ b/shared/source/helpers/gfx_core_helper.h @@ -176,6 +176,7 @@ class GfxCoreHelper { virtual void adjustCopyEngineRegularContextCount(const size_t enginesCount, uint32_t &contextCount) const = 0; virtual aub_stream::EngineType getDefaultHpCopyEngine(const HardwareInfo &hwInfo) const = 0; virtual void initializeDefaultHpCopyEngine(const HardwareInfo &hwInfo) = 0; + virtual void initializeFromProductHelper(const ProductHelper &productHelper) = 0; virtual bool is48ResourceNeededForCmdBuffer() const = 0; virtual uint32_t getKernelPrivateMemSize(const KernelDescriptor &kernelDescriptor) const = 0; @@ -412,6 +413,7 @@ class GfxCoreHelperHw : public GfxCoreHelper { void adjustCopyEngineRegularContextCount(const size_t enginesCount, uint32_t &contextCount) const override; aub_stream::EngineType getDefaultHpCopyEngine(const HardwareInfo &hwInfo) const override; void initializeDefaultHpCopyEngine(const HardwareInfo &hwInfo) override; + void initializeFromProductHelper(const ProductHelper &productHelper) override; bool is48ResourceNeededForCmdBuffer() const override; @@ -438,6 +440,7 @@ class GfxCoreHelperHw : public GfxCoreHelper { protected: aub_stream::EngineType hpCopyEngineType = aub_stream::EngineType::NUM_ENGINES; + bool secondaryContextsEnabled = false; static const AuxTranslationMode defaultAuxTranslationMode; GfxCoreHelperHw() = default; diff --git a/shared/source/helpers/gfx_core_helper_base.inl b/shared/source/helpers/gfx_core_helper_base.inl index 311866d635..e12111c647 100644 --- a/shared/source/helpers/gfx_core_helper_base.inl +++ b/shared/source/helpers/gfx_core_helper_base.inl @@ -727,6 +727,11 @@ void GfxCoreHelperHw::initializeDefaultHpCopyEngine(const HardwareInf hpCopyEngineType = aub_stream::EngineType::NUM_ENGINES; } +template +void GfxCoreHelperHw::initializeFromProductHelper(const ProductHelper &productHelper) { + secondaryContextsEnabled = productHelper.areSecondaryContextsSupported(); +} + template bool GfxCoreHelperHw::is48ResourceNeededForCmdBuffer() const { return true; diff --git a/shared/source/os_interface/product_helper.h b/shared/source/os_interface/product_helper.h index b35b131e29..9fb09415b5 100644 --- a/shared/source/os_interface/product_helper.h +++ b/shared/source/os_interface/product_helper.h @@ -128,6 +128,7 @@ class ProductHelper { virtual bool isPageFaultSupported() const = 0; virtual bool isKmdMigrationSupported() const = 0; virtual bool isDisableScratchPagesSupported() const = 0; + virtual bool areSecondaryContextsSupported() const = 0; virtual bool isTile64With3DSurfaceOnBCSSupported(const HardwareInfo &hwInfo) const = 0; virtual bool isDcFlushAllowed() const = 0; virtual bool isDcFlushMitigated() const = 0; diff --git a/shared/source/os_interface/product_helper.inl b/shared/source/os_interface/product_helper.inl index e83e68d1a9..520f24e206 100644 --- a/shared/source/os_interface/product_helper.inl +++ b/shared/source/os_interface/product_helper.inl @@ -436,6 +436,11 @@ bool ProductHelperHw::isDisableScratchPagesSupported() const { return false; } +template +bool ProductHelperHw::areSecondaryContextsSupported() const { + return false; +} + template bool ProductHelperHw::isDcFlushAllowed() const { using GfxProduct = typename HwMapper::GfxProduct; diff --git a/shared/source/os_interface/product_helper_hw.h b/shared/source/os_interface/product_helper_hw.h index 5f98185b50..5e2c81d35b 100644 --- a/shared/source/os_interface/product_helper_hw.h +++ b/shared/source/os_interface/product_helper_hw.h @@ -71,6 +71,7 @@ class ProductHelperHw : public ProductHelper { bool blitEnqueuePreferred(bool isWriteToImageFromBuffer) const override; bool isKmdMigrationSupported() const override; bool isDisableScratchPagesSupported() const override; + bool areSecondaryContextsSupported() const override; bool isTile64With3DSurfaceOnBCSSupported(const HardwareInfo &hwInfo) const override; bool isDcFlushAllowed() const override; bool isDcFlushMitigated() const override;