mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Add cl_device_uuid_khr to getDeviceInfo.
Related-To: NEO-5681 Signed-off-by: Baj, Tomasz <tomasz.baj@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
d63a044e60
commit
4e4560fe91
@ -68,6 +68,7 @@ cl_int ClDevice::getDeviceInfo(cl_device_info paramName,
|
||||
size_t value = 0u;
|
||||
ClDeviceInfoParam param{};
|
||||
const void *src = nullptr;
|
||||
std::array<uint8_t, HwInfoConfig::uuidSize> deviceUuid;
|
||||
|
||||
// clang-format off
|
||||
// please keep alphabetical order
|
||||
@ -292,6 +293,12 @@ cl_int ClDevice::getDeviceInfo(cl_device_info paramName,
|
||||
retSize = srcSize = sizeof(deviceInfo.pciBusInfo);
|
||||
}
|
||||
break;
|
||||
case CL_DEVICE_UUID_KHR: {
|
||||
device.generateUuid(deviceUuid);
|
||||
src = &deviceUuid;
|
||||
retSize = srcSize = sizeof(deviceUuid);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (getDeviceInfoForImage(paramName, src, srcSize, retSize) && !getSharedDeviceInfo().imageSupport) {
|
||||
src = &value;
|
||||
|
@ -1042,6 +1042,18 @@ TEST(GetDeviceInfoTest, givenPciBusInfoIsNotAvailableWhenGettingPciBusInfoForDev
|
||||
ASSERT_EQ(retVal, CL_INVALID_VALUE);
|
||||
}
|
||||
|
||||
TEST(GetDeviceInfo, givenDeviceUuidWhenGettingDeviceInfoThenGenerateDeviceUuid) {
|
||||
std::array<uint8_t, HwInfoConfig::uuidSize> generateDeviceUuid, deviceUuidKHR;
|
||||
size_t retSize = 0;
|
||||
|
||||
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
|
||||
auto retVal = device->getDeviceInfo(CL_DEVICE_UUID_KHR, sizeof(deviceUuidKHR), &deviceUuidKHR, &retSize);
|
||||
ASSERT_EQ(retVal, CL_SUCCESS);
|
||||
|
||||
device.get()->getDevice().generateUuid(generateDeviceUuid);
|
||||
EXPECT_EQ(generateDeviceUuid, deviceUuidKHR);
|
||||
}
|
||||
|
||||
struct DeviceAttributeQueryTest : public ::testing::TestWithParam<uint32_t /*cl_device_info*/> {
|
||||
void SetUp() override {
|
||||
param = GetParam();
|
||||
|
@ -86,6 +86,19 @@ TEST_F(DeviceTest, whenAllocateRTDispatchGlobalsIsCalledThenRTDispatchGlobalsIsA
|
||||
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(3));
|
||||
}
|
||||
|
||||
TEST_F(DeviceTest, GivenDeviceWhenGenerateUuidThenValidValuesAreSet) {
|
||||
std::array<uint8_t, HwInfoConfig::uuidSize> uuid, expectedUuid;
|
||||
pDevice->generateUuid(uuid);
|
||||
uint32_t rootDeviceIndex = pDevice->getRootDeviceIndex();
|
||||
|
||||
expectedUuid.fill(0);
|
||||
memcpy_s(&expectedUuid[0], sizeof(uint32_t), &pDevice->getDeviceInfo().vendorId, sizeof(pDevice->getDeviceInfo().vendorId));
|
||||
memcpy_s(&expectedUuid[4], sizeof(uint32_t), &pDevice->getHardwareInfo().platform.usDeviceID, sizeof(pDevice->getHardwareInfo().platform.usDeviceID));
|
||||
memcpy_s(&expectedUuid[8], sizeof(uint32_t), &rootDeviceIndex, sizeof(rootDeviceIndex));
|
||||
|
||||
EXPECT_EQ(memcmp(&uuid, &expectedUuid, HwInfoConfig::uuidSize), 0);
|
||||
}
|
||||
|
||||
using DeviceGetCapsTest = Test<DeviceFixture>;
|
||||
|
||||
TEST_F(DeviceGetCapsTest, givenMockCompilerInterfaceWhenInitializeCapsIsCalledThenMaxParameterSizeIsSetCorrectly) {
|
||||
|
@ -219,21 +219,4 @@ HWTEST2_F(DeviceUuidEnablementTest, GivenEnableChipsetUniqueUUIDIsDisabledWhenDe
|
||||
EXPECT_EQ(true, deviceFactory->rootDevices[0]->getUuid(uuid));
|
||||
EXPECT_FALSE(0 == std::memcmp(uuid.data(), expectedUuid.data(), 16));
|
||||
}
|
||||
|
||||
using DeviceTest = Test<DeviceFixture>;
|
||||
|
||||
HWTEST2_F(DeviceTest, GivenDeviceWhenGenerateUuidThenValidValuesAreSet, MatchAny) {
|
||||
|
||||
std::array<uint8_t, NEO::HwInfoConfig::uuidSize> uuid, expectedUuid;
|
||||
auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
|
||||
device->generateUuid(uuid);
|
||||
uint32_t rootDeviceIndex = device->getRootDeviceIndex();
|
||||
|
||||
expectedUuid.fill(0);
|
||||
memcpy_s(&expectedUuid[0], sizeof(uint32_t), &device->getDeviceInfo().vendorId, sizeof(device->getDeviceInfo().vendorId));
|
||||
memcpy_s(&expectedUuid[4], sizeof(uint32_t), &device->getHardwareInfo().platform.usDeviceID, sizeof(device->getHardwareInfo().platform.usDeviceID));
|
||||
memcpy_s(&expectedUuid[8], sizeof(uint32_t), &rootDeviceIndex, sizeof(rootDeviceIndex));
|
||||
|
||||
EXPECT_EQ(memcmp(&uuid, &expectedUuid, NEO::HwInfoConfig::uuidSize), 0);
|
||||
}
|
||||
} // namespace NEO
|
||||
|
Reference in New Issue
Block a user