diff --git a/shared/source/helpers/gfx_core_helper_base.inl b/shared/source/helpers/gfx_core_helper_base.inl index bef2724616..49525c1ef9 100644 --- a/shared/source/helpers/gfx_core_helper_base.inl +++ b/shared/source/helpers/gfx_core_helper_base.inl @@ -802,6 +802,8 @@ uint32_t GfxCoreHelperHw::calculateAvailableThreadCount(const Hardwar template void GfxCoreHelperHw::alignThreadGroupCountToDssSize(uint32_t &threadCount, uint32_t dssCount, uint32_t threadsPerDss, uint32_t threadGroupSize) const { + uint32_t availableTreadCount = (threadsPerDss / threadGroupSize) * dssCount; + threadCount = std::min(threadCount, availableTreadCount); } template diff --git a/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp b/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp index add34c2b59..777df449ec 100644 --- a/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp +++ b/shared/test/unit_test/helpers/gfx_core_helper_tests.cpp @@ -1874,10 +1874,32 @@ HWTEST_F(GfxCoreHelperTest, givenGetDeviceTimestampWidthCalledThenReturnCorrectV EXPECT_EQ(64u, helper.getDeviceTimestampWidth()); } -HWTEST2_F(GfxCoreHelperTest, givenHwHelperWhenAligningThreadGroupCountToDssSizeThenThreadGroupCountDoesNotChange, IsAtMostXe2HpgCore) { +HWTEST_F(GfxCoreHelperTest, givenHwHelperWhenAligningThreadGroupCountToDssSizeThenThreadGroupCountChanged) { auto &helper = getHelper(); uint32_t threadGroupCountBefore = 4096; uint32_t threadCount = threadGroupCountBefore; helper.alignThreadGroupCountToDssSize(threadCount, 1, 1, 1); - EXPECT_EQ(threadGroupCountBefore, threadCount); + EXPECT_NE(threadGroupCountBefore, threadCount); +} + +HWTEST_F(GfxCoreHelperTest, givenHwHelperWhenThreadGroupCountIsAlignedToDssThenThreadCountNotChanged) { + auto &helper = getHelper(); + uint32_t dssCount = 16; + uint32_t threadGroupSize = 32; + uint32_t threadsPerDss = 2 * threadGroupSize; + uint32_t maxThreadCount = (dssCount * threadsPerDss) / threadGroupSize; + uint32_t threadCount = maxThreadCount; + helper.alignThreadGroupCountToDssSize(threadCount, dssCount, threadsPerDss, threadGroupSize); + EXPECT_EQ(2 * dssCount, threadCount); +} + +HWTEST_F(GfxCoreHelperTest, givenHwHelperWhenThreadGroupCountIsAlignedToDssThenThreadCountChanged) { + auto &helper = getHelper(); + uint32_t dssCount = 16; + uint32_t threadGroupSize = 32; + uint32_t threadsPerDss = 2 * threadGroupSize - 1; + uint32_t maxThreadCount = (dssCount * threadsPerDss) / threadGroupSize; + uint32_t threadCount = maxThreadCount; + helper.alignThreadGroupCountToDssSize(threadCount, dssCount, threadsPerDss, threadGroupSize); + EXPECT_EQ(dssCount, threadCount); } \ No newline at end of file