mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 18:06:32 +08:00
feature: L0 Device Hierarchy support for Composite & Flat modes
Related-To: LOCI-4615 - Added Support for users to set ZE_FLAT_DEVICE_HIERARCHY to either FLAT or COMPOSITE to change how devices are returned in zeDeviceGet and clGetDeviceIDs. - COMPOSITE is default behavior that exists today. - FLAT returns all sub devices which have no sub devices and all root devices that have no sub devices in zeDeviceGet ie with all devices flattened out in order. - Added zeDeviceGetRootDevice for one to retrieve the Root Device for any SubDevice. Signed-off-by: Neil R Spruit <neil.r.spruit@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
5b80bd4d7c
commit
8efd8853fb
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/ult_hw_config.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
#include "shared/test/common/mocks/mock_io_functions.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
#include "opencl/test/unit_test/fixtures/platform_fixture.h"
|
||||
@@ -179,6 +180,41 @@ TEST(clGetDeviceIDsTest, givenReturnSubDevicesAsApiDevicesWhenCallClGetDeviceIDs
|
||||
EXPECT_EQ(devices[numEntries], dummyDevice);
|
||||
}
|
||||
|
||||
TEST(clGetDeviceIDsTest, givenZeFlatDeviceHierarchyWhenCallClGetDeviceIDsThenSubDevicesAreReturnedAsSeparateClDevices) {
|
||||
platformsImpl->clear();
|
||||
constexpr auto numRootDevices = 3u;
|
||||
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
||||
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
||||
DebugManager.flags.CreateMultipleSubDevices.set(numRootDevices);
|
||||
VariableBackup<uint32_t> mockGetenvCalledBackup(&IoFunctions::mockGetenvCalled, 0);
|
||||
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", "FLAT"}};
|
||||
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
|
||||
cl_uint maxNumDevices;
|
||||
auto retVal = clGetDeviceIDs(nullptr, CL_DEVICE_TYPE_ALL, 0, nullptr, &maxNumDevices);
|
||||
EXPECT_EQ(retVal, CL_SUCCESS);
|
||||
EXPECT_EQ(numRootDevices * numRootDevices, maxNumDevices);
|
||||
|
||||
cl_uint numDevices = 0;
|
||||
cl_uint numEntries = maxNumDevices - 1;
|
||||
cl_device_id devices[numRootDevices * numRootDevices];
|
||||
|
||||
const auto dummyDevice = reinterpret_cast<cl_device_id>(0x1357);
|
||||
for (auto i = 0u; i < maxNumDevices; i++) {
|
||||
devices[i] = dummyDevice;
|
||||
}
|
||||
|
||||
retVal = clGetDeviceIDs(nullptr, CL_DEVICE_TYPE_ALL, numEntries, devices, &numDevices);
|
||||
EXPECT_EQ(retVal, CL_SUCCESS);
|
||||
EXPECT_LT(numDevices, maxNumDevices);
|
||||
EXPECT_EQ(numEntries, numDevices);
|
||||
for (auto i = 0u; i < numEntries; i++) {
|
||||
EXPECT_EQ(devices[i], platform()->getClDevice(i / numRootDevices)->getSubDevice(i % numRootDevices));
|
||||
}
|
||||
EXPECT_EQ(devices[numEntries], dummyDevice);
|
||||
}
|
||||
|
||||
TEST(clGetDeviceIDsTest, givenMultipleRootDevicesAndLimitedNumberOfReturnedDevicesWhenGetDeviceIdsThenLimitedNumberOfRootDevicesIsReturned) {
|
||||
platformsImpl->clear();
|
||||
constexpr auto numRootDevices = 3u;
|
||||
|
||||
Reference in New Issue
Block a user