Framework for adding custom device names

- Add new macro to define custom name
- Add handling for custom name
- Remove gen from generic name

Resolves: NEO-5251

Signed-off-by: Adam Cetnerowski <adam.cetnerowski@intel.com>
This commit is contained in:
Adam Cetnerowski
2020-11-09 17:35:33 +00:00
committed by Compute-Runtime-Automation
parent 8a4bf3782a
commit 154f7e87be
22 changed files with 38 additions and 84 deletions

View File

@ -24,9 +24,11 @@
namespace NEO { namespace NEO {
const DeviceDescriptor deviceDescriptorTable[] = { const DeviceDescriptor deviceDescriptorTable[] = {
#define DEVICE(devId, gt, gtType) {devId, &gt::hwInfo, &gt::setupHardwareInfo, gtType}, #define NAMEDDEVICE(devId, gt, gtType, devName) {devId, &gt::hwInfo, &gt::setupHardwareInfo, gtType, devName},
#define DEVICE(devId, gt, gtType) {devId, &gt::hwInfo, &gt::setupHardwareInfo, gtType, ""},
#include "devices.inl" #include "devices.inl"
#undef DEVICE #undef DEVICE
#undef NAMEDDEVICE
{0, nullptr, nullptr, GTTYPE_UNDEFINED}}; {0, nullptr, nullptr, GTTYPE_UNDEFINED}};
Drm *Drm::create(std::unique_ptr<HwDeviceId> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) { Drm *Drm::create(std::unique_ptr<HwDeviceId> hwDeviceId, RootDeviceEnvironment &rootDeviceEnvironment) {
@ -52,11 +54,13 @@ Drm *Drm::create(std::unique_ptr<HwDeviceId> hwDeviceId, RootDeviceEnvironment &
} }
const DeviceDescriptor *device = nullptr; const DeviceDescriptor *device = nullptr;
const char *devName = "";
GTTYPE eGtType = GTTYPE_UNDEFINED; GTTYPE eGtType = GTTYPE_UNDEFINED;
for (auto &d : deviceDescriptorTable) { for (auto &d : deviceDescriptorTable) {
if (drmObject->deviceId == d.deviceId) { if (drmObject->deviceId == d.deviceId) {
device = &d; device = &d;
eGtType = d.eGtType; eGtType = d.eGtType;
devName = d.devName;
break; break;
} }
} }
@ -67,6 +71,7 @@ Drm *Drm::create(std::unique_ptr<HwDeviceId> hwDeviceId, RootDeviceEnvironment &
} }
drmObject->setGtType(eGtType); drmObject->setGtType(eGtType);
rootDeviceEnvironment.setHwInfo(device->pHwInfo); rootDeviceEnvironment.setHwInfo(device->pHwInfo);
rootDeviceEnvironment.getMutableHardwareInfo()->capabilityTable.deviceName = devName;
} else { } else {
printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr, printDebugString(DebugManager.flags.PrintDebugMessages.get(), stderr,
"FATAL: Unknown device: deviceId: %04x, revisionId: %04x\n", drmObject->deviceId, drmObject->revisionId); "FATAL: Unknown device: deviceId: %04x, revisionId: %04x\n", drmObject->deviceId, drmObject->revisionId);

View File

@ -66,6 +66,7 @@ const RuntimeCapabilityTable EHL::capabilityTable{
true, // instrumentationEnabled true, // instrumentationEnabled
true, // forceStatelessCompilationFor32Bit true, // forceStatelessCompilationFor32Bit
"lp", // platformType "lp", // platformType
"", // deviceName
true, // sourceLevelDebuggerSupported true, // sourceLevelDebuggerSupported
false, // supportsVme false, // supportsVme
false, // supportCacheFlushAfterWalker false, // supportCacheFlushAfterWalker

View File

@ -67,6 +67,7 @@ const RuntimeCapabilityTable ICLLP::capabilityTable{
true, // instrumentationEnabled true, // instrumentationEnabled
true, // forceStatelessCompilationFor32Bit true, // forceStatelessCompilationFor32Bit
"lp", // platformType "lp", // platformType
"", // deviceName
true, // sourceLevelDebuggerSupported true, // sourceLevelDebuggerSupported
true, // supportsVme true, // supportsVme
false, // supportCacheFlushAfterWalker false, // supportCacheFlushAfterWalker
@ -78,7 +79,7 @@ const RuntimeCapabilityTable ICLLP::capabilityTable{
true, // supportsIndependentForwardProgress true, // supportsIndependentForwardProgress
true, // hostPtrTrackingEnabled true, // hostPtrTrackingEnabled
true, // levelZeroSupported true, // levelZeroSupported
true // isIntegratedDevice true, // isIntegratedDevice
}; };
WorkaroundTable ICLLP::workaroundTable = {}; WorkaroundTable ICLLP::workaroundTable = {};

View File

@ -66,6 +66,7 @@ const RuntimeCapabilityTable LKF::capabilityTable{
true, // instrumentationEnabled true, // instrumentationEnabled
true, // forceStatelessCompilationFor32Bit true, // forceStatelessCompilationFor32Bit
"lp", // platformType "lp", // platformType
"", // deviceName
true, // sourceLevelDebuggerSupported true, // sourceLevelDebuggerSupported
false, // supportsVme false, // supportsVme
false, // supportCacheFlushAfterWalker false, // supportCacheFlushAfterWalker

View File

@ -68,6 +68,7 @@ const RuntimeCapabilityTable ADLS::capabilityTable{
true, // forceStatelessCompilationFor32Bit true, // forceStatelessCompilationFor32Bit
true, // ftr64KBpages true, // ftr64KBpages
"lp", // platformType "lp", // platformType
"", // deviceName
true, // sourceLevelDebuggerSupported true, // sourceLevelDebuggerSupported
false, // supportsVme false, // supportsVme
false, // supportCacheFlushAfterWalker false, // supportCacheFlushAfterWalker

View File

@ -72,6 +72,7 @@ const RuntimeCapabilityTable DG1::capabilityTable{
true, // instrumentationEnabled true, // instrumentationEnabled
true, // forceStatelessCompilationFor32Bit true, // forceStatelessCompilationFor32Bit
"lp", // platformType "lp", // platformType
"", // deviceName
true, // sourceLevelDebuggerSupported true, // sourceLevelDebuggerSupported
false, // supportsVme false, // supportsVme
true, // supportCacheFlushAfterWalker true, // supportCacheFlushAfterWalker

View File

@ -64,6 +64,7 @@ const RuntimeCapabilityTable RKL::capabilityTable{
true, // instrumentationEnabled true, // instrumentationEnabled
true, // forceStatelessCompilationFor32Bit true, // forceStatelessCompilationFor32Bit
"lp", // platformType "lp", // platformType
"", // deviceName
true, // sourceLevelDebuggerSupported true, // sourceLevelDebuggerSupported
false, // supportsVme false, // supportsVme
false, // supportCacheFlushAfterWalker false, // supportCacheFlushAfterWalker

View File

@ -68,6 +68,7 @@ const RuntimeCapabilityTable TGLLP::capabilityTable{
true, // forceStatelessCompilationFor32Bit true, // forceStatelessCompilationFor32Bit
true, // ftr64KBpages true, // ftr64KBpages
"lp", // platformType "lp", // platformType
"", // deviceName
true, // sourceLevelDebuggerSupported true, // sourceLevelDebuggerSupported
false, // supportsVme false, // supportsVme
false, // supportCacheFlushAfterWalker false, // supportCacheFlushAfterWalker

View File

@ -71,6 +71,7 @@ const RuntimeCapabilityTable BDW::capabilityTable{
true, // instrumentationEnabled true, // instrumentationEnabled
true, // forceStatelessCompilationFor32Bit true, // forceStatelessCompilationFor32Bit
"core", // platformType "core", // platformType
"", // deviceName
false, // sourceLevelDebuggerSupported false, // sourceLevelDebuggerSupported
false, // supportsVme false, // supportsVme
false, // supportCacheFlushAfterWalker false, // supportCacheFlushAfterWalker

View File

@ -68,6 +68,7 @@ const RuntimeCapabilityTable BXT::capabilityTable{
true, // instrumentationEnabled true, // instrumentationEnabled
false, // forceStatelessCompilationFor32Bit false, // forceStatelessCompilationFor32Bit
"lp", // platformType "lp", // platformType
"", // deviceName
true, // sourceLevelDebuggerSupported true, // sourceLevelDebuggerSupported
true, // supportsVme true, // supportsVme
false, // supportCacheFlushAfterWalker false, // supportCacheFlushAfterWalker

View File

@ -63,6 +63,7 @@ const RuntimeCapabilityTable CFL::capabilityTable{
true, // instrumentationEnabled true, // instrumentationEnabled
true, // forceStatelessCompilationFor32Bit true, // forceStatelessCompilationFor32Bit
"core", // platformType "core", // platformType
"", // deviceName
true, // sourceLevelDebuggerSupported true, // sourceLevelDebuggerSupported
true, // supportsVme true, // supportsVme
false, // supportCacheFlushAfterWalker false, // supportCacheFlushAfterWalker

View File

@ -63,6 +63,7 @@ const RuntimeCapabilityTable GLK::capabilityTable{
true, // instrumentationEnabled true, // instrumentationEnabled
false, // forceStatelessCompilationFor32Bit false, // forceStatelessCompilationFor32Bit
"lp", // platformType "lp", // platformType
"", // deviceName
true, // sourceLevelDebuggerSupported true, // sourceLevelDebuggerSupported
true, // supportsVme true, // supportsVme
false, // supportCacheFlushAfterWalker false, // supportCacheFlushAfterWalker

View File

@ -63,6 +63,7 @@ const RuntimeCapabilityTable KBL::capabilityTable{
true, // instrumentationEnabled true, // instrumentationEnabled
true, // forceStatelessCompilationFor32Bit true, // forceStatelessCompilationFor32Bit
"core", // platformType "core", // platformType
"", // deviceName
true, // sourceLevelDebuggerSupported true, // sourceLevelDebuggerSupported
true, // supportsVme true, // supportsVme
false, // supportCacheFlushAfterWalker false, // supportCacheFlushAfterWalker

View File

@ -71,6 +71,7 @@ const RuntimeCapabilityTable SKL::capabilityTable{
true, // instrumentationEnabled true, // instrumentationEnabled
true, // forceStatelessCompilationFor32Bit true, // forceStatelessCompilationFor32Bit
"core", // platformType "core", // platformType
"", // deviceName
true, // sourceLevelDebuggerSupported true, // sourceLevelDebuggerSupported
true, // supportsVme true, // supportsVme
false, // supportCacheFlushAfterWalker false, // supportCacheFlushAfterWalker
@ -84,6 +85,7 @@ const RuntimeCapabilityTable SKL::capabilityTable{
true, // levelZeroSupported true, // levelZeroSupported
true // isIntegratedDevice true // isIntegratedDevice
}; };
WorkaroundTable SKL::workaroundTable = {}; WorkaroundTable SKL::workaroundTable = {};
FeatureTable SKL::featureTable = {}; FeatureTable SKL::featureTable = {};
void SKL::setupFeatureAndWorkaroundTable(HardwareInfo *hwInfo) { void SKL::setupFeatureAndWorkaroundTable(HardwareInfo *hwInfo) {

View File

@ -13,18 +13,9 @@ set(IGDRCL_SRCS_tests_device
${CMAKE_CURRENT_SOURCE_DIR}/get_device_info_size_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/get_device_info_size_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/get_device_info_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/get_device_info_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sub_device_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/sub_device_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/get_device_name_tests.cpp
) )
if(SUPPORT_DG1 AND "${BRANCH_TYPE}" STREQUAL "")
list(APPEND IGDRCL_SRCS_tests_device
${CMAKE_CURRENT_SOURCE_DIR}/get_device_name_tests_dg1.cpp
)
else()
list(APPEND IGDRCL_SRCS_tests_device
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/get_device_name_tests.cpp
)
endif()
if(WIN32) if(WIN32)
list(APPEND IGDRCL_SRCS_tests_device list(APPEND IGDRCL_SRCS_tests_device
${CMAKE_CURRENT_SOURCE_DIR}/device_win_timers_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/device_win_timers_tests.cpp

View File

@ -23,8 +23,7 @@ using DeviceNameTest = ::testing::Test;
TEST_F(DeviceNameTest, WhenCallingGetClDeviceNameThenReturnDeviceNameWithDeviceIdAppendedAtTheEnd) { TEST_F(DeviceNameTest, WhenCallingGetClDeviceNameThenReturnDeviceNameWithDeviceIdAppendedAtTheEnd) {
auto clDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get())); auto clDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
std::string deviceName = "Intel(R) Graphics "; std::string deviceName = "Intel(R) Graphics";
deviceName += familyName[defaultHwInfo->platform.eRenderCoreFamily];
EXPECT_STREQ(deviceName.c_str(), clDevice->device.getDeviceName(*defaultHwInfo.get()).c_str()); EXPECT_STREQ(deviceName.c_str(), clDevice->device.getDeviceName(*defaultHwInfo.get()).c_str());
std::stringstream clDeviceName; std::stringstream clDeviceName;
@ -32,3 +31,13 @@ TEST_F(DeviceNameTest, WhenCallingGetClDeviceNameThenReturnDeviceNameWithDeviceI
clDeviceName << " [0x" << std::hex << std::setw(4) << std::setfill('0') << defaultHwInfo->platform.usDeviceID << "]"; clDeviceName << " [0x" << std::hex << std::setw(4) << std::setfill('0') << defaultHwInfo->platform.usDeviceID << "]";
EXPECT_STREQ(clDeviceName.str().c_str(), clDevice->getClDeviceName(*defaultHwInfo.get()).c_str()); EXPECT_STREQ(clDeviceName.str().c_str(), clDevice->getClDeviceName(*defaultHwInfo.get()).c_str());
} }
TEST_F(DeviceNameTest, GivenDeviceWithNameWhenCallingGetClDeviceNameThenReturnCustomDeviceName) {
HardwareInfo localHwInfo = *defaultHwInfo;
localHwInfo.capabilityTable.deviceName = "Custom Device";
auto clDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&localHwInfo));
std::string deviceName = "Custom Device";
EXPECT_STREQ(deviceName.c_str(), clDevice->device.getDeviceName(localHwInfo).c_str());
}

View File

@ -1,36 +0,0 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/unit_test/helpers/default_hw_info.h"
#include "shared/test/unit_test/mocks/mock_device.h"
#include "opencl/test/unit_test/mocks/mock_cl_device.h"
#include "gtest/gtest.h"
namespace NEO {
extern const char *familyName[];
} // namespace NEO
using namespace NEO;
using DeviceNameTest = ::testing::Test;
TEST_F(DeviceNameTest, WhenCallingGetClDeviceNameThenReturnDeviceNameWithDeviceIdAppendedAtTheEnd) {
auto clDevice = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(defaultHwInfo.get()));
std::string deviceName = "Intel(R) Graphics";
if (defaultHwInfo->platform.eProductFamily < PRODUCT_FAMILY::IGFX_DG1) {
deviceName += std::string(" ") + familyName[defaultHwInfo->platform.eRenderCoreFamily];
}
EXPECT_STREQ(deviceName.c_str(), clDevice->device.getDeviceName(*defaultHwInfo.get()).c_str());
std::stringstream clDeviceName;
clDeviceName << deviceName;
clDeviceName << " [0x" << std::hex << std::setw(4) << std::setfill('0') << defaultHwInfo->platform.usDeviceID << "]";
EXPECT_STREQ(clDeviceName.str().c_str(), clDevice->getClDeviceName(*defaultHwInfo.get()).c_str());
}

View File

@ -15,17 +15,8 @@ set(NEO_CORE_DEVICE
${CMAKE_CURRENT_SOURCE_DIR}/root_device.h ${CMAKE_CURRENT_SOURCE_DIR}/root_device.h
${CMAKE_CURRENT_SOURCE_DIR}/sub_device.cpp ${CMAKE_CURRENT_SOURCE_DIR}/sub_device.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sub_device.h ${CMAKE_CURRENT_SOURCE_DIR}/sub_device.h
${CMAKE_CURRENT_SOURCE_DIR}/device_get_device_name.cpp
) )
if(SUPPORT_DG1 AND "${BRANCH_TYPE}" STREQUAL "")
list(APPEND NEO_CORE_DEVICE
${CMAKE_CURRENT_SOURCE_DIR}/device_get_device_name_dg1.cpp
)
else()
list(APPEND NEO_CORE_DEVICE
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/device_get_device_name.cpp
)
endif()
set_property(GLOBAL PROPERTY NEO_CORE_DEVICE ${NEO_CORE_DEVICE}) set_property(GLOBAL PROPERTY NEO_CORE_DEVICE ${NEO_CORE_DEVICE})
add_subdirectories() add_subdirectories()

View File

@ -11,8 +11,6 @@
namespace NEO { namespace NEO {
const std::string Device::getDeviceName(const HardwareInfo &hwInfo) const { const std::string Device::getDeviceName(const HardwareInfo &hwInfo) const {
std::string deviceName = "Intel(R) Graphics "; return std::string(hwInfo.capabilityTable.deviceName).empty() ? "Intel(R) Graphics" : hwInfo.capabilityTable.deviceName;
deviceName += familyName[hwInfo.platform.eRenderCoreFamily];
return deviceName;
} }
} // namespace NEO } // namespace NEO

View File

@ -1,20 +0,0 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/device/device.h"
#include "shared/source/helpers/hw_info.h"
namespace NEO {
const std::string Device::getDeviceName(const HardwareInfo &hwInfo) const {
std::string deviceName = "Intel(R) Graphics";
if (hwInfo.platform.eProductFamily < PRODUCT_FAMILY::IGFX_DG1) {
deviceName += std::string(" ") + familyName[hwInfo.platform.eRenderCoreFamily];
}
return deviceName;
}
} // namespace NEO

View File

@ -51,6 +51,7 @@ struct RuntimeCapabilityTable {
bool instrumentationEnabled; bool instrumentationEnabled;
bool forceStatelessCompilationFor32Bit; bool forceStatelessCompilationFor32Bit;
const char *platformType; const char *platformType;
const char *deviceName;
bool debuggerSupported; bool debuggerSupported;
bool supportsVme; bool supportsVme;
bool supportCacheFlushAfterWalker; bool supportCacheFlushAfterWalker;
@ -82,7 +83,7 @@ struct HardwareInfo {
WorkaroundTable workaroundTable = {}; WorkaroundTable workaroundTable = {};
alignas(4) GT_SYSTEM_INFO gtSystemInfo = {}; alignas(4) GT_SYSTEM_INFO gtSystemInfo = {};
RuntimeCapabilityTable capabilityTable = {}; alignas(8) RuntimeCapabilityTable capabilityTable = {};
}; };
template <PRODUCT_FAMILY product> template <PRODUCT_FAMILY product>

View File

@ -43,6 +43,7 @@ struct DeviceDescriptor { // NOLINT(clang-analyzer-optin.performance.Padding)
const HardwareInfo *pHwInfo; const HardwareInfo *pHwInfo;
void (*setupHardwareInfo)(HardwareInfo *, bool); void (*setupHardwareInfo)(HardwareInfo *, bool);
GTTYPE eGtType; GTTYPE eGtType;
const char *devName;
}; };
extern const DeviceDescriptor deviceDescriptorTable[]; extern const DeviceDescriptor deviceDescriptorTable[];