mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
refactor: move groupDevices logic to shared code
update platforms used in unit test Related-To: NEO-14062 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
c7c7ae9d49
commit
6ec92ac082
@@ -105,7 +105,7 @@ cl_int CL_API_CALL clGetPlatformIDs(cl_uint numEntries,
|
||||
retVal = CL_OUT_OF_HOST_MEMORY;
|
||||
break;
|
||||
}
|
||||
auto groupedDevices = Platform::groupDevices(std::move(allDevices));
|
||||
auto groupedDevices = Device::groupDevices(std::move(allDevices));
|
||||
for (auto &deviceVector : groupedDevices) {
|
||||
|
||||
auto pPlatform = Platform::createFunc(*executionEnvironment);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
* Copyright (C) 2018-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -243,23 +243,4 @@ std::unique_ptr<Platform> (*Platform::createFunc)(ExecutionEnvironment &) = [](E
|
||||
return std::make_unique<Platform>(executionEnvironment);
|
||||
};
|
||||
|
||||
std::vector<DeviceVector> Platform::groupDevices(DeviceVector devices) {
|
||||
std::map<PRODUCT_FAMILY, size_t> platformsMap;
|
||||
std::vector<DeviceVector> outDevices;
|
||||
for (auto &device : devices) {
|
||||
auto productFamily = device->getHardwareInfo().platform.eProductFamily;
|
||||
auto result = platformsMap.find(productFamily);
|
||||
if (result == platformsMap.end()) {
|
||||
platformsMap.insert({productFamily, platformsMap.size()});
|
||||
outDevices.push_back(DeviceVector{});
|
||||
}
|
||||
auto platformId = platformsMap[productFamily];
|
||||
outDevices[platformId].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)
|
||||
});
|
||||
return outDevices;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
* Copyright (C) 2018-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -57,7 +57,6 @@ class Platform : public BaseObject<_cl_platform_id> {
|
||||
ExecutionEnvironment *peekExecutionEnvironment() const { return &executionEnvironment; }
|
||||
|
||||
static std::unique_ptr<Platform> (*createFunc)(ExecutionEnvironment &executionEnvironment);
|
||||
static std::vector<DeviceVector> groupDevices(DeviceVector devices);
|
||||
|
||||
protected:
|
||||
enum {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
* Copyright (C) 2018-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -438,42 +438,3 @@ TEST(PlatformInitTest, GivenPreferredPlatformNameWhenPlatformIsInitializedThenOv
|
||||
EXPECT_TRUE(status);
|
||||
EXPECT_STREQ("Overridden Platform Name", platform()->getPlatformInfo().name.c_str());
|
||||
}
|
||||
|
||||
TEST(PlatformGroupDevicesTest, whenMultipleDevicesAreCreatedThenGroupDevicesCreatesVectorPerEachProductFamily) {
|
||||
DebugManagerStateRestore restorer;
|
||||
const size_t numRootDevices = 5u;
|
||||
|
||||
debugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
||||
auto executionEnvironment = new ExecutionEnvironment();
|
||||
|
||||
for (auto i = 0u; i < numRootDevices; i++) {
|
||||
executionEnvironment->rootDeviceEnvironments.push_back(std::make_unique<MockRootDeviceEnvironment>(*executionEnvironment));
|
||||
}
|
||||
auto inputDevices = DeviceFactory::createDevices(*executionEnvironment);
|
||||
EXPECT_EQ(numRootDevices, inputDevices.size());
|
||||
|
||||
auto skl0Device = inputDevices[0].get();
|
||||
auto kbl0Device = inputDevices[1].get();
|
||||
auto skl1Device = inputDevices[2].get();
|
||||
auto skl2Device = inputDevices[3].get();
|
||||
auto cfl0Device = inputDevices[4].get();
|
||||
|
||||
executionEnvironment->rootDeviceEnvironments[0]->getMutableHardwareInfo()->platform.eProductFamily = IGFX_SKYLAKE;
|
||||
executionEnvironment->rootDeviceEnvironments[1]->getMutableHardwareInfo()->platform.eProductFamily = IGFX_KABYLAKE;
|
||||
executionEnvironment->rootDeviceEnvironments[2]->getMutableHardwareInfo()->platform.eProductFamily = IGFX_SKYLAKE;
|
||||
executionEnvironment->rootDeviceEnvironments[3]->getMutableHardwareInfo()->platform.eProductFamily = IGFX_SKYLAKE;
|
||||
executionEnvironment->rootDeviceEnvironments[4]->getMutableHardwareInfo()->platform.eProductFamily = IGFX_COFFEELAKE;
|
||||
|
||||
auto groupedDevices = Platform::groupDevices(std::move(inputDevices));
|
||||
|
||||
EXPECT_EQ(3u, groupedDevices.size());
|
||||
EXPECT_EQ(1u, groupedDevices[0].size());
|
||||
EXPECT_EQ(1u, groupedDevices[1].size());
|
||||
EXPECT_EQ(3u, groupedDevices[2].size());
|
||||
|
||||
EXPECT_EQ(skl0Device, groupedDevices[2][0].get());
|
||||
EXPECT_EQ(skl1Device, groupedDevices[2][1].get());
|
||||
EXPECT_EQ(skl2Device, groupedDevices[2][2].get());
|
||||
EXPECT_EQ(kbl0Device, groupedDevices[1][0].get());
|
||||
EXPECT_EQ(cfl0Device, groupedDevices[0][0].get());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user