mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-25 05:24:02 +08:00
fix: respect affinity mask with COMBINED hierarchy in OCL
Related-To: GSD-9560 Signed-off-by: Jaroslaw Warchulski <jaroslaw.warchulski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
4e20673e96
commit
a180afa2e6
@@ -259,8 +259,7 @@ cl_int CL_API_CALL clGetDeviceIDs(cl_platform_id platform,
|
||||
|
||||
cl_uint retNum = 0;
|
||||
for (auto platformDeviceIndex = 0u; platformDeviceIndex < numDev; platformDeviceIndex++) {
|
||||
bool exposeSubDevices = pPlatform->peekExecutionEnvironment()->isExposingSubDevicesAsDevices() ||
|
||||
pPlatform->peekExecutionEnvironment()->isCombinedDeviceHierarchy();
|
||||
bool exposeSubDevices = pPlatform->peekExecutionEnvironment()->isExposingSubDevicesAsDevices();
|
||||
|
||||
ClDevice *device = pPlatform->getClDevice(platformDeviceIndex);
|
||||
UNRECOVERABLE_IF(device == nullptr);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2024 Intel Corporation
|
||||
* Copyright (C) 2020-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -51,7 +51,7 @@ ClDevice::ClDevice(Device &device, ClDevice &rootClDevice, Platform *platform) :
|
||||
pClSubDevice->decRefApi();
|
||||
pClSubDevice->internalParentDevice = this;
|
||||
|
||||
if (!device.getExecutionEnvironment()->isExposingSubDevicesAsDevices() && !device.getExecutionEnvironment()->isCombinedDeviceHierarchy()) {
|
||||
if (!device.getExecutionEnvironment()->isExposingSubDevicesAsDevices()) {
|
||||
auto &deviceInfo = pClSubDevice->deviceInfo;
|
||||
deviceInfo.parentDevice = this;
|
||||
deviceInfo.partitionType[0] = CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2024 Intel Corporation
|
||||
* Copyright (C) 2018-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -296,4 +296,40 @@ TEST(clGetDeviceIDsNegativeTests, whenFailToCreateDeviceThenclGetDeviceIDsReturn
|
||||
}
|
||||
}
|
||||
|
||||
TEST(clGetDeviceIDsTest, givenMultipleRootDevicesWithAffinityMaskWhenGetDeviceIdsThenCorrectDevicesAreReturned) {
|
||||
constexpr auto numRootDevices = 3u;
|
||||
VariableBackup<UltHwConfig> backup(&ultHwConfig);
|
||||
ultHwConfig.useMockedPrepareDeviceEnvironmentsFunc = false;
|
||||
DebugManagerStateRestore restorer;
|
||||
debugManager.flags.CreateMultipleRootDevices.set(numRootDevices);
|
||||
debugManager.flags.ZE_AFFINITY_MASK.set("0,1");
|
||||
cl_uint numDevices = 0;
|
||||
cl_uint numEntries = numRootDevices;
|
||||
cl_device_id devices[numRootDevices];
|
||||
|
||||
std::string hierarchies[] = {"COMPOSITE", "FLAT", "COMBINED"};
|
||||
for (std::string hierarchy : hierarchies) {
|
||||
platformsImpl->clear();
|
||||
std::unordered_map<std::string, std::string> mockableEnvs = {{"ZE_FLAT_DEVICE_HIERARCHY", hierarchy}};
|
||||
VariableBackup<std::unordered_map<std::string, std::string> *> mockableEnvValuesBackup(&IoFunctions::mockableEnvValues, &mockableEnvs);
|
||||
|
||||
const auto dummyDevice = reinterpret_cast<cl_device_id>(0x1357);
|
||||
for (auto i = 0u; i < numRootDevices; i++) {
|
||||
devices[i] = dummyDevice;
|
||||
}
|
||||
|
||||
auto retVal = clGetDeviceIDs(nullptr, CL_DEVICE_TYPE_ALL, numEntries, devices, &numDevices);
|
||||
EXPECT_EQ(retVal, CL_SUCCESS);
|
||||
EXPECT_EQ(numDevices, 2u);
|
||||
|
||||
for (auto i = 0u; i < numRootDevices; i++) {
|
||||
if (i < 2u) {
|
||||
EXPECT_EQ(devices[i], platform()->getClDevice(i));
|
||||
} else {
|
||||
EXPECT_EQ(devices[i], dummyDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ULT
|
||||
|
||||
Reference in New Issue
Block a user