Skip to content

Commit 4e4560f

Browse files
Baj, TomaszCompute-Runtime-Automation
authored andcommitted
Add cl_device_uuid_khr to getDeviceInfo.
Related-To: NEO-5681 Signed-off-by: Baj, Tomasz <tomasz.baj@intel.com>
1 parent d63a044 commit 4e4560f

File tree

4 files changed

+32
-17
lines changed

4 files changed

+32
-17
lines changed

opencl/source/cl_device/cl_device_info.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ cl_int ClDevice::getDeviceInfo(cl_device_info paramName,
6868
size_t value = 0u;
6969
ClDeviceInfoParam param{};
7070
const void *src = nullptr;
71+
std::array<uint8_t, HwInfoConfig::uuidSize> deviceUuid;
7172

7273
// clang-format off
7374
// please keep alphabetical order
@@ -292,6 +293,12 @@ cl_int ClDevice::getDeviceInfo(cl_device_info paramName,
292293
retSize = srcSize = sizeof(deviceInfo.pciBusInfo);
293294
}
294295
break;
296+
case CL_DEVICE_UUID_KHR: {
297+
device.generateUuid(deviceUuid);
298+
src = &deviceUuid;
299+
retSize = srcSize = sizeof(deviceUuid);
300+
break;
301+
}
295302
default:
296303
if (getDeviceInfoForImage(paramName, src, srcSize, retSize) && !getSharedDeviceInfo().imageSupport) {
297304
src = &value;

opencl/test/unit_test/device/get_device_info_tests.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,18 @@ TEST(GetDeviceInfoTest, givenPciBusInfoIsNotAvailableWhenGettingPciBusInfoForDev
10421042
ASSERT_EQ(retVal, CL_INVALID_VALUE);
10431043
}
10441044

1045+
TEST(GetDeviceInfo, givenDeviceUuidWhenGettingDeviceInfoThenGenerateDeviceUuid) {
1046+
std::array<uint8_t, HwInfoConfig::uuidSize> generateDeviceUuid, deviceUuidKHR;
1047+
size_t retSize = 0;
1048+
1049+
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
1050+
auto retVal = device->getDeviceInfo(CL_DEVICE_UUID_KHR, sizeof(deviceUuidKHR), &deviceUuidKHR, &retSize);
1051+
ASSERT_EQ(retVal, CL_SUCCESS);
1052+
1053+
device.get()->getDevice().generateUuid(generateDeviceUuid);
1054+
EXPECT_EQ(generateDeviceUuid, deviceUuidKHR);
1055+
}
1056+
10451057
struct DeviceAttributeQueryTest : public ::testing::TestWithParam<uint32_t /*cl_device_info*/> {
10461058
void SetUp() override {
10471059
param = GetParam();

shared/test/unit_test/device/neo_device_tests.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,19 @@ TEST_F(DeviceTest, whenAllocateRTDispatchGlobalsIsCalledThenRTDispatchGlobalsIsA
8686
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(3));
8787
}
8888

89+
TEST_F(DeviceTest, GivenDeviceWhenGenerateUuidThenValidValuesAreSet) {
90+
std::array<uint8_t, HwInfoConfig::uuidSize> uuid, expectedUuid;
91+
pDevice->generateUuid(uuid);
92+
uint32_t rootDeviceIndex = pDevice->getRootDeviceIndex();
93+
94+
expectedUuid.fill(0);
95+
memcpy_s(&expectedUuid[0], sizeof(uint32_t), &pDevice->getDeviceInfo().vendorId, sizeof(pDevice->getDeviceInfo().vendorId));
96+
memcpy_s(&expectedUuid[4], sizeof(uint32_t), &pDevice->getHardwareInfo().platform.usDeviceID, sizeof(pDevice->getHardwareInfo().platform.usDeviceID));
97+
memcpy_s(&expectedUuid[8], sizeof(uint32_t), &rootDeviceIndex, sizeof(rootDeviceIndex));
98+
99+
EXPECT_EQ(memcmp(&uuid, &expectedUuid, HwInfoConfig::uuidSize), 0);
100+
}
101+
89102
using DeviceGetCapsTest = Test<DeviceFixture>;
90103

91104
TEST_F(DeviceGetCapsTest, givenMockCompilerInterfaceWhenInitializeCapsIsCalledThenMaxParameterSizeIsSetCorrectly) {

shared/test/unit_test/os_interface/device_uuid_tests.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -219,21 +219,4 @@ HWTEST2_F(DeviceUuidEnablementTest, GivenEnableChipsetUniqueUUIDIsDisabledWhenDe
219219
EXPECT_EQ(true, deviceFactory->rootDevices[0]->getUuid(uuid));
220220
EXPECT_FALSE(0 == std::memcmp(uuid.data(), expectedUuid.data(), 16));
221221
}
222-
223-
using DeviceTest = Test<DeviceFixture>;
224-
225-
HWTEST2_F(DeviceTest, GivenDeviceWhenGenerateUuidThenValidValuesAreSet, MatchAny) {
226-
227-
std::array<uint8_t, NEO::HwInfoConfig::uuidSize> uuid, expectedUuid;
228-
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
229-
device->generateUuid(uuid);
230-
uint32_t rootDeviceIndex = device->getRootDeviceIndex();
231-
232-
expectedUuid.fill(0);
233-
memcpy_s(&expectedUuid[0], sizeof(uint32_t), &device->getDeviceInfo().vendorId, sizeof(device->getDeviceInfo().vendorId));
234-
memcpy_s(&expectedUuid[4], sizeof(uint32_t), &device->getHardwareInfo().platform.usDeviceID, sizeof(device->getHardwareInfo().platform.usDeviceID));
235-
memcpy_s(&expectedUuid[8], sizeof(uint32_t), &rootDeviceIndex, sizeof(rootDeviceIndex));
236-
237-
EXPECT_EQ(memcmp(&uuid, &expectedUuid, NEO::HwInfoConfig::uuidSize), 0);
238-
}
239222
} // namespace NEO

0 commit comments

Comments
 (0)