feature: add regular and hp contexts in group without dedicated hp engine

- if no hp copy engine available, create group with regular and hp
contexts

Related-To: NEO-11983

Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe 2024-08-28 07:04:42 +00:00 committed by Compute-Runtime-Automation
parent 1070df4c54
commit 482e077252
7 changed files with 27 additions and 12 deletions

View File

@ -1736,9 +1736,7 @@ ze_result_t DeviceImp::getCsrForOrdinalAndIndex(NEO::CommandStreamReceiver **csr
*csr = engines[index].commandStreamReceiver; *csr = engines[index].commandStreamReceiver;
if (copyOnly && contextPriority == NEO::EngineUsage::highPriority) { if (copyOnly && contextPriority == NEO::EngineUsage::highPriority) {
if (getCsrForHighPriority(csr, copyOnly) != ZE_RESULT_SUCCESS) { getCsrForHighPriority(csr, copyOnly);
contextPriority = NEO::EngineUsage::regular;
}
} }
} else { } else {

View File

@ -4762,14 +4762,19 @@ HWTEST_F(DeviceTest, givenContextGroupSupportedWhenGettingHighPriorityCsrThenCor
result = deviceImp.getCsrForOrdinalAndIndex(&highPriorityCsr, ordinal, index, ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH, false); result = deviceImp.getCsrForOrdinalAndIndex(&highPriorityCsr, ordinal, index, ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH, false);
EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, result); EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, result);
// When no HP copy engine, then regular engine is returned // When no HP copy engine, then hp csr from group is returned
NEO::CommandStreamReceiver *bcsEngine = nullptr; NEO::CommandStreamReceiver *bcsEngine = nullptr, *bcsEngine2 = nullptr;
EXPECT_EQ(nullptr, neoMockDevice->getHpCopyEngine()); EXPECT_EQ(nullptr, neoMockDevice->getHpCopyEngine());
result = deviceImp.getCsrForOrdinalAndIndex(&bcsEngine, ordinalCopy, index, ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH, false); result = deviceImp.getCsrForOrdinalAndIndex(&bcsEngine, ordinalCopy, index, ZE_COMMAND_QUEUE_PRIORITY_PRIORITY_HIGH, false);
EXPECT_EQ(ZE_RESULT_SUCCESS, result); EXPECT_EQ(ZE_RESULT_SUCCESS, result);
ASSERT_NE(nullptr, bcsEngine); ASSERT_NE(nullptr, bcsEngine);
EXPECT_TRUE(bcsEngine->getOsContext().isRegular()); EXPECT_TRUE(bcsEngine->getOsContext().isHighPriority());
result = deviceImp.getCsrForOrdinalAndIndex(&bcsEngine2, ordinalCopy, index, ZE_COMMAND_QUEUE_PRIORITY_NORMAL, false);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
ASSERT_EQ(bcsEngine2, bcsEngine->getPrimaryCsr());
EXPECT_TRUE(bcsEngine2->getOsContext().isRegular());
} }
} }

View File

@ -365,6 +365,8 @@ bool Device::createEngines() {
if (gfxCoreHelper.areSecondaryContextsSupported()) { if (gfxCoreHelper.areSecondaryContextsSupported()) {
auto hpCopyEngine = getHpCopyEngine();
for (auto engineGroupType : {EngineGroupType::compute, EngineGroupType::copy, EngineGroupType::linkedCopy}) { for (auto engineGroupType : {EngineGroupType::compute, EngineGroupType::copy, EngineGroupType::linkedCopy}) {
auto engineGroup = tryGetRegularEngineGroup(engineGroupType); auto engineGroup = tryGetRegularEngineGroup(engineGroupType);
@ -373,7 +375,13 @@ bool Device::createEngines() {
} }
auto contextCount = gfxCoreHelper.getContextGroupContextsCount(); auto contextCount = gfxCoreHelper.getContextGroupContextsCount();
auto highPriorityContextCount = gfxCoreHelper.getContextGroupHpContextsCount(engineGroupType); bool hpEngineAvailable = false;
if (NEO::EngineHelper::isCopyOnlyEngineType(engineGroupType)) {
hpEngineAvailable = hpCopyEngine != nullptr;
}
auto highPriorityContextCount = gfxCoreHelper.getContextGroupHpContextsCount(engineGroupType, hpEngineAvailable);
if (debugManager.flags.OverrideNumHighPriorityContexts.get() != -1) { if (debugManager.flags.OverrideNumHighPriorityContexts.get() != -1) {
highPriorityContextCount = static_cast<uint32_t>(debugManager.flags.OverrideNumHighPriorityContexts.get()); highPriorityContextCount = static_cast<uint32_t>(debugManager.flags.OverrideNumHighPriorityContexts.get());
@ -395,7 +403,6 @@ bool Device::createEngines() {
} }
} }
auto hpCopyEngine = getHpCopyEngine();
if (hpCopyEngine) { if (hpCopyEngine) {
auto engineType = hpCopyEngine->getEngineType(); auto engineType = hpCopyEngine->getEngineType();
if ((static_cast<uint32_t>(debugManager.flags.SecondaryContextEngineTypeMask.get()) & (1 << static_cast<uint32_t>(engineType))) != 0) { if ((static_cast<uint32_t>(debugManager.flags.SecondaryContextEngineTypeMask.get()) & (1 << static_cast<uint32_t>(engineType))) != 0) {

View File

@ -97,7 +97,7 @@ void RootDevice::initializeRootCommandStreamReceiver() {
if (useContextGroup) { if (useContextGroup) {
auto contextCount = gfxCoreHelper.getContextGroupContextsCount(); auto contextCount = gfxCoreHelper.getContextGroupContextsCount();
EngineGroupType engineGroupType = gfxCoreHelper.getEngineGroupType(engine.getEngineType(), engine.getEngineUsage(), hwInfo); EngineGroupType engineGroupType = gfxCoreHelper.getEngineGroupType(engine.getEngineType(), engine.getEngineUsage(), hwInfo);
auto highPriorityContextCount = gfxCoreHelper.getContextGroupHpContextsCount(engineGroupType); auto highPriorityContextCount = gfxCoreHelper.getContextGroupHpContextsCount(engineGroupType, false);
if (debugManager.flags.OverrideNumHighPriorityContexts.get() != -1) { if (debugManager.flags.OverrideNumHighPriorityContexts.get() != -1) {
highPriorityContextCount = static_cast<uint32_t>(debugManager.flags.OverrideNumHighPriorityContexts.get()); highPriorityContextCount = static_cast<uint32_t>(debugManager.flags.OverrideNumHighPriorityContexts.get());

View File

@ -179,7 +179,7 @@ class GfxCoreHelper {
virtual bool areSecondaryContextsSupported() const = 0; virtual bool areSecondaryContextsSupported() const = 0;
virtual uint32_t getContextGroupContextsCount() const = 0; virtual uint32_t getContextGroupContextsCount() const = 0;
virtual uint32_t getContextGroupHpContextsCount(EngineGroupType type) const = 0; virtual uint32_t getContextGroupHpContextsCount(EngineGroupType type, bool hpEngineAvailable) const = 0;
virtual aub_stream::EngineType getDefaultHpCopyEngine(const HardwareInfo &hwInfo) const = 0; virtual aub_stream::EngineType getDefaultHpCopyEngine(const HardwareInfo &hwInfo) const = 0;
virtual bool is48ResourceNeededForCmdBuffer() const = 0; virtual bool is48ResourceNeededForCmdBuffer() const = 0;
@ -413,7 +413,7 @@ class GfxCoreHelperHw : public GfxCoreHelper {
bool areSecondaryContextsSupported() const override; bool areSecondaryContextsSupported() const override;
uint32_t getContextGroupContextsCount() const override; uint32_t getContextGroupContextsCount() const override;
uint32_t getContextGroupHpContextsCount(EngineGroupType type) const override; uint32_t getContextGroupHpContextsCount(EngineGroupType type, bool hpEngineAvailable) const override;
aub_stream::EngineType getDefaultHpCopyEngine(const HardwareInfo &hwInfo) const override; aub_stream::EngineType getDefaultHpCopyEngine(const HardwareInfo &hwInfo) const override;
bool is48ResourceNeededForCmdBuffer() const override; bool is48ResourceNeededForCmdBuffer() const override;

View File

@ -732,7 +732,10 @@ uint32_t GfxCoreHelperHw<GfxFamily>::getContextGroupContextsCount() const {
} }
template <typename GfxFamily> template <typename GfxFamily>
uint32_t GfxCoreHelperHw<GfxFamily>::getContextGroupHpContextsCount(EngineGroupType type) const { uint32_t GfxCoreHelperHw<GfxFamily>::getContextGroupHpContextsCount(EngineGroupType type, bool hpEngineAvailable) const {
if (hpEngineAvailable) {
return 0;
}
return std::min(getContextGroupContextsCount() / 2, 4u); return std::min(getContextGroupContextsCount() / 2, 4u);
} }

View File

@ -1808,6 +1808,8 @@ TEST_F(GfxCoreHelperTest, givenContextGroupEnabledWithDebugKeyWhenContextGroupCo
debugManager.flags.ContextGroupSize.set(2); debugManager.flags.ContextGroupSize.set(2);
EXPECT_EQ(2u, gfxCoreHelper.getContextGroupContextsCount()); EXPECT_EQ(2u, gfxCoreHelper.getContextGroupContextsCount());
EXPECT_TRUE(gfxCoreHelper.areSecondaryContextsSupported()); EXPECT_TRUE(gfxCoreHelper.areSecondaryContextsSupported());
EXPECT_EQ(1u, gfxCoreHelper.getContextGroupHpContextsCount(EngineGroupType::copy, false));
EXPECT_EQ(0u, gfxCoreHelper.getContextGroupHpContextsCount(EngineGroupType::copy, true));
} }
HWTEST_F(GfxCoreHelperTest, whenAskingIf48bResourceNeededForCmdBufferThenReturnTrue) { HWTEST_F(GfxCoreHelperTest, whenAskingIf48bResourceNeededForCmdBufferThenReturnTrue) {