mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-29 09:03:14 +08:00
Retrieve model name and vendor name for sysman zesDeviceGetProperties
Signed-off-by: Mayank Raghuwanshi <mayank.raghuwanshi@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
ede866c212
commit
17565be417
@@ -19,8 +19,6 @@
|
||||
namespace L0 {
|
||||
|
||||
const std::string LinuxGlobalOperationsImp::deviceDir("device");
|
||||
const std::string LinuxGlobalOperationsImp::vendorFile("device/vendor");
|
||||
const std::string LinuxGlobalOperationsImp::deviceFile("device/device");
|
||||
const std::string LinuxGlobalOperationsImp::subsystemVendorFile("device/subsystem_vendor");
|
||||
const std::string LinuxGlobalOperationsImp::driverFile("device/driver");
|
||||
const std::string LinuxGlobalOperationsImp::functionLevelReset("device/reset");
|
||||
@@ -67,23 +65,17 @@ void LinuxGlobalOperationsImp::getBrandName(char (&brandName)[ZES_STRING_PROPERT
|
||||
}
|
||||
|
||||
void LinuxGlobalOperationsImp::getModelName(char (&modelName)[ZES_STRING_PROPERTY_SIZE]) {
|
||||
std::string strVal;
|
||||
ze_result_t result = pSysfsAccess->read(deviceFile, strVal);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
std::strncpy(modelName, unknown.c_str(), ZES_STRING_PROPERTY_SIZE);
|
||||
return;
|
||||
}
|
||||
std::strncpy(modelName, strVal.c_str(), ZES_STRING_PROPERTY_SIZE);
|
||||
NEO::Device *neoDevice = pDevice->getNEODevice();
|
||||
std::string deviceModelName = neoDevice->getDeviceName(neoDevice->getHardwareInfo());
|
||||
std::strncpy(modelName, deviceModelName.c_str(), ZES_STRING_PROPERTY_SIZE);
|
||||
}
|
||||
|
||||
void LinuxGlobalOperationsImp::getVendorName(char (&vendorName)[ZES_STRING_PROPERTY_SIZE]) {
|
||||
std::string strVal;
|
||||
ze_result_t result = pSysfsAccess->read(vendorFile, strVal);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
std::strncpy(vendorName, unknown.c_str(), ZES_STRING_PROPERTY_SIZE);
|
||||
return;
|
||||
}
|
||||
if (strVal.compare(intelPciId) == 0) {
|
||||
ze_device_properties_t coreDeviceProperties;
|
||||
pDevice->getProperties(&coreDeviceProperties);
|
||||
std::stringstream pciId;
|
||||
pciId << std::hex << coreDeviceProperties.vendorId;
|
||||
if (("0x" + pciId.str()).compare(intelPciId) == 0) {
|
||||
std::strncpy(vendorName, vendorIntel.c_str(), ZES_STRING_PROPERTY_SIZE);
|
||||
} else {
|
||||
std::strncpy(vendorName, unknown.c_str(), ZES_STRING_PROPERTY_SIZE);
|
||||
|
||||
@@ -43,8 +43,6 @@ class LinuxGlobalOperationsImp : public OsGlobalOperations, NEO::NonCopyableOrMo
|
||||
|
||||
private:
|
||||
static const std::string deviceDir;
|
||||
static const std::string vendorFile;
|
||||
static const std::string deviceFile;
|
||||
static const std::string subsystemVendorFile;
|
||||
static const std::string driverFile;
|
||||
static const std::string functionLevelReset;
|
||||
|
||||
@@ -17,8 +17,6 @@ const std::string vendorIntel("Intel(R) Corporation");
|
||||
const std::string unknown("unknown");
|
||||
const std::string intelPciId("0x8086");
|
||||
const std::string deviceDir("device");
|
||||
const std::string vendorFile("device/vendor");
|
||||
const std::string deviceFile("device/device");
|
||||
const std::string subsystemVendorFile("device/subsystem_vendor");
|
||||
const std::string driverFile("device/driver");
|
||||
const std::string agamaVersionFile("/sys/module/i915/agama_version");
|
||||
@@ -69,10 +67,6 @@ struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
|
||||
ze_result_t getValString(const std::string file, std::string &val) {
|
||||
if (file.compare(subsystemVendorFile) == 0) {
|
||||
val = "0x8086";
|
||||
} else if (file.compare(deviceFile) == 0) {
|
||||
val = "0x3ea5";
|
||||
} else if (file.compare(vendorFile) == 0) {
|
||||
val = "0x8086";
|
||||
} else if (file.compare("clients/8/pid") == 0) {
|
||||
val = bPid4;
|
||||
} else {
|
||||
@@ -84,10 +78,6 @@ struct Mock<GlobalOperationsSysfsAccess> : public GlobalOperationsSysfsAccess {
|
||||
ze_result_t getFalseValString(const std::string file, std::string &val) {
|
||||
if (file.compare(subsystemVendorFile) == 0) {
|
||||
val = "0xa086";
|
||||
} else if (file.compare(deviceFile) == 0) {
|
||||
val = "0xa123";
|
||||
} else if (file.compare(vendorFile) == 0) {
|
||||
val = "0xa086";
|
||||
} else {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ constexpr int64_t engines6 = 1u;
|
||||
constexpr int64_t engines7 = 1u;
|
||||
constexpr uint32_t totalProcessStates = 5u; // Three process States for three pids
|
||||
constexpr uint32_t totalProcessStatesForFaultyClients = 3u;
|
||||
const std::string expectedModelName("0x3ea5");
|
||||
class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
|
||||
protected:
|
||||
std::unique_ptr<Mock<GlobalOperationsSysfsAccess>> pSysfsAccess;
|
||||
@@ -50,6 +49,7 @@ class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
|
||||
OsGlobalOperations *pOsGlobalOperationsPrev = nullptr;
|
||||
L0::GlobalOperations *pGlobalOperationsPrev = nullptr;
|
||||
L0::GlobalOperationsImp *pGlobalOperationsImp;
|
||||
std::string expectedModelName;
|
||||
|
||||
void SetUp() override {
|
||||
SysmanDeviceFixture::SetUp();
|
||||
@@ -74,6 +74,7 @@ class SysmanGlobalOperationsFixture : public SysmanDeviceFixture {
|
||||
pGlobalOperationsImp = static_cast<L0::GlobalOperationsImp *>(pSysmanDeviceImp->pGlobalOperations);
|
||||
pOsGlobalOperationsPrev = pGlobalOperationsImp->pOsGlobalOperations;
|
||||
pGlobalOperationsImp->pOsGlobalOperations = nullptr;
|
||||
expectedModelName = neoDevice->getDeviceName(neoDevice->getHardwareInfo());
|
||||
pGlobalOperationsImp->init();
|
||||
}
|
||||
|
||||
@@ -151,12 +152,12 @@ TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDevice
|
||||
EXPECT_TRUE(0 == unknown.compare(properties.driverVersion));
|
||||
}
|
||||
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDeviceGetPropertiesForCheckingDevicePropertiesWhenRespectiveFilesAreNotIncorrectThenVerifyzesDeviceGetPropertiesCallSucceeds) {
|
||||
zes_device_properties_t properties;
|
||||
TEST_F(SysmanGlobalOperationsFixture, GivenValidDeviceHandleWhenCallingzesDeviceGetPropertiesForCheckingDevicePropertiesWhenVendorIsUnKnownThenVerifyzesDeviceGetPropertiesCallSucceeds) {
|
||||
ON_CALL(*pSysfsAccess.get(), read(_, Matcher<std::string &>(_)))
|
||||
.WillByDefault(::testing::Invoke(pSysfsAccess.get(), &Mock<GlobalOperationsSysfsAccess>::getFalseValString));
|
||||
neoDevice->deviceInfo.vendorId = 1806; //Unknown Vendor id
|
||||
pGlobalOperationsImp->init();
|
||||
|
||||
zes_device_properties_t properties;
|
||||
ze_result_t result = zesDeviceGetProperties(device, &properties);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
|
||||
EXPECT_TRUE(0 == unknown.compare(properties.vendorName));
|
||||
|
||||
Reference in New Issue
Block a user