mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
refactor: Move all constants in sysman namespace
- Use inline constexpr for declaring global variables - Avoid using Macros - Use string_view type instead of std::string Signed-off-by: Jitendra Sharma <jitendra.sharma@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
7f6b259f0e
commit
82eacc88bf
@ -56,7 +56,7 @@ void OsFirmware::getSupportedFwTypes(std::vector<std::string> &supportedFwTypes,
|
||||
|
||||
void LinuxFirmwareImp::osGetFwProperties(zes_firmware_properties_t *pProperties) {
|
||||
if (ZE_RESULT_SUCCESS != getFirmwareVersion(osFwType, pProperties)) {
|
||||
strncpy_s(static_cast<char *>(pProperties->version), ZES_STRING_PROPERTY_SIZE, unknown.c_str(), ZES_STRING_PROPERTY_SIZE - 1);
|
||||
strncpy_s(static_cast<char *>(pProperties->version), ZES_STRING_PROPERTY_SIZE, unknown.data(), ZES_STRING_PROPERTY_SIZE - 1);
|
||||
}
|
||||
pProperties->canControl = true; // Assuming that user has permission to flash the firmware
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ ze_result_t WddmFirmwareImp::getFirmwareVersion(std::string fwType, zes_firmware
|
||||
|
||||
void WddmFirmwareImp::osGetFwProperties(zes_firmware_properties_t *pProperties) {
|
||||
if (ZE_RESULT_SUCCESS != getFirmwareVersion(osFwType, pProperties)) {
|
||||
strncpy_s(static_cast<char *>(pProperties->version), ZES_STRING_PROPERTY_SIZE, unknown.c_str(), ZES_STRING_PROPERTY_SIZE);
|
||||
strncpy_s(static_cast<char *>(pProperties->version), ZES_STRING_PROPERTY_SIZE, unknown.data(), ZES_STRING_PROPERTY_SIZE);
|
||||
}
|
||||
pProperties->canControl = true; // Assuming that user has permission to flash the firmware
|
||||
}
|
||||
|
@ -119,13 +119,13 @@ void LinuxGlobalOperationsImp::getBrandName(char (&brandName)[ZES_STRING_PROPERT
|
||||
std::string strVal;
|
||||
ze_result_t result = pSysfsAccess->read(subsystemVendorFile, strVal);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
std::strncpy(brandName, unknown.c_str(), ZES_STRING_PROPERTY_SIZE);
|
||||
std::strncpy(brandName, unknown.data(), ZES_STRING_PROPERTY_SIZE);
|
||||
return;
|
||||
}
|
||||
if (strVal.compare(intelPciId) == 0) {
|
||||
std::strncpy(brandName, vendorIntel.c_str(), ZES_STRING_PROPERTY_SIZE);
|
||||
std::strncpy(brandName, vendorIntel.data(), ZES_STRING_PROPERTY_SIZE);
|
||||
} else {
|
||||
std::strncpy(brandName, unknown.c_str(), ZES_STRING_PROPERTY_SIZE);
|
||||
std::strncpy(brandName, unknown.data(), ZES_STRING_PROPERTY_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,13 +147,13 @@ void LinuxGlobalOperationsImp::getVendorName(char (&vendorName)[ZES_STRING_PROPE
|
||||
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);
|
||||
std::strncpy(vendorName, unknown.data(), ZES_STRING_PROPERTY_SIZE);
|
||||
return;
|
||||
}
|
||||
if (strVal.compare(intelPciId) == 0) {
|
||||
std::strncpy(vendorName, vendorIntel.c_str(), ZES_STRING_PROPERTY_SIZE);
|
||||
std::strncpy(vendorName, vendorIntel.data(), ZES_STRING_PROPERTY_SIZE);
|
||||
} else {
|
||||
std::strncpy(vendorName, unknown.c_str(), ZES_STRING_PROPERTY_SIZE);
|
||||
std::strncpy(vendorName, unknown.data(), ZES_STRING_PROPERTY_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,11 +118,11 @@ ze_result_t GlobalOperationsImp::deviceGetProperties(zes_device_properties_t *pP
|
||||
pOsGlobalOperations->getBrandName(pProperties->brandName);
|
||||
memset(pProperties->boardNumber, 0, ZES_STRING_PROPERTY_SIZE);
|
||||
if (!pOsGlobalOperations->getBoardNumber(pProperties->boardNumber)) {
|
||||
memcpy_s(pProperties->boardNumber, ZES_STRING_PROPERTY_SIZE, unknown.c_str(), unknown.length() + 1);
|
||||
memcpy_s(pProperties->boardNumber, ZES_STRING_PROPERTY_SIZE, unknown.data(), unknown.length() + 1);
|
||||
}
|
||||
memset(pProperties->serialNumber, 0, ZES_STRING_PROPERTY_SIZE);
|
||||
if (!pOsGlobalOperations->getSerialNumber(pProperties->serialNumber)) {
|
||||
memcpy_s(pProperties->serialNumber, ZES_STRING_PROPERTY_SIZE, unknown.c_str(), unknown.length() + 1);
|
||||
memcpy_s(pProperties->serialNumber, ZES_STRING_PROPERTY_SIZE, unknown.data(), unknown.length() + 1);
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
|
@ -81,8 +81,8 @@ void LinuxPciImp::getMaxLinkCaps(double &maxLinkSpeed, int32_t &maxLinkWidth) {
|
||||
}
|
||||
|
||||
uint16_t linkCaps = L0::Sysman::PciUtil::getWordFromConfig(linkCapPos, configMemory.data());
|
||||
maxLinkSpeed = convertPciGenToLinkSpeed(BITS(linkCaps, 0, 4));
|
||||
maxLinkWidth = BITS(linkCaps, 4, 6);
|
||||
maxLinkSpeed = convertPciGenToLinkSpeed(bits(linkCaps, 0, 4));
|
||||
maxLinkWidth = bits(linkCaps, 4, 6);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -189,7 +189,7 @@ uint16_t LinuxPciImp::getLinkCapabilityPos(uint8_t *configMem) {
|
||||
id = L0::Sysman::PciUtil::getByteFromConfig(pos + PCI_CAP_LIST_ID, configMem);
|
||||
if (id == PCI_CAP_ID_EXP) {
|
||||
capRegister = L0::Sysman::PciUtil::getWordFromConfig(pos + PCI_CAP_FLAGS, configMem);
|
||||
type = BITS(capRegister, 4, 4);
|
||||
type = bits(capRegister, 4, 4);
|
||||
|
||||
// Root Complex Integrated end point and
|
||||
// Root Complex Event collector will not implement link capabilities
|
||||
@ -258,11 +258,11 @@ bool LinuxPciImp::resizableBarEnabled(uint32_t barIndex) {
|
||||
|
||||
// Only first Control register(at offset 008h, as shown above), could tell about number of resizable Bars
|
||||
controlRegister = L0::Sysman::PciUtil::getDwordFromConfig(rebarCapabilityPos + PCI_REBAR_CTRL, configMemory.data());
|
||||
nBars = BITS(controlRegister, 5, 3); // control register's bits 5,6 and 7 contain number of resizable bars information
|
||||
nBars = bits(controlRegister, 5, 3); // control register's bits 5,6 and 7 contain number of resizable bars information
|
||||
for (auto barNumber = 0u; barNumber < nBars; barNumber++) {
|
||||
uint32_t barId = 0;
|
||||
controlRegister = L0::Sysman::PciUtil::getDwordFromConfig(rebarCapabilityPos + PCI_REBAR_CTRL, configMemory.data());
|
||||
barId = BITS(controlRegister, 0, 3); // Control register's bit 0,1,2 tells the index of bar
|
||||
barId = bits(controlRegister, 0, 3); // Control register's bit 0,1,2 tells the index of bar
|
||||
if (barId == barIndex) {
|
||||
isBarResizable = true;
|
||||
break;
|
||||
@ -286,7 +286,7 @@ bool LinuxPciImp::resizableBarEnabled(uint32_t barIndex) {
|
||||
|
||||
// Control register's bit 8 to 13 indicates current BAR size in encoded form.
|
||||
// Example, real value of current size could be 2^currentSize MB
|
||||
auto currentSize = BITS(controlRegister, 8, 6);
|
||||
auto currentSize = bits(controlRegister, 8, 6);
|
||||
|
||||
// If current size is equal to larget possible BAR size, it indicates resizable BAR is enabled.
|
||||
return (currentSize == largestPossibleBarSize);
|
||||
|
@ -166,7 +166,7 @@ void SysmanKmdInterfaceI915Prelim::getDriverVersion(char (&driverVersion)[ZES_ST
|
||||
ze_result_t result = pFsAccess->read(agamaVersionFile, strVal);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed to read driver version from %s and returning error:0x%x \n", __FUNCTION__, agamaVersionFile.c_str(), result);
|
||||
std::strncpy(driverVersion, unknown.c_str(), ZES_STRING_PROPERTY_SIZE);
|
||||
std::strncpy(driverVersion, unknown.data(), ZES_STRING_PROPERTY_SIZE);
|
||||
} else {
|
||||
std::strncpy(driverVersion, strVal.c_str(), ZES_STRING_PROPERTY_SIZE);
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ void SysmanKmdInterfaceI915Upstream::getDriverVersion(char (&driverVersion)[ZES_
|
||||
ze_result_t result = pFsAccess->read(srcVersionFile, strVal);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed to read driver version from %s and returning error:0x%x\n", __FUNCTION__, srcVersionFile.c_str(), result);
|
||||
std::strncpy(driverVersion, unknown.c_str(), ZES_STRING_PROPERTY_SIZE);
|
||||
std::strncpy(driverVersion, unknown.data(), ZES_STRING_PROPERTY_SIZE);
|
||||
} else {
|
||||
std::strncpy(driverVersion, strVal.c_str(), ZES_STRING_PROPERTY_SIZE);
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ void SysmanKmdInterfaceXe::getDriverVersion(char (&driverVersion)[ZES_STRING_PRO
|
||||
ze_result_t result = pFsAccess->read(srcVersionFile, strVal);
|
||||
if (ZE_RESULT_SUCCESS != result) {
|
||||
NEO::printDebugString(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s(): Failed to read driver version from %s and returning error:0x%x\n", __FUNCTION__, srcVersionFile.c_str(), result);
|
||||
std::strncpy(driverVersion, unknown.c_str(), ZES_STRING_PROPERTY_SIZE);
|
||||
std::strncpy(driverVersion, unknown.data(), ZES_STRING_PROPERTY_SIZE);
|
||||
} else {
|
||||
std::strncpy(driverVersion, strVal.c_str(), ZES_STRING_PROPERTY_SIZE);
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ static ze_result_t getPciStatsValues(zes_pci_stats_t *pStats, std::map<std::stri
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
uint64_t rxCounter = PACK_INTO_64BIT(rxCounterMsb, rxCounterLsb);
|
||||
uint64_t rxCounter = packInto64Bit(rxCounterMsb, rxCounterLsb);
|
||||
|
||||
uint32_t txCounterLsb = 0;
|
||||
if (!PlatformMonitoringTech::readValue(keyOffsetMap, telemNodeDir, "reg_PCIESS_tx_bytecount_lsb", telemOffset, txCounterLsb)) {
|
||||
@ -317,7 +317,7 @@ static ze_result_t getPciStatsValues(zes_pci_stats_t *pStats, std::map<std::stri
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
uint64_t txCounter = PACK_INTO_64BIT(txCounterMsb, txCounterLsb);
|
||||
uint64_t txCounter = packInto64Bit(txCounterMsb, txCounterLsb);
|
||||
|
||||
uint32_t rxPacketCounterLsb = 0;
|
||||
if (!PlatformMonitoringTech::readValue(keyOffsetMap, telemNodeDir, "reg_PCIESS_rx_pktcount_lsb", telemOffset, rxPacketCounterLsb)) {
|
||||
@ -329,7 +329,7 @@ static ze_result_t getPciStatsValues(zes_pci_stats_t *pStats, std::map<std::stri
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
uint64_t rxPacketCounter = PACK_INTO_64BIT(rxPacketCounterMsb, rxPacketCounterLsb);
|
||||
uint64_t rxPacketCounter = packInto64Bit(rxPacketCounterMsb, rxPacketCounterLsb);
|
||||
|
||||
uint32_t txPacketCounterLsb = 0;
|
||||
if (!PlatformMonitoringTech::readValue(keyOffsetMap, telemNodeDir, "reg_PCIESS_tx_pktcount_lsb", telemOffset, txPacketCounterLsb)) {
|
||||
@ -341,7 +341,7 @@ static ze_result_t getPciStatsValues(zes_pci_stats_t *pStats, std::map<std::stri
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
uint64_t txPacketCounter = PACK_INTO_64BIT(txPacketCounterMsb, txPacketCounterLsb);
|
||||
uint64_t txPacketCounter = packInto64Bit(txPacketCounterMsb, txPacketCounterLsb);
|
||||
|
||||
pStats->speed.gen = -1;
|
||||
pStats->speed.width = -1;
|
||||
@ -493,7 +493,7 @@ static ze_result_t getMemoryBandwidthTimestamp(const std::map<std::string, uint6
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
pBandwidth->timestamp = PACK_INTO_64BIT(timeStampH, timeStampL);
|
||||
pBandwidth->timestamp = packInto64Bit(timeStampH, timeStampL);
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
@ -514,7 +514,7 @@ static ze_result_t getCounterValues(const std::vector<std::pair<const std::strin
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
totalCounter += PACK_INTO_64BIT(regH, regL);
|
||||
totalCounter += packInto64Bit(regH, regL);
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
|
@ -18,8 +18,6 @@
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
#define PACK_INTO_64BIT(valueH, valueL) ((static_cast<uint64_t>(valueH) << 32) | static_cast<uint64_t>(valueL))
|
||||
|
||||
constexpr static auto gfxProduct = IGFX_BMG;
|
||||
|
||||
static std::map<unsigned long, std::map<std::string, uint32_t>> guidToKeyOffsetMap = {
|
||||
@ -396,7 +394,7 @@ ze_result_t SysmanProductHelperHw<gfxProduct>::getPciStats(zes_pci_stats_t *pSta
|
||||
"readValue call failed for register key rx_byte_count_msb\n");
|
||||
return status;
|
||||
}
|
||||
pStats->rxCounter = PACK_INTO_64BIT(rxCounterH, rxCounterL);
|
||||
pStats->rxCounter = packInto64Bit(rxCounterH, rxCounterL);
|
||||
|
||||
// tx counter calculation
|
||||
uint32_t txCounterL = 0;
|
||||
@ -414,7 +412,7 @@ ze_result_t SysmanProductHelperHw<gfxProduct>::getPciStats(zes_pci_stats_t *pSta
|
||||
"readValue call failed for register key tx_byte_count_msb\n");
|
||||
return status;
|
||||
}
|
||||
pStats->txCounter = PACK_INTO_64BIT(txCounterH, txCounterL);
|
||||
pStats->txCounter = packInto64Bit(txCounterH, txCounterL);
|
||||
|
||||
// packet counter calculation
|
||||
uint32_t rxPacketCounterL = 0;
|
||||
@ -449,7 +447,7 @@ ze_result_t SysmanProductHelperHw<gfxProduct>::getPciStats(zes_pci_stats_t *pSta
|
||||
return status;
|
||||
}
|
||||
|
||||
pStats->packetCounter = PACK_INTO_64BIT(txPacketCounterH, txPacketCounterL) + PACK_INTO_64BIT(rxPacketCounterH, rxPacketCounterL);
|
||||
pStats->packetCounter = packInto64Bit(txPacketCounterH, txPacketCounterL) + packInto64Bit(rxPacketCounterH, rxPacketCounterL);
|
||||
pStats->timestamp = SysmanDevice::getSysmanTimestamp();
|
||||
|
||||
return status;
|
||||
@ -524,7 +522,7 @@ ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryBandWidth(zes_mem_bandwi
|
||||
return status;
|
||||
}
|
||||
|
||||
uint64_t readCounter = PACK_INTO_64BIT(readRegisterH, readRegisterL);
|
||||
uint64_t readCounter = packInto64Bit(readRegisterH, readRegisterL);
|
||||
|
||||
pBandwidth->readCounter += readCounter;
|
||||
}
|
||||
@ -546,7 +544,7 @@ ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryBandWidth(zes_mem_bandwi
|
||||
return status;
|
||||
}
|
||||
|
||||
uint64_t writeCounter = PACK_INTO_64BIT(writeRegisterH, writeRegisterL);
|
||||
uint64_t writeCounter = packInto64Bit(writeRegisterH, writeRegisterL);
|
||||
|
||||
pBandwidth->writeCounter += writeCounter;
|
||||
}
|
||||
@ -581,7 +579,7 @@ ze_result_t SysmanProductHelperHw<gfxProduct>::getMemoryBandWidth(zes_mem_bandwi
|
||||
return status;
|
||||
}
|
||||
|
||||
pBandwidth->timestamp = PACK_INTO_64BIT(timeStampH, timeStampL);
|
||||
pBandwidth->timestamp = packInto64Bit(timeStampH, timeStampL);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
@ -10,29 +10,31 @@
|
||||
|
||||
#include <chrono>
|
||||
#include <map>
|
||||
#include <string>
|
||||
const std::string vendorIntel("Intel(R) Corporation");
|
||||
const std::string unknown("unknown");
|
||||
const std::string intelPciId("0x8086");
|
||||
const std::string guid64BitMemoryCounters("0xb15a0ede");
|
||||
constexpr uint32_t mbpsToBytesPerSecond = 125000;
|
||||
constexpr double milliVoltsFactor = 1000.0;
|
||||
constexpr uint32_t maxRasErrorCategoryCount = 7;
|
||||
constexpr uint32_t maxRasErrorCategoryExpCount = 10;
|
||||
|
||||
constexpr double maxPerformanceFactor = 100;
|
||||
constexpr double halfOfMaxPerformanceFactor = 50;
|
||||
constexpr double minPerformanceFactor = 0;
|
||||
|
||||
constexpr uint32_t numSocTemperatureEntries = 7; // entries would be PCH or GT_TEMP, DRAM, SA, PSF, DE, PCIE, TYPEC
|
||||
constexpr uint32_t numCoreTemperatureEntries = 4; // entries would be CORE0, CORE1, CORE2, CORE3
|
||||
constexpr uint32_t numComputeTemperatureEntries = 3; // entries would be IA, GT and LLC
|
||||
constexpr uint32_t invalidMaxTemperature = 125;
|
||||
constexpr uint32_t invalidMinTemperature = 10;
|
||||
constexpr uint32_t vendorIdIntel = 0x8086;
|
||||
#include <string_view>
|
||||
|
||||
namespace L0 {
|
||||
namespace Sysman {
|
||||
|
||||
inline constexpr std::string_view vendorIntel("Intel(R) Corporation");
|
||||
inline constexpr std::string_view unknown("unknown");
|
||||
inline constexpr std::string_view intelPciId("0x8086");
|
||||
inline constexpr std::string_view guid64BitMemoryCounters("0xb15a0ede");
|
||||
inline constexpr uint32_t mbpsToBytesPerSecond = 125000;
|
||||
inline constexpr double milliVoltsFactor = 1000.0;
|
||||
inline constexpr uint32_t maxRasErrorCategoryCount = 7;
|
||||
inline constexpr uint32_t maxRasErrorCategoryExpCount = 10;
|
||||
|
||||
inline constexpr double maxPerformanceFactor = 100;
|
||||
inline constexpr double halfOfMaxPerformanceFactor = 50;
|
||||
inline constexpr double minPerformanceFactor = 0;
|
||||
|
||||
inline constexpr uint32_t numSocTemperatureEntries = 7; // entries would be PCH or GT_TEMP, DRAM, SA, PSF, DE, PCIE, TYPEC
|
||||
inline constexpr uint32_t numCoreTemperatureEntries = 4; // entries would be CORE0, CORE1, CORE2, CORE3
|
||||
inline constexpr uint32_t numComputeTemperatureEntries = 3; // entries would be IA, GT and LLC
|
||||
inline constexpr uint32_t invalidMaxTemperature = 125;
|
||||
inline constexpr uint32_t invalidMinTemperature = 10;
|
||||
inline constexpr uint32_t vendorIdIntel = 0x8086;
|
||||
|
||||
struct SteadyClock {
|
||||
typedef std::chrono::duration<uint64_t, std::milli> duration;
|
||||
typedef duration::rep rep;
|
||||
@ -44,15 +46,12 @@ struct SteadyClock {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Sysman
|
||||
} // namespace L0
|
||||
|
||||
namespace PciLinkSpeeds {
|
||||
constexpr double pci2Dot5GigaTransfersPerSecond = 2.5;
|
||||
constexpr double pci5GigaTransfersPerSecond = 5.0;
|
||||
constexpr double pci8GigaTransfersPerSecond = 8.0;
|
||||
constexpr double pci16GigaTransfersPerSecond = 16.0;
|
||||
constexpr double pci32GigaTransfersPerSecond = 32.0;
|
||||
inline constexpr double pci2Dot5GigaTransfersPerSecond = 2.5;
|
||||
inline constexpr double pci5GigaTransfersPerSecond = 5.0;
|
||||
inline constexpr double pci8GigaTransfersPerSecond = 8.0;
|
||||
inline constexpr double pci16GigaTransfersPerSecond = 16.0;
|
||||
inline constexpr double pci32GigaTransfersPerSecond = 32.0;
|
||||
|
||||
} // namespace PciLinkSpeeds
|
||||
enum PciGenerations {
|
||||
@ -63,30 +62,39 @@ enum PciGenerations {
|
||||
PciGen5,
|
||||
};
|
||||
|
||||
constexpr uint8_t maxPciBars = 6;
|
||||
inline constexpr uint8_t maxPciBars = 6;
|
||||
// Linux kernel would report 255 link width, as an indication of unknown.
|
||||
constexpr uint32_t unknownPcieLinkWidth = 255u;
|
||||
inline constexpr uint32_t unknownPcieLinkWidth = 255u;
|
||||
|
||||
constexpr uint32_t microSecondsToNanoSeconds = 1000u;
|
||||
inline constexpr uint32_t microSecondsToNanoSeconds = 1000u;
|
||||
|
||||
constexpr uint64_t convertJouleToMicroJoule = 1000000u;
|
||||
constexpr uint64_t minTimeoutModeHeartbeat = 5000u;
|
||||
constexpr uint64_t minTimeoutInMicroSeconds = 1000u;
|
||||
constexpr uint16_t milliSecsToMicroSecs = 1000;
|
||||
constexpr uint32_t milliFactor = 1000u;
|
||||
constexpr uint32_t microFactor = milliFactor * milliFactor;
|
||||
constexpr uint64_t gigaUnitTransferToUnitTransfer = 1000 * 1000 * 1000;
|
||||
constexpr uint64_t megaBytesToBytes = 1000 * 1000;
|
||||
inline constexpr uint64_t convertJouleToMicroJoule = 1000000u;
|
||||
inline constexpr uint64_t minTimeoutModeHeartbeat = 5000u;
|
||||
inline constexpr uint64_t minTimeoutInMicroSeconds = 1000u;
|
||||
inline constexpr uint16_t milliSecsToMicroSecs = 1000;
|
||||
inline constexpr uint32_t milliFactor = 1000u;
|
||||
inline constexpr uint32_t microFactor = milliFactor * milliFactor;
|
||||
inline constexpr uint64_t gigaUnitTransferToUnitTransfer = 1000 * 1000 * 1000;
|
||||
inline constexpr uint64_t megaBytesToBytes = 1000 * 1000;
|
||||
|
||||
constexpr int32_t memoryBusWidth = 128; // bus width in bytes
|
||||
constexpr int32_t numMemoryChannels = 8;
|
||||
constexpr uint32_t unknownMemoryType = UINT32_MAX;
|
||||
#define BITS(x, at, width) (((x) >> (at)) & ((1 << (width)) - 1))
|
||||
#define PACK_INTO_64BIT(msb, lsb) ((static_cast<uint64_t>(msb) << 32) | static_cast<uint64_t>(lsb))
|
||||
inline constexpr int32_t memoryBusWidth = 128; // bus width in bytes
|
||||
inline constexpr int32_t numMemoryChannels = 8;
|
||||
inline constexpr uint32_t unknownMemoryType = UINT32_MAX;
|
||||
|
||||
const std::map<std::string, zes_engine_type_flag_t> sysfsEngineMapToLevel0EngineType = {
|
||||
inline constexpr uint32_t bits(uint32_t x, uint32_t at, uint32_t width) {
|
||||
return (((x) >> (at)) & ((1 << (width)) - 1));
|
||||
}
|
||||
|
||||
inline constexpr uint64_t packInto64Bit(uint32_t msb, uint32_t lsb) {
|
||||
return ((static_cast<uint64_t>(msb) << 32) | static_cast<uint64_t>(lsb));
|
||||
}
|
||||
|
||||
const std::map<std::string_view, zes_engine_type_flag_t> sysfsEngineMapToLevel0EngineType = {
|
||||
{"rcs", ZES_ENGINE_TYPE_FLAG_RENDER},
|
||||
{"ccs", ZES_ENGINE_TYPE_FLAG_COMPUTE},
|
||||
{"bcs", ZES_ENGINE_TYPE_FLAG_DMA},
|
||||
{"vcs", ZES_ENGINE_TYPE_FLAG_MEDIA},
|
||||
{"vecs", ZES_ENGINE_TYPE_FLAG_OTHER}};
|
||||
|
||||
} // namespace Sysman
|
||||
} // namespace L0
|
||||
|
@ -1157,15 +1157,15 @@ HWTEST2_F(SysmanProductHelperMemoryTest, GivenSysmanProductHelperInstanceWhenCal
|
||||
zes_mem_bandwidth_t memBandwidth;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pSysmanProductHelper->getMemoryBandwidth(&memBandwidth, pLinuxSysmanImp, subdeviceId));
|
||||
|
||||
uint64_t outputReadCounter = PACK_INTO_64BIT(readCounterUpper, readCounterLower);
|
||||
uint64_t outputReadCounter = packInto64Bit(readCounterUpper, readCounterLower);
|
||||
outputReadCounter = (outputReadCounter * transactionSize) / microFactor;
|
||||
EXPECT_EQ(outputReadCounter, memBandwidth.readCounter);
|
||||
|
||||
uint64_t outputWriteCounter = PACK_INTO_64BIT(writeCounterUpper, writeCounterLower);
|
||||
uint64_t outputWriteCounter = packInto64Bit(writeCounterUpper, writeCounterLower);
|
||||
outputWriteCounter = (outputWriteCounter * transactionSize) / microFactor;
|
||||
EXPECT_EQ(outputWriteCounter, memBandwidth.writeCounter);
|
||||
|
||||
uint64_t outputTimestamp = PACK_INTO_64BIT(timeStampUpper, timeStampLower);
|
||||
uint64_t outputTimestamp = packInto64Bit(timeStampUpper, timeStampLower);
|
||||
EXPECT_EQ(outputTimestamp, memBandwidth.timestamp);
|
||||
|
||||
uint64_t outputMaxBandwidth = vramBandwidth;
|
||||
|
@ -227,14 +227,14 @@ HWTEST2_F(SysmanProductHelperPciTest, GivenSysmanProductHelperInstanceWhenGetPci
|
||||
zes_pci_stats_t stats;
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, pSysmanProductHelper->getPciStats(&stats, pLinuxSysmanImp));
|
||||
|
||||
uint64_t mockRxCounter = PACK_INTO_64BIT(mockRxCounterMsb, mockRxCounterLsb);
|
||||
uint64_t mockRxCounter = packInto64Bit(mockRxCounterMsb, mockRxCounterLsb);
|
||||
EXPECT_EQ(mockRxCounter, stats.rxCounter);
|
||||
|
||||
uint64_t mockTxCounter = PACK_INTO_64BIT(mockTxCounterMsb, mockTxCounterLsb);
|
||||
uint64_t mockTxCounter = packInto64Bit(mockTxCounterMsb, mockTxCounterLsb);
|
||||
EXPECT_EQ(mockTxCounter, stats.txCounter);
|
||||
|
||||
uint64_t mockRxPacketCounter = PACK_INTO_64BIT(mockRxPacketCounterMsb, mockRxPacketCounterLsb);
|
||||
uint64_t mockTxPacketCounter = PACK_INTO_64BIT(mockTxPacketCounterMsb, mockTxPacketCounterLsb);
|
||||
uint64_t mockRxPacketCounter = packInto64Bit(mockRxPacketCounterMsb, mockRxPacketCounterLsb);
|
||||
uint64_t mockTxPacketCounter = packInto64Bit(mockTxPacketCounterMsb, mockTxPacketCounterLsb);
|
||||
EXPECT_EQ(mockRxPacketCounter + mockTxPacketCounter, stats.packetCounter);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user