From 8000133b2aa5b452b59b33b92ea9e240a983f2a1 Mon Sep 17 00:00:00 2001 From: Mateusz Hoppe Date: Wed, 25 Sep 2024 12:26:47 +0000 Subject: [PATCH] refactor: add method to adjust regular context count Related-To: NEO-12258 Signed-off-by: Mateusz Hoppe --- shared/source/device/device.cpp | 4 ++++ shared/source/helpers/gfx_core_helper.h | 2 ++ shared/source/helpers/gfx_core_helper_base.inl | 4 ++++ shared/test/unit_test/device/neo_device_tests.cpp | 8 +++++++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/shared/source/device/device.cpp b/shared/source/device/device.cpp index d96484e520..d70a3524a3 100644 --- a/shared/source/device/device.cpp +++ b/shared/source/device/device.cpp @@ -407,6 +407,10 @@ bool Device::createEngines() { highPriorityContextCount = highPriorityContextCount / hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled; } + if (engineGroupType == EngineGroupType::copy || engineGroupType == EngineGroupType::linkedCopy) { + gfxCoreHelper.adjustCopyEngineRegularContextCount(engineGroup->engines.size(), contextCount); + } + for (uint32_t engineIndex = 0; engineIndex < static_cast(engineGroup->engines.size()); engineIndex++) { auto engineType = engineGroup->engines[engineIndex].getEngineType(); diff --git a/shared/source/helpers/gfx_core_helper.h b/shared/source/helpers/gfx_core_helper.h index 43c0433840..c669f958b0 100644 --- a/shared/source/helpers/gfx_core_helper.h +++ b/shared/source/helpers/gfx_core_helper.h @@ -179,6 +179,7 @@ class GfxCoreHelper { virtual bool areSecondaryContextsSupported() const = 0; virtual uint32_t getContextGroupContextsCount() const = 0; virtual uint32_t getContextGroupHpContextsCount(EngineGroupType type, bool hpEngineAvailable) const = 0; + 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; @@ -412,6 +413,7 @@ class GfxCoreHelperHw : public GfxCoreHelper { bool areSecondaryContextsSupported() const override; uint32_t getContextGroupContextsCount() const override; uint32_t getContextGroupHpContextsCount(EngineGroupType type, bool hpEngineAvailable) const override; + 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; diff --git a/shared/source/helpers/gfx_core_helper_base.inl b/shared/source/helpers/gfx_core_helper_base.inl index 85be97bbb6..9bd2b8b472 100644 --- a/shared/source/helpers/gfx_core_helper_base.inl +++ b/shared/source/helpers/gfx_core_helper_base.inl @@ -720,6 +720,10 @@ uint32_t GfxCoreHelperHw::getContextGroupHpContextsCount(EngineGroupT return std::min(getContextGroupContextsCount() / 2, 4u); } +template +void GfxCoreHelperHw::adjustCopyEngineRegularContextCount(const size_t enginesCount, uint32_t &contextCount) const { +} + template aub_stream::EngineType GfxCoreHelperHw::getDefaultHpCopyEngine(const HardwareInfo &hwInfo) const { return hpCopyEngineType; diff --git a/shared/test/unit_test/device/neo_device_tests.cpp b/shared/test/unit_test/device/neo_device_tests.cpp index f2c0d9644a..0bbca80dcf 100644 --- a/shared/test/unit_test/device/neo_device_tests.cpp +++ b/shared/test/unit_test/device/neo_device_tests.cpp @@ -1701,7 +1701,13 @@ HWTEST_F(DeviceTests, givenCopyEnginesWhenCreatingSecondaryContextsThenUseCopyTy if (supportedRegular || supportedHp) { auto usage = supportedRegular ? EngineUsage::regular : EngineUsage::highPriority; EXPECT_NE(device->secondaryEngines.end(), device->secondaryEngines.find(engineType)); - EXPECT_EQ(5u, device->secondaryEngines[engineType].engines.size()); + + auto expectedEngineCount = 5u; + if (supportedRegular) { + gfxCoreHelper.adjustCopyEngineRegularContextCount(device->secondaryEngines[engineType].engines.size(), expectedEngineCount); + } + + EXPECT_EQ(expectedEngineCount, device->secondaryEngines[engineType].engines.size()); auto engine = device->getSecondaryEngineCsr({engineType, usage}, false); ASSERT_NE(nullptr, engine);