diff --git a/level_zero/core/test/unit_tests/sources/device/test_l0_device.cpp b/level_zero/core/test/unit_tests/sources/device/test_l0_device.cpp index 1ce27aaf02..af192b8d42 100644 --- a/level_zero/core/test/unit_tests/sources/device/test_l0_device.cpp +++ b/level_zero/core/test/unit_tests/sources/device/test_l0_device.cpp @@ -4613,7 +4613,7 @@ HWTEST_F(DeviceTest, givenContextGroupSupportedWhenGettingLowPriorityCsrThenCorr auto hwInfo = *NEO::defaultHwInfo; hwInfo.featureTable.flags.ftrCCSNode = true; hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCS; - hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 2; + hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 1; MockExecutionEnvironment mockExecutionEnvironment{&hwInfo}; RAIIGfxCoreHelperFactory raii(*mockExecutionEnvironment.rootDeviceEnvironments[rootDeviceIndex]); @@ -4734,7 +4734,7 @@ HWTEST_F(DeviceTest, givenContextGroupSupportedWhenGettingHighPriorityCsrThenCor auto &secondaryEngines = neoMockDevice->secondaryEngines[EngineHelpers::mapCcsIndexToEngineType(index)]; - ASSERT_EQ(8u, secondaryEngines.engines.size()); + ASSERT_EQ(8u / hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled, secondaryEngines.engines.size()); auto highPriorityIndex = secondaryEngines.regularEnginesTotal; ASSERT_LT(highPriorityIndex, static_cast(secondaryEngines.engines.size())); diff --git a/shared/source/device/device.cpp b/shared/source/device/device.cpp index 85d9ea1be0..14491026b4 100644 --- a/shared/source/device/device.cpp +++ b/shared/source/device/device.cpp @@ -364,6 +364,7 @@ bool Device::createEngines() { } if (gfxCoreHelper.areSecondaryContextsSupported()) { + auto &hwInfo = this->getHardwareInfo(); auto hpCopyEngine = getHpCopyEngine(); @@ -387,6 +388,11 @@ bool Device::createEngines() { highPriorityContextCount = static_cast(debugManager.flags.OverrideNumHighPriorityContexts.get()); } + if (engineGroupType == EngineGroupType::compute && hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled > 1) { + contextCount = contextCount / hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled; + highPriorityContextCount = highPriorityContextCount / hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled; + } + for (uint32_t engineIndex = 0; engineIndex < static_cast(engineGroup->engines.size()); engineIndex++) { auto engineType = engineGroup->engines[engineIndex].getEngineType(); diff --git a/shared/test/unit_test/device/neo_device_tests.cpp b/shared/test/unit_test/device/neo_device_tests.cpp index bb52444509..77acd00ddb 100644 --- a/shared/test/unit_test/device/neo_device_tests.cpp +++ b/shared/test/unit_test/device/neo_device_tests.cpp @@ -7,6 +7,7 @@ #include "shared/source/device/device.h" #include "shared/source/gmm_helper/gmm.h" +#include "shared/source/helpers/array_count.h" #include "shared/source/helpers/driver_model_type.h" #include "shared/source/helpers/gfx_core_helper.h" #include "shared/source/memory_manager/allocations_list.h" @@ -1195,71 +1196,78 @@ HWTEST_F(DeviceTests, givenCCSEnginesAndContextGroupSizeEnabledWhenDeviceIsCreat hwInfo.featureTable.flags.ftrCCSNode = true; hwInfo.featureTable.ftrBcsInfo = 0; hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCS; - hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 2; - auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo)); - auto &engineGroups = device->getRegularEngineGroups(); + uint32_t numOfCCS[] = {1, 2, 4}; - auto engineGroupType = EngineGroupType::compute; - size_t computeEnginesCount = 0; - for (const auto &engine : engineGroups) { - if (engine.engineGroupType == engineGroupType) { - computeEnginesCount = engine.engines.size(); - } - } + for (size_t i = 0; i < arrayCount(numOfCCS); i++) { - if (computeEnginesCount == 0) { - GTEST_SKIP(); - } + hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = numOfCCS[i]; - ASSERT_EQ(computeEnginesCount, device->secondaryEngines.size()); - ASSERT_EQ(contextGroupSize, device->secondaryEngines[aub_stream::EngineType::ENGINE_CCS].engines.size()); + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo)); + auto &engineGroups = device->getRegularEngineGroups(); - auto defaultEngine = device->getDefaultEngine(); - EXPECT_EQ(defaultEngine.commandStreamReceiver, device->secondaryEngines[aub_stream::EngineType::ENGINE_CCS].engines[0].commandStreamReceiver); - - const uint32_t regularContextCount = std::min(contextGroupSize / 2, 4u); - - for (uint32_t ccsIndex = 0; ccsIndex < computeEnginesCount; ccsIndex++) { - auto &secondaryEngines = device->secondaryEngines[EngineHelpers::mapCcsIndexToEngineType(ccsIndex)]; - - EXPECT_TRUE(secondaryEngines.engines[0].osContext->isPartOfContextGroup()); - EXPECT_EQ(nullptr, secondaryEngines.engines[0].osContext->getPrimaryContext()); - - for (size_t i = 1; i < device->secondaryEngines[aub_stream::EngineType::ENGINE_CCS].engines.size(); i++) { - EXPECT_EQ(secondaryEngines.engines[0].osContext, secondaryEngines.engines[i].osContext->getPrimaryContext()); - EXPECT_TRUE(secondaryEngines.engines[i].osContext->isPartOfContextGroup()); - } - - EXPECT_EQ(0u, secondaryEngines.regularCounter.load()); - EXPECT_EQ(0u, secondaryEngines.highPriorityCounter.load()); - - EXPECT_EQ(regularContextCount, secondaryEngines.regularEnginesTotal); - EXPECT_EQ(contextGroupSize - regularContextCount, secondaryEngines.highPriorityEnginesTotal); - - for (size_t contextId = 0; contextId < regularContextCount + 1; contextId++) { - auto engine = device->getSecondaryEngineCsr({EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::regular}, false); - ASSERT_NE(nullptr, engine); - - EXPECT_EQ(contextId + 1, secondaryEngines.regularCounter.load()); - if (contextId == regularContextCount) { - EXPECT_EQ(&secondaryEngines.engines[0], engine); + auto engineGroupType = EngineGroupType::compute; + size_t computeEnginesCount = 0; + for (const auto &engine : engineGroups) { + if (engine.engineGroupType == engineGroupType) { + computeEnginesCount = engine.engines.size(); } } - for (size_t contextId = 0; contextId < contextGroupSize - regularContextCount + 1; contextId++) { - auto engine = device->getSecondaryEngineCsr({EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::highPriority}, false); - ASSERT_NE(nullptr, engine); + if (computeEnginesCount == 0) { + GTEST_SKIP(); + } - EXPECT_EQ(contextId + 1, secondaryEngines.highPriorityCounter.load()); - if (contextId == contextGroupSize - regularContextCount) { - EXPECT_EQ(&secondaryEngines.engines[regularContextCount], engine); + ASSERT_EQ(computeEnginesCount, device->secondaryEngines.size()); + ASSERT_EQ(contextGroupSize / numOfCCS[i], device->secondaryEngines[aub_stream::EngineType::ENGINE_CCS].engines.size()); + + auto defaultEngine = device->getDefaultEngine(); + EXPECT_EQ(defaultEngine.commandStreamReceiver, device->secondaryEngines[aub_stream::EngineType::ENGINE_CCS].engines[0].commandStreamReceiver); + + const uint32_t regularContextCount = std::min(contextGroupSize / 2, 4u) / numOfCCS[i]; + + for (uint32_t ccsIndex = 0; ccsIndex < computeEnginesCount; ccsIndex++) { + auto &secondaryEngines = device->secondaryEngines[EngineHelpers::mapCcsIndexToEngineType(ccsIndex)]; + + EXPECT_TRUE(secondaryEngines.engines[0].osContext->isPartOfContextGroup()); + EXPECT_EQ(nullptr, secondaryEngines.engines[0].osContext->getPrimaryContext()); + + for (size_t i = 1; i < device->secondaryEngines[aub_stream::EngineType::ENGINE_CCS].engines.size(); i++) { + EXPECT_EQ(secondaryEngines.engines[0].osContext, secondaryEngines.engines[i].osContext->getPrimaryContext()); + EXPECT_TRUE(secondaryEngines.engines[i].osContext->isPartOfContextGroup()); + } + + EXPECT_EQ(0u, secondaryEngines.regularCounter.load()); + EXPECT_EQ(0u, secondaryEngines.highPriorityCounter.load()); + + EXPECT_EQ(regularContextCount, secondaryEngines.regularEnginesTotal); + EXPECT_EQ(contextGroupSize / numOfCCS[i] - regularContextCount, secondaryEngines.highPriorityEnginesTotal); + + for (size_t contextId = 0; contextId < regularContextCount + 1; contextId++) { + auto engine = device->getSecondaryEngineCsr({EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::regular}, false); + ASSERT_NE(nullptr, engine); + + EXPECT_EQ(contextId + 1, secondaryEngines.regularCounter.load()); + if (contextId == regularContextCount) { + EXPECT_EQ(&secondaryEngines.engines[0], engine); + } + } + + auto hpCount = contextGroupSize / numOfCCS[i] - regularContextCount; + for (size_t contextId = 0; contextId < hpCount + 1; contextId++) { + auto engine = device->getSecondaryEngineCsr({EngineHelpers::mapCcsIndexToEngineType(ccsIndex), EngineUsage::highPriority}, false); + ASSERT_NE(nullptr, engine); + + EXPECT_EQ(contextId + 1, secondaryEngines.highPriorityCounter.load()); + if (contextId == hpCount) { + EXPECT_EQ(&secondaryEngines.engines[regularContextCount], engine); + } } } - } - auto internalEngine = device->getInternalEngine(); - EXPECT_NE(internalEngine.commandStreamReceiver, device->getSecondaryEngineCsr({aub_stream::EngineType::ENGINE_CCS, EngineUsage::internal}, false)->commandStreamReceiver); + auto internalEngine = device->getInternalEngine(); + EXPECT_NE(internalEngine.commandStreamReceiver, device->getSecondaryEngineCsr({aub_stream::EngineType::ENGINE_CCS, EngineUsage::internal}, false)->commandStreamReceiver); + } } HWTEST_F(DeviceTests, givenRootDeviceWithCCSEngineAndContextGroupSizeEnabledWhenDeviceIsCreatedThenSecondaryEnginesAreCreated) { @@ -1275,7 +1283,7 @@ HWTEST_F(DeviceTests, givenRootDeviceWithCCSEngineAndContextGroupSizeEnabledWhen hwInfo.featureTable.flags.ftrCCSNode = true; hwInfo.featureTable.ftrBcsInfo = 0; hwInfo.capabilityTable.defaultEngineType = aub_stream::ENGINE_CCS; - hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 2; + hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled = 1; auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(&hwInfo)); auto &engineGroups = device->getRegularEngineGroups();