fix: correct logic of groupDevices function
discrete devices should be exposed before integrated devices Related-To: NEO-14062 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
parent
eae7510b64
commit
24a61d096d
|
@ -1264,17 +1264,24 @@ std::vector<DeviceVector> Device::groupDevices(DeviceVector devices) {
|
|||
std::map<PRODUCT_FAMILY, size_t> productsMap;
|
||||
std::vector<DeviceVector> outDevices;
|
||||
for (auto &device : devices) {
|
||||
auto productFamily = device->getHardwareInfo().platform.eProductFamily;
|
||||
auto result = productsMap.find(productFamily);
|
||||
if (result == productsMap.end()) {
|
||||
productsMap.insert({productFamily, productsMap.size()});
|
||||
outDevices.push_back(DeviceVector{});
|
||||
if (device) {
|
||||
auto productFamily = device->getHardwareInfo().platform.eProductFamily;
|
||||
auto result = productsMap.find(productFamily);
|
||||
if (result == productsMap.end()) {
|
||||
productsMap.insert({productFamily, productsMap.size()});
|
||||
outDevices.push_back(DeviceVector{});
|
||||
}
|
||||
auto productId = productsMap[productFamily];
|
||||
outDevices[productId].push_back(std::move(device));
|
||||
}
|
||||
auto productId = productsMap[productFamily];
|
||||
outDevices[productId].push_back(std::move(device));
|
||||
}
|
||||
std::sort(outDevices.begin(), outDevices.end(), [](DeviceVector &lhs, DeviceVector &rhs) -> bool {
|
||||
return lhs[0]->getHardwareInfo().platform.eProductFamily > rhs[0]->getHardwareInfo().platform.eProductFamily; // NOLINT(clang-analyzer-cplusplus.Move)
|
||||
auto &leftHwInfo = lhs[0]->getHardwareInfo(); // NOLINT(clang-analyzer-cplusplus.Move) - MSVC assumes usage of moved vector
|
||||
auto &rightHwInfo = rhs[0]->getHardwareInfo(); // NOLINT(clang-analyzer-cplusplus.Move)
|
||||
if (leftHwInfo.capabilityTable.isIntegratedDevice != rightHwInfo.capabilityTable.isIntegratedDevice) {
|
||||
return rightHwInfo.capabilityTable.isIntegratedDevice;
|
||||
}
|
||||
return leftHwInfo.platform.eProductFamily > rightHwInfo.platform.eProductFamily;
|
||||
});
|
||||
return outDevices;
|
||||
}
|
||||
|
|
|
@ -2130,7 +2130,7 @@ TEST(Device, givenDeviceWhenGettingMicrosecondResolutionThenCorrectValueReturned
|
|||
EXPECT_EQ(device->getMicrosecondResolution(), expectedMicrosecondResolution);
|
||||
}
|
||||
|
||||
TEST(GroupDevicesTest, whenMultipleDevicesAreCreatedThenGroupDevicesCreatesVectorPerEachProductFamily) {
|
||||
TEST(GroupDevicesTest, whenMultipleDevicesAreCreatedThenGroupDevicesCreatesVectorPerEachProductFamilySortedOverGpuTypeAndProductFamily) {
|
||||
DebugManagerStateRestore restorer;
|
||||
const size_t numRootDevices = 5u;
|
||||
|
||||
|
@ -2150,21 +2150,42 @@ TEST(GroupDevicesTest, whenMultipleDevicesAreCreatedThenGroupDevicesCreatesVecto
|
|||
auto ptl0Device = inputDevices[4].get();
|
||||
|
||||
executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo()->platform.eProductFamily = IGFX_LUNARLAKE;
|
||||
executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo()->capabilityTable.isIntegratedDevice = true;
|
||||
executionEnvironment->rootDeviceEnvironments[1]->getMutableHardwareInfo()->platform.eProductFamily = IGFX_BMG;
|
||||
executionEnvironment->rootDeviceEnvironments[1]->getMutableHardwareInfo()->capabilityTable.isIntegratedDevice = false;
|
||||
executionEnvironment->rootDeviceEnvironments[2]->getMutableHardwareInfo()->platform.eProductFamily = IGFX_LUNARLAKE;
|
||||
executionEnvironment->rootDeviceEnvironments[2]->getMutableHardwareInfo()->capabilityTable.isIntegratedDevice = true;
|
||||
executionEnvironment->rootDeviceEnvironments[3]->getMutableHardwareInfo()->platform.eProductFamily = IGFX_LUNARLAKE;
|
||||
executionEnvironment->rootDeviceEnvironments[3]->getMutableHardwareInfo()->capabilityTable.isIntegratedDevice = true;
|
||||
executionEnvironment->rootDeviceEnvironments[4]->getMutableHardwareInfo()->platform.eProductFamily = IGFX_PTL;
|
||||
executionEnvironment->rootDeviceEnvironments[4]->getMutableHardwareInfo()->capabilityTable.isIntegratedDevice = true;
|
||||
|
||||
auto groupedDevices = Device::groupDevices(std::move(inputDevices));
|
||||
|
||||
EXPECT_EQ(3u, groupedDevices.size());
|
||||
EXPECT_EQ(1u, groupedDevices[0].size());
|
||||
EXPECT_EQ(3u, groupedDevices[1].size());
|
||||
EXPECT_EQ(1u, groupedDevices[2].size());
|
||||
EXPECT_EQ(1u, groupedDevices[1].size());
|
||||
EXPECT_EQ(3u, groupedDevices[2].size());
|
||||
|
||||
EXPECT_EQ(bmg0Device, groupedDevices[2][0].get());
|
||||
EXPECT_EQ(lnl0Device, groupedDevices[1][0].get());
|
||||
EXPECT_EQ(lnl1Device, groupedDevices[1][1].get());
|
||||
EXPECT_EQ(lnl2Device, groupedDevices[1][2].get());
|
||||
EXPECT_EQ(ptl0Device, groupedDevices[0][0].get());
|
||||
EXPECT_EQ(lnl0Device, groupedDevices[2][0].get());
|
||||
EXPECT_EQ(lnl1Device, groupedDevices[2][1].get());
|
||||
EXPECT_EQ(lnl2Device, groupedDevices[2][2].get());
|
||||
EXPECT_EQ(ptl0Device, groupedDevices[1][0].get());
|
||||
EXPECT_EQ(bmg0Device, groupedDevices[0][0].get());
|
||||
}
|
||||
|
||||
TEST(GroupDevicesTest, givenEmptyDeviceVectorWhenGroupDevicesThenEmptyVectorIsReturned) {
|
||||
DeviceVector inputDevices{};
|
||||
auto groupedDevices = Device::groupDevices(std::move(inputDevices));
|
||||
|
||||
EXPECT_TRUE(groupedDevices.empty());
|
||||
}
|
||||
|
||||
TEST(GroupDevicesTest, givenNullInputInDeviceVectorWhenGroupDevicesThenEmptyVectorIsReturned) {
|
||||
DeviceVector inputDevices{};
|
||||
inputDevices.push_back(nullptr);
|
||||
inputDevices.push_back(nullptr);
|
||||
auto groupedDevices = Device::groupDevices(std::move(inputDevices));
|
||||
|
||||
EXPECT_TRUE(groupedDevices.empty());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue