From c7475fefdee02f6cf56074786f42854654df0d45 Mon Sep 17 00:00:00 2001 From: Slawomir Milczarek Date: Tue, 16 Dec 2025 23:51:38 +0000 Subject: [PATCH] fix: Set context group count for root device engine correctly Related-To: NEO-16676 This ensures that the OsContext is only marked as part of a context group when useContextGroup is true, aligning the OsContext's state with the actual context grouping logic. Signed-off-by: Slawomir Milczarek --- shared/source/device/root_device.cpp | 2 +- .../unit_test/device/neo_device_tests.cpp | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/shared/source/device/root_device.cpp b/shared/source/device/root_device.cpp index 5ce74ce5c8..c23a4685cc 100644 --- a/shared/source/device/root_device.cpp +++ b/shared/source/device/root_device.cpp @@ -107,7 +107,7 @@ bool RootDevice::createRootDeviceEngine(EngineTypeUsage engineTypeUsage, DeviceB auto osContext = getMemoryManager()->createAndRegisterOsContext(rootCommandStreamReceiver.get(), engineDescriptor); - osContext->setContextGroupCount(gfxCoreHelper.getContextGroupContextsCount()); + osContext->setContextGroupCount(useContextGroup ? gfxCoreHelper.getContextGroupContextsCount() : 0); osContext->setIsPrimaryEngine(isPrimaryEngine); rootCommandStreamReceiver->setupContext(*osContext); diff --git a/shared/test/unit_test/device/neo_device_tests.cpp b/shared/test/unit_test/device/neo_device_tests.cpp index f4859a42e1..7285270c32 100644 --- a/shared/test/unit_test/device/neo_device_tests.cpp +++ b/shared/test/unit_test/device/neo_device_tests.cpp @@ -2977,6 +2977,33 @@ HWTEST_F(DeviceTests, givenMaskedSubDevicesWhenCallingPollForCompletionOnRootDev EXPECT_EQ(callCount, numMaskedSubDevices); } +HWTEST_F(DeviceTests, givenEngineUsageWhenCreatingRootDeviceEngineThenIsPartOfContextGroupIsSetCorrectly) { + DebugManagerStateRestore dbgRestorer; + const uint32_t contextGroupSize = 8; + debugManager.flags.ContextGroupSize.set(contextGroupSize); + + struct TestCase { + EngineUsage engineUsage; + bool expectedIsPartOfContextGroup; + }; + + std::vector testCases = { + {EngineUsage::regular, true}, // Regular engine should be part of context group + {EngineUsage::highPriority, false}, // High-priority engine should NOT be part of context group + {EngineUsage::lowPriority, false}, // Low-priority engine should NOT be part of context group + }; + + for (const auto &testCase : testCases) { + auto device = std::make_unique(); + EngineTypeUsage engineTypeUsage = {aub_stream::ENGINE_CCS, testCase.engineUsage}; + bool result = device->createRootDeviceEngine(engineTypeUsage, device->getDeviceBitfield()); + EXPECT_TRUE(result); + + auto &osContext = device->getAllEngines().back().osContext; + EXPECT_EQ(testCase.expectedIsPartOfContextGroup, osContext->isPartOfContextGroup()); + } +} + TEST(DeviceCanAccessPeerTest, givenTheSameDeviceThenCanAccessPeerReturnsTrue) { UltDeviceFactory deviceFactory{2, 0}; auto rootDevice0 = deviceFactory.rootDevices[0];