Return correct device name in L0

With this commit L0 driver will report the same device name as OpenCL
driver

Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
Maciej Plewka
2022-05-11 15:40:35 +00:00
committed by Compute-Runtime-Automation
parent be908f4695
commit b0d84f88d7
2 changed files with 25 additions and 0 deletions

View File

@@ -655,6 +655,9 @@ ze_result_t DeviceImp::getProperties(ze_device_properties_t *pDeviceProperties)
memset(pDeviceProperties->name, 0, ZE_MAX_DEVICE_NAME);
std::string name = getNEODevice()->getDeviceInfo().name;
if (driverInfo) {
name.assign(driverInfo->getDeviceName(name).c_str());
}
memcpy_s(pDeviceProperties->name, name.length(), name.c_str(), name.length());
return ZE_RESULT_SUCCESS;

View File

@@ -993,6 +993,28 @@ TEST_F(DeviceTest, givenDevicePropertiesStructureWhenDevicePropertiesCalledThenA
EXPECT_NE(deviceProperties.maxMemAllocSize, devicePropertiesBefore.maxMemAllocSize);
}
TEST_F(DeviceTest, givenDevicePropertiesStructureWhenDriverInfoIsEmptyThenDeviceNameTheSameAsInDeviceInfo) {
auto deviceImp = static_cast<DeviceImp *>(device);
ze_device_properties_t deviceProperties;
auto name = device->getNEODevice()->getDeviceInfo().name;
deviceImp->driverInfo.reset();
deviceImp->getProperties(&deviceProperties);
EXPECT_STREQ(deviceProperties.name, name.c_str());
}
TEST_F(DeviceTest, givenDevicePropertiesStructureWhenDriverInfoIsNotEmptyThenDeviceNameTheSameAsInDriverInfo) {
auto deviceImp = static_cast<DeviceImp *>(device);
ze_device_properties_t deviceProperties;
auto driverInfo = std::make_unique<DriverInfoMock>();
std::string customDevName = "Custom device name";
auto name = device->getNEODevice()->getDeviceInfo().name;
driverInfo->setDeviceName(customDevName);
deviceImp->driverInfo.reset(driverInfo.release());
deviceImp->getProperties(&deviceProperties);
EXPECT_STREQ(deviceProperties.name, customDevName.c_str());
EXPECT_STRNE(deviceProperties.name, name.c_str());
}
TEST_F(DeviceTest, WhenGettingDevicePropertiesThenSubslicesPerSliceIsBasedOnSubslicesSupported) {
ze_device_properties_t deviceProperties = {ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES};
deviceProperties.type = ZE_DEVICE_TYPE_GPU;