fix: Correct logic to select internal BCS engine

When BCS3 is not available, use last available copy engine as internal.

Related-To: HSD-18039263936

Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski
2024-07-17 21:39:08 +00:00
committed by Compute-Runtime-Automation
parent d7777ef163
commit 46f9133bf2
9 changed files with 118 additions and 21 deletions

View File

@@ -1,11 +1,12 @@
/*
* Copyright (C) 2019-2021 Intel Corporation
* Copyright (C) 2019-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/bit_helpers.h"
#include "shared/source/helpers/constants.h"
#include "gtest/gtest.h"
@@ -197,3 +198,23 @@ TEST(SetBitsTests, givenDifferentValuesWhenTestingSetBitsThenCorrectValueIsRetur
EXPECT_EQ(0b0u, setBits(0b1010, false, 0b1010));
EXPECT_EQ(0b1010u, setBits(0b1010, true, 0b1010));
}
TEST(GetMsbIndexTests, givenDifferentValuesWhenTestingGetMostSignificantSetBitIndexThenCorrectValueIsReturned) {
EXPECT_EQ(0u, getMostSignificantSetBitIndex(0b0));
EXPECT_EQ(0u, getMostSignificantSetBitIndex(0b1));
EXPECT_EQ(1u, getMostSignificantSetBitIndex(0b10));
EXPECT_EQ(2u, getMostSignificantSetBitIndex(0b100));
EXPECT_EQ(3u, getMostSignificantSetBitIndex(0b1000));
EXPECT_EQ(3u, getMostSignificantSetBitIndex(0b1001));
EXPECT_EQ(3u, getMostSignificantSetBitIndex(0b1010));
EXPECT_EQ(3u, getMostSignificantSetBitIndex(0b1100));
EXPECT_EQ(3u, getMostSignificantSetBitIndex(0b1101));
EXPECT_EQ(6u, getMostSignificantSetBitIndex(maxNBitValue(7)));
EXPECT_EQ(7u, getMostSignificantSetBitIndex(maxNBitValue(8)));
EXPECT_EQ(8u, getMostSignificantSetBitIndex(maxNBitValue(9)));
EXPECT_EQ(16u, getMostSignificantSetBitIndex(maxNBitValue(17)));
EXPECT_EQ(32u, getMostSignificantSetBitIndex(maxNBitValue(33)));
EXPECT_EQ(63u, getMostSignificantSetBitIndex(maxNBitValue(64)));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2023 Intel Corporation
* Copyright (C) 2021-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -163,7 +163,7 @@ TEST(EngineNodeHelperTest, givenLinkCopyEnginesAndInternalUsageEnabledWhenGettin
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[0];
auto &hwInfo = *rootDeviceEnvironment.getMutableHardwareInfo();
DeviceBitfield deviceBitfield = 0b11;
hwInfo.featureTable.ftrBcsInfo = 0b111;
hwInfo.featureTable.ftrBcsInfo = 0b1111;
auto isInternalUsage = true;
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS3, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, isInternalUsage));
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS3, EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, isInternalUsage));

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2023 Intel Corporation
* Copyright (C) 2021-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -64,6 +64,68 @@ HWTEST2_F(EngineNodeHelperTestsXeHPAndLater, givenForceBCSForInternalCopyEngineW
}
}
HWTEST2_F(EngineNodeHelperTestsXeHPAndLater, givenLessThanFourCopyEnginesWhenGetBcsEngineTypeForInternalEngineThenReturnLastAvailableEngine, IsAtLeastXeHpcCore) {
auto &rootDeviceEnvironment = pDevice->getRootDeviceEnvironment();
auto &hwInfo = *rootDeviceEnvironment.getMutableHardwareInfo();
hwInfo.capabilityTable.blitterOperationsSupported = true;
auto &selectorCopyEngine = pDevice->getNearestGenericSubDevice(0)->getSelectorCopyEngine();
DeviceBitfield deviceBitfield = 0xff;
{
hwInfo.featureTable.ftrBcsInfo = 0b1;
auto engineType = EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, true);
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, engineType);
}
{
hwInfo.featureTable.ftrBcsInfo = 0b11;
auto engineType = EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, true);
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS1, engineType);
}
{
hwInfo.featureTable.ftrBcsInfo = 0b111;
auto engineType = EngineHelpers::getBcsEngineType(rootDeviceEnvironment, deviceBitfield, selectorCopyEngine, true);
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS2, engineType);
}
}
HWTEST2_F(EngineNodeHelperTestsXeHPAndLater, givenLessThanFourCopyEnginesWhenGetGpgpuEngineInstancesThenUseLastCopyEngineAsInternal, IsAtLeastXeHpcCore) {
auto &rootDeviceEnvironment = pDevice->getRootDeviceEnvironment();
auto &hwInfo = *rootDeviceEnvironment.getMutableHardwareInfo();
hwInfo.capabilityTable.blitterOperationsSupported = true;
auto &gfxCoreHelper = pDevice->getGfxCoreHelper();
auto &productHelper = rootDeviceEnvironment.getProductHelper();
auto hasInternalEngine = [](const EngineInstancesContainer &engines, aub_stream::EngineType expectedEngineType) {
for (auto &[engineType, engineUsage] : engines) {
if (engineType == expectedEngineType && engineUsage == EngineUsage::internal) {
return true;
}
}
return false;
};
{
if (aub_stream::EngineType::ENGINE_BCS == productHelper.getDefaultCopyEngine()) {
hwInfo.featureTable.ftrBcsInfo = 0b1;
auto &engines = gfxCoreHelper.getGpgpuEngineInstances(rootDeviceEnvironment);
EXPECT_TRUE(hasInternalEngine(engines, aub_stream::EngineType::ENGINE_BCS));
EXPECT_FALSE(hasInternalEngine(engines, aub_stream::EngineType::ENGINE_BCS3));
}
}
{
hwInfo.featureTable.ftrBcsInfo = 0b11;
auto &engines = gfxCoreHelper.getGpgpuEngineInstances(rootDeviceEnvironment);
EXPECT_TRUE(hasInternalEngine(engines, aub_stream::EngineType::ENGINE_BCS1));
EXPECT_FALSE(hasInternalEngine(engines, aub_stream::EngineType::ENGINE_BCS3));
}
{
hwInfo.featureTable.ftrBcsInfo = 0b111;
auto &engines = gfxCoreHelper.getGpgpuEngineInstances(rootDeviceEnvironment);
EXPECT_TRUE(hasInternalEngine(engines, aub_stream::EngineType::ENGINE_BCS2));
EXPECT_FALSE(hasInternalEngine(engines, aub_stream::EngineType::ENGINE_BCS3));
}
}
HWTEST2_F(EngineNodeHelperTestsXeHPAndLater, givenEnableCmdQRoundRobindBcsEngineAssignWhenSelectLinkCopyEngineThenRoundRobinOverAllAvailableLinkedCopyEngines, IsAtLeastXeHpCore) {
DebugManagerStateRestore restore;
debugManager.flags.EnableCmdQRoundRobindBcsEngineAssign.set(1u);