mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Get CL Device Name with device ID appended at the end
Related-To: NEO-4744 Change-Id: I8a9a791a634f9c0c444695036d96e3c959c90de0 Signed-off-by: Slawomir Milczarek <slawomir.milczarek@intel.com>
This commit is contained in:

committed by
sys_ocldev

parent
324150dd37
commit
eb8f5fa301
@ -130,6 +130,7 @@ class ClDevice : public BaseObject<_cl_device_id> {
|
||||
void initializeOpenclCAllVersions();
|
||||
void initializeOsSpecificCaps();
|
||||
void setupFp64Flags();
|
||||
const std::string getClDeviceName(const HardwareInfo &hwInfo) const;
|
||||
|
||||
Device &device;
|
||||
std::vector<std::unique_ptr<ClDevice>> subDevices;
|
||||
|
@ -5,6 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/device/device_info.h"
|
||||
#include "shared/source/helpers/basic_math.h"
|
||||
#include "shared/source/helpers/hw_helper.h"
|
||||
@ -71,10 +72,7 @@ void ClDevice::initializeCaps() {
|
||||
|
||||
driverVersion = TOSTR(NEO_OCL_DRIVER_VERSION);
|
||||
|
||||
// Add our graphics family name to the device name
|
||||
name += "Intel(R) ";
|
||||
name += familyName[hwInfo.platform.eRenderCoreFamily];
|
||||
name += " HD Graphics NEO";
|
||||
name = getClDeviceName(hwInfo);
|
||||
|
||||
if (driverInfo) {
|
||||
name.assign(driverInfo.get()->getDeviceName(name).c_str());
|
||||
@ -434,4 +432,13 @@ void ClDevice::initializeOpenclCAllVersions() {
|
||||
}
|
||||
}
|
||||
|
||||
const std::string ClDevice::getClDeviceName(const HardwareInfo &hwInfo) const {
|
||||
std::stringstream deviceName;
|
||||
|
||||
deviceName << device.getDeviceName(hwInfo);
|
||||
deviceName << " [0x" << std::hex << hwInfo.platform.usDeviceID << "]";
|
||||
|
||||
return deviceName.str();
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
@ -15,6 +15,16 @@ set(IGDRCL_SRCS_tests_device
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/sub_device_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)
|
||||
list(APPEND IGDRCL_SRCS_tests_device
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/device_win_timers_tests.cpp
|
||||
|
@ -119,9 +119,9 @@ TEST_F(DeviceGetCapsTest, WhenCreatingDeviceThenCapsArePopulatedCorrectly) {
|
||||
EXPECT_NE(nullptr, caps.builtInKernels);
|
||||
|
||||
std::string strDriverName = caps.name;
|
||||
std::string strFamilyName = familyName[device->getRenderCoreFamily()];
|
||||
std::string strDeviceName = device->getClDeviceName(*defaultHwInfo.get());
|
||||
|
||||
EXPECT_NE(std::string::npos, strDriverName.find(strFamilyName));
|
||||
EXPECT_NE(std::string::npos, strDriverName.find(strDeviceName));
|
||||
|
||||
EXPECT_NE(nullptr, caps.name);
|
||||
EXPECT_NE(nullptr, caps.vendor);
|
||||
@ -1246,9 +1246,7 @@ TEST_F(DeviceGetCapsTest, givenSystemWithNoDriverInfoWhenGettingNameAndVersionTh
|
||||
|
||||
const auto &caps = device->getDeviceInfo();
|
||||
|
||||
std::string tempName = "Intel(R) ";
|
||||
tempName += familyName[defaultHwInfo->platform.eRenderCoreFamily];
|
||||
tempName += " HD Graphics NEO";
|
||||
std::string tempName = device->getClDeviceName(*defaultHwInfo.get());
|
||||
|
||||
#define QTR(a) #a
|
||||
#define TOSTR(b) QTR(b)
|
||||
|
34
opencl/test/unit_test/device/get_device_name_tests.cpp
Normal file
34
opencl/test/unit_test/device/get_device_name_tests.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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 ";
|
||||
deviceName += 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 << defaultHwInfo->platform.usDeviceID << "]";
|
||||
EXPECT_STREQ(clDeviceName.str().c_str(), clDevice->getClDeviceName(*defaultHwInfo.get()).c_str());
|
||||
}
|
36
opencl/test/unit_test/device/get_device_name_tests_dg1.cpp
Normal file
36
opencl/test/unit_test/device/get_device_name_tests_dg1.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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 << defaultHwInfo->platform.usDeviceID << "]";
|
||||
EXPECT_STREQ(clDeviceName.str().c_str(), clDevice->getClDeviceName(*defaultHwInfo.get()).c_str());
|
||||
}
|
@ -32,6 +32,7 @@ class MockClDevice : public ClDevice {
|
||||
using ClDevice::deviceInfo;
|
||||
using ClDevice::driverInfo;
|
||||
using ClDevice::enabledClVersion;
|
||||
using ClDevice::getClDeviceName;
|
||||
using ClDevice::initializeCaps;
|
||||
using ClDevice::name;
|
||||
using ClDevice::ocl21FeaturesEnabled;
|
||||
|
Reference in New Issue
Block a user