From af6798f25719960ff08494fdba9721a76412c9bc Mon Sep 17 00:00:00 2001 From: Mayank Raghuwanshi Date: Fri, 14 Jul 2023 11:56:00 +0000 Subject: [PATCH] feature: Add support for 64 bit memory counters for zesInit Related-To: LOCI-4613, LOCI-4612 Signed-off-by: Mayank Raghuwanshi --- .../driver_experimental/public/CMakeLists.txt | 2 - .../api/driver_experimental/public/zex_api.h | 1 - .../public/zex_sysman_memory.cpp | 47 --------- .../public/zex_sysman_memory.h | 46 --------- .../get_extension_function_lookup_map.cpp | 1 - .../SYSMAN_MEMORY_BANDWIDTH.md | 71 -------------- .../sysman/source/linux/pmt/sysman_pmt.cpp | 4 + .../sysman/source/linux/pmt/sysman_pmt.h | 2 + .../source/linux/pmt/sysman_pmt_xml_offsets.h | 39 ++++++++ .../linux/sysman_os_memory_imp_prelim.cpp | 80 ++++++++++++++- .../linux/sysman_os_memory_imp_prelim.h | 1 + .../sysman/source/memory/sysman_memory.h | 1 - .../source/memory/sysman_memory_imp.cpp | 4 - .../sysman/source/memory/sysman_memory_imp.h | 1 - level_zero/sysman/source/sysman_const.h | 1 + .../sources/memory/linux/mock_memory_prelim.h | 29 ++++++ .../linux/test_sysman_memory_prelim.cpp | 37 +++---- .../sysman/memory/linux/os_memory_imp.cpp | 4 - .../sysman/memory/linux/os_memory_imp.h | 1 - .../sysman/memory/linux/os_memory_imp_dg1.cpp | 4 - .../memory/linux/os_memory_imp_prelim.cpp | 86 ---------------- .../memory/linux/os_memory_imp_prelim.h | 1 - .../tools/source/sysman/memory/memory.h | 2 - .../tools/source/sysman/memory/memory_imp.cpp | 4 - .../tools/source/sysman/memory/memory_imp.h | 1 - .../tools/source/sysman/memory/os_memory.h | 1 - .../sysman/memory/windows/os_memory_imp.cpp | 4 - .../sysman/memory/windows/os_memory_imp.h | 1 - .../linux/test_sysman_memory_prelim.cpp | 97 +++++-------------- 29 files changed, 195 insertions(+), 378 deletions(-) delete mode 100644 level_zero/api/driver_experimental/public/zex_sysman_memory.cpp delete mode 100644 level_zero/api/driver_experimental/public/zex_sysman_memory.h delete mode 100644 level_zero/doc/experimental_extensions/SYSMAN_MEMORY_BANDWIDTH.md diff --git a/level_zero/api/driver_experimental/public/CMakeLists.txt b/level_zero/api/driver_experimental/public/CMakeLists.txt index 0cb871ab1d..d1c0fcadfd 100644 --- a/level_zero/api/driver_experimental/public/CMakeLists.txt +++ b/level_zero/api/driver_experimental/public/CMakeLists.txt @@ -17,6 +17,4 @@ target_sources(${L0_STATIC_LIB_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/zex_memory.h ${CMAKE_CURRENT_SOURCE_DIR}/zex_module.cpp ${CMAKE_CURRENT_SOURCE_DIR}/zex_module.h - ${CMAKE_CURRENT_SOURCE_DIR}/zex_sysman_memory.h - ${CMAKE_CURRENT_SOURCE_DIR}/zex_sysman_memory.cpp ) diff --git a/level_zero/api/driver_experimental/public/zex_api.h b/level_zero/api/driver_experimental/public/zex_api.h index 49164a6e52..d6e9d38519 100644 --- a/level_zero/api/driver_experimental/public/zex_api.h +++ b/level_zero/api/driver_experimental/public/zex_api.h @@ -22,6 +22,5 @@ #include "zex_driver.h" #include "zex_memory.h" #include "zex_module.h" -#include "zex_sysman_memory.h" #endif // _ZEX_API_H diff --git a/level_zero/api/driver_experimental/public/zex_sysman_memory.cpp b/level_zero/api/driver_experimental/public/zex_sysman_memory.cpp deleted file mode 100644 index 05fae212fe..0000000000 --- a/level_zero/api/driver_experimental/public/zex_sysman_memory.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2023 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#include "level_zero/api/driver_experimental/public/zex_sysman_memory.h" - -#include "level_zero/api/driver_experimental/public/zex_api.h" -#include "level_zero/core/source/driver/driver.h" -#include "level_zero/core/source/driver/driver_handle.h" -#include "level_zero/sysman/source/sysman_device.h" -#include "level_zero/sysman/source/sysman_driver.h" -#include "level_zero/sysman/source/sysman_driver_handle.h" -#include "level_zero/tools/source/sysman/memory/memory.h" -#include "level_zero/tools/source/sysman/sysman.h" - -namespace L0 { - -ze_result_t ZE_APICALL -zexSysmanMemoryGetBandwidth( - zes_mem_handle_t hMemory, - uint64_t *pReadCounters, - uint64_t *pWriteCounters, - uint64_t *pMaxBandwidth, - uint64_t timeout) { - if (L0::sysmanInitFromCore) { - return L0::Memory::fromHandle(hMemory)->memoryGetBandwidthEx(pReadCounters, pWriteCounters, pMaxBandwidth, timeout); - } - return L0::Sysman::Memory::fromHandle(hMemory)->memoryGetBandwidthEx(pReadCounters, pWriteCounters, pMaxBandwidth, timeout); -} - -} // namespace L0 - -extern "C" { - -ZE_APIEXPORT ze_result_t ZE_APICALL -zexSysmanMemoryGetBandwidth( - zes_mem_handle_t hMemory, - uint64_t *pReadCounters, - uint64_t *pWriteCounters, - uint64_t *pMaxBandwidth, - uint64_t timeout) { - return L0::zexSysmanMemoryGetBandwidth(hMemory, pReadCounters, pWriteCounters, pMaxBandwidth, timeout); -} -} diff --git a/level_zero/api/driver_experimental/public/zex_sysman_memory.h b/level_zero/api/driver_experimental/public/zex_sysman_memory.h deleted file mode 100644 index f47c21ed73..0000000000 --- a/level_zero/api/driver_experimental/public/zex_sysman_memory.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2023 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#ifndef _ZEX_SYSMAN_MEMORY_H -#define _ZEX_SYSMAN_MEMORY_H -#if defined(__cplusplus) -#pragma once -#endif - -#include "level_zero/api/driver_experimental/public/zex_api.h" - -namespace L0 { -/////////////////////////////////////////////////////////////////////////////// -/// @brief Get memory bandwidth -/// -/// @details -/// - The application may call this function from simultaneous threads. -/// - The implementation of this function should be lock-free. -/// -/// @returns -/// - ::ZE_RESULT_SUCCESS -/// - ::ZE_RESULT_ERROR_UNINITIALIZED -/// - ::ZE_RESULT_ERROR_DEVICE_LOST -/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY -/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY -/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hMemory` -/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER -/// + `nullptr == pBandwidth` -/// - ::ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS -/// + User does not have permissions to query this telemetry. -ze_result_t ZE_APICALL -zexSysmanMemoryGetBandwidth( - zes_mem_handle_t hMemory, ///<[in] Handleforthecomponent. - uint64_t *pReadCounters, ///<[out] Total bytes read from memory in duration - uint64_t *pWriteCounters, ///<[out] Total bytes written to memory in duration - uint64_t *pMaxBandwidth, ///<[out] Maximum bandwidth in units of bytes/sec - uint64_t duration ///<[in] duration in milliseconds -); - -} // namespace L0 -#endif diff --git a/level_zero/core/source/get_extension_function_lookup_map.cpp b/level_zero/core/source/get_extension_function_lookup_map.cpp index 051f04251f..4ddca94540 100644 --- a/level_zero/core/source/get_extension_function_lookup_map.cpp +++ b/level_zero/core/source/get_extension_function_lookup_map.cpp @@ -25,7 +25,6 @@ std::unordered_map getExtensionFunctionsLookupMap() { addToMap(lookupMap, zexCommandListAppendWaitOnMemory); addToMap(lookupMap, zexCommandListAppendWriteToMemory); - addToMap(lookupMap, zexSysmanMemoryGetBandwidth); #undef addToMap return lookupMap; diff --git a/level_zero/doc/experimental_extensions/SYSMAN_MEMORY_BANDWIDTH.md b/level_zero/doc/experimental_extensions/SYSMAN_MEMORY_BANDWIDTH.md deleted file mode 100644 index 36846a15b2..0000000000 --- a/level_zero/doc/experimental_extensions/SYSMAN_MEMORY_BANDWIDTH.md +++ /dev/null @@ -1,71 +0,0 @@ - - -# Sysman Memory Bandwidth - -* [Overview](#Overview) -* [Interfaces](#Interfaces) -* [Known Issues and Limitations](#Known-Issues-and-Limitations) - -# Overview - -`zesMemoryGetBandwidth` exposes memory read, write counters and timestamp. The expectation is these -counters are monotonically increasing and user can get bandwidth information using two snapshots of -the read and write counters taken at different instances. However, the counters could overflow -depending on underlying width of the counter presented by the hardware, and currently there is no -mechanism with which user can detect these overflows. Therefore `zexSysmanMemoryGetBandwidth` is -introduced to resolve this problem it takes care of overflow internally. -`zexSysmanMemoryGetBandwidth` takes duration as input argument and provides reads and write counter -values that elapsed in that duration. This interface blocks host thread progress for the duration -specified by the user. -To calculate the bandwidth using `zexSysmanMemoryGetBandwidth` use the formula -`Bandwidth = (Readcounters + WriteCounters) / duration` - -# Interfaces - -```cpp -/////////////////////////////////////////////////////////////////////////////// -/// @brief Get memory bandwidth -/// -/// @details -/// - The application may call this function from simultaneous threads. -/// - The implementation of this function should be lock-free. -/// -/// @returns -/// - ::ZE_RESULT_SUCCESS -/// - ::ZE_RESULT_ERROR_UNINITIALIZED -/// - ::ZE_RESULT_ERROR_DEVICE_LOST -/// - ::ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY -/// - ::ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY -/// - ::ZE_RESULT_ERROR_INVALID_NULL_HANDLE -/// + `nullptr == hMemory` -/// - ::ZE_RESULT_ERROR_INVALID_NULL_POINTER -/// + `nullptr == pBandwidth` -/// - ::ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS -/// + User does not have permissions to query this telemetry. -ze_result_t ZE_APICALL -zexSysmanMemoryGetBandwidth( - zes_mem_handle_t hMemory, ///<[in] Handleforthecomponent. - uint64_t *pReadCounters, ///<[out] Total bytes read from memory in duration - uint64_t *pWriteCounters, ///<[out] Total bytes written to memory in duration - uint64_t *pMaxBandwidth, ///<[out] Maximum bandwidth in units of bytes/sec - uint64_t duration ///<[in] duration in milliseconds -); -``` - -```cpp -typedef ze_result_t (*pFnzexSysmanMemoryGetBandwidth)(zes_mem_handle_t, uint64 *, uint64 *, uint64 *, uint64); -... - -pFnzexSysmanMemoryGetBandwidth zexSysmanMemoryGetBandwidth = nullptr; -ze_result_t res = zeDriverGetExtensionFunctionAddress(hDriver, "zexSysmanMemoryGetBandwidth", reinterpret_cast(&zexSysmanMemoryGetBandwidth))); -``` - -# Known Issues and Limitations - -* Implemented and validation only on Xe HPC (PVC). \ No newline at end of file diff --git a/level_zero/sysman/source/linux/pmt/sysman_pmt.cpp b/level_zero/sysman/source/linux/pmt/sysman_pmt.cpp index 2451d403c3..575b2b0979 100644 --- a/level_zero/sysman/source/linux/pmt/sysman_pmt.cpp +++ b/level_zero/sysman/source/linux/pmt/sysman_pmt.cpp @@ -23,6 +23,10 @@ const std::string PlatformMonitoringTech::baseTelemSysFS("/sys/class/intel_pmt") const std::string PlatformMonitoringTech::telem("telem"); uint32_t PlatformMonitoringTech::rootDeviceTelemNodeIndex = 0; +std::string PlatformMonitoringTech::getGuid() { + return guid; +} + ze_result_t PlatformMonitoringTech::readValue(const std::string key, uint32_t &value) { auto offset = keyOffsetMap.find(key); if (offset == keyOffsetMap.end()) { diff --git a/level_zero/sysman/source/linux/pmt/sysman_pmt.h b/level_zero/sysman/source/linux/pmt/sysman_pmt.h index 7f6cdf7b66..05443213ed 100644 --- a/level_zero/sysman/source/linux/pmt/sysman_pmt.h +++ b/level_zero/sysman/source/linux/pmt/sysman_pmt.h @@ -30,6 +30,7 @@ class PlatformMonitoringTech : NEO::NonCopyableOrMovableClass { virtual ze_result_t readValue(const std::string key, uint32_t &value); virtual ze_result_t readValue(const std::string key, uint64_t &value); + std::string getGuid(); static ze_result_t enumerateRootTelemIndex(FsAccess *pFsAccess, std::string &gpuUpstreamPortPath); static void create(LinuxSysmanImp *pLinuxSysmanImp, std::string &gpuUpstreamPortPath, std::map &mapOfSubDeviceIdToPmtObject); @@ -39,6 +40,7 @@ class PlatformMonitoringTech : NEO::NonCopyableOrMovableClass { static uint32_t rootDeviceTelemNodeIndex; std::string telemetryDeviceEntry{}; std::map keyOffsetMap; + std::string guid; ze_result_t init(FsAccess *pFsAccess, const std::string &gpuUpstreamPortPath, PRODUCT_FAMILY productFamily); static void doInitPmtObject(FsAccess *pFsAccess, uint32_t subdeviceId, PlatformMonitoringTech *pPmt, const std::string &gpuUpstreamPortPath, std::map &mapOfSubDeviceIdToPmtObject, PRODUCT_FAMILY productFamily); diff --git a/level_zero/sysman/source/linux/pmt/sysman_pmt_xml_offsets.h b/level_zero/sysman/source/linux/pmt/sysman_pmt_xml_offsets.h index c7b094226d..6ac84ae4cb 100644 --- a/level_zero/sysman/source/linux/pmt/sysman_pmt_xml_offsets.h +++ b/level_zero/sysman/source/linux/pmt/sysman_pmt_xml_offsets.h @@ -240,6 +240,45 @@ const std::map> guidToKeyOffsetMap {"VF1_HBM2_WRITE", 348}, {"VF1_HBM3_READ", 360}, {"VF1_HBM3_WRITE", 364}}}, + {"0xb15a0ede", // For PVC device + {{"HBM0MaxDeviceTemperature", 28}, + {"HBM1MaxDeviceTemperature", 36}, + {"TileMinTemperature", 40}, + {"TileMaxTemperature", 44}, + {"GTMinTemperature", 48}, + {"GTMaxTemperature", 52}, + {"VF0_VFID", 88}, + {"VF0_HBM0_READ", 92}, + {"VF0_HBM0_WRITE", 96}, + {"VF0_HBM1_READ", 104}, + {"VF0_HBM1_WRITE", 108}, + {"VF0_TIMESTAMP_L", 168}, + {"VF0_TIMESTAMP_H", 172}, + {"VF1_VFID", 176}, + {"VF1_HBM0_READ", 180}, + {"VF1_HBM0_WRITE", 184}, + {"VF1_HBM1_READ", 192}, + {"VF1_HBM1_WRITE", 196}, + {"VF1_TIMESTAMP_L", 256}, + {"VF1_TIMESTAMP_H", 260}, + {"HBM2MaxDeviceTemperature", 300}, + {"HBM3MaxDeviceTemperature", 308}, + {"VF0_HBM2_READ", 312}, + {"VF0_HBM2_WRITE", 316}, + {"VF0_HBM3_READ", 328}, + {"VF0_HBM3_WRITE", 332}, + {"VF1_HBM2_READ", 344}, + {"VF1_HBM2_WRITE", 348}, + {"VF1_HBM3_READ", 360}, + {"VF1_HBM3_WRITE", 364}, + {"VF0_HBM_READ_L", 384}, + {"VF0_HBM_READ_H", 388}, + {"VF0_HBM_WRITE_L", 392}, + {"VF0_HBM_WRITE_H", 396}, + {"VF1_HBM_READ_L", 400}, + {"VF1_HBM_READ_H", 404}, + {"VF1_HBM_WRITE_L", 408}, + {"VF1_HBM_WRITE_H", 412}}}, {"0x41fe79a5", // For PVC root device {{"PPIN", 152}, {"BoardNumber", 72}}}}; diff --git a/level_zero/sysman/source/memory/linux/sysman_os_memory_imp_prelim.cpp b/level_zero/sysman/source/memory/linux/sysman_os_memory_imp_prelim.cpp index f0823f2c1f..15f91cca08 100644 --- a/level_zero/sysman/source/memory/linux/sysman_os_memory_imp_prelim.cpp +++ b/level_zero/sysman/source/memory/linux/sysman_os_memory_imp_prelim.cpp @@ -197,6 +197,79 @@ ze_result_t LinuxMemoryImp::getBandwidthForDg2(zes_mem_bandwidth_t *pBandwidth) return result; } +ze_result_t LinuxMemoryImp::getHbmBandwidthPVC(uint32_t numHbmModules, zes_mem_bandwidth_t *pBandwidth) { + std::string guid = pPmt->getGuid(); + if (guid != guid64BitMemoryCounters) { + return getHbmBandwidth(numHbmModules, pBandwidth); + } + pBandwidth->readCounter = 0; + pBandwidth->writeCounter = 0; + pBandwidth->timestamp = 0; + pBandwidth->maxBandwidth = 0; + ze_result_t result = ZE_RESULT_ERROR_UNKNOWN; + std::string vfId = ""; + result = getVFIDString(vfId); + if (result != ZE_RESULT_SUCCESS) { + NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():getVFIDString returning error:0x%x while retriving VFID string \n", __FUNCTION__, result); + return result; + } + auto &hwInfo = pDevice->getHardwareInfo(); + auto productFamily = hwInfo.platform.eProductFamily; + auto &productHelper = pDevice->getRootDeviceEnvironment().getHelper(); + auto stepping = productHelper.getSteppingFromHwRevId(hwInfo); + + uint32_t readCounterL = 0; + std::string readCounterKey = vfId + "_HBM_READ_L"; + result = pPmt->readValue(readCounterKey, readCounterL); + if (result != ZE_RESULT_SUCCESS) { + NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for readCounterL returning error:0x%x \n", __FUNCTION__, result); + return result; + } + + uint32_t readCounterH = 0; + readCounterKey = vfId + "_HBM_READ_H"; + result = pPmt->readValue(readCounterKey, readCounterH); + if (result != ZE_RESULT_SUCCESS) { + NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for readCounterH returning error:0x%x \n", __FUNCTION__, result); + return result; + } + + constexpr uint64_t transactionSize = 32; + pBandwidth->readCounter = readCounterH; + pBandwidth->readCounter = (pBandwidth->readCounter << 32) | static_cast(readCounterL); + pBandwidth->readCounter = (pBandwidth->readCounter * transactionSize); + + uint32_t writeCounterL = 0; + std::string writeCounterKey = vfId + "_HBM_WRITE_L"; + result = pPmt->readValue(writeCounterKey, writeCounterL); + if (result != ZE_RESULT_SUCCESS) { + NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for writeCounterL returning error:0x%x \n", __FUNCTION__, result); + return result; + } + + uint32_t writeCounterH = 0; + writeCounterKey = vfId + "_HBM_WRITE_H"; + result = pPmt->readValue(writeCounterKey, writeCounterH); + if (result != ZE_RESULT_SUCCESS) { + NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for writeCounterH returning error:0x%x \n", __FUNCTION__, result); + return result; + } + + pBandwidth->writeCounter = writeCounterH; + pBandwidth->writeCounter = (pBandwidth->writeCounter << 32) | static_cast(writeCounterL); + pBandwidth->writeCounter = (pBandwidth->writeCounter * transactionSize); + + uint64_t timeStampVal = 0; + memoryGetTimeStamp(timeStampVal); + pBandwidth->timestamp = timeStampVal; + + uint64_t hbmFrequency = 0; + getHbmFrequency(productFamily, stepping, hbmFrequency); + + pBandwidth->maxBandwidth = memoryBusWidth * hbmFrequency * numHbmModules; // Value in bytes/secs + return result; +} + ze_result_t LinuxMemoryImp::getHbmBandwidth(uint32_t numHbmModules, zes_mem_bandwidth_t *pBandwidth) { pBandwidth->readCounter = 0; pBandwidth->writeCounter = 0; @@ -235,6 +308,10 @@ ze_result_t LinuxMemoryImp::getHbmBandwidth(uint32_t numHbmModules, zes_mem_band pBandwidth->writeCounter += counterValue; } + constexpr uint64_t transactionSize = 32; + pBandwidth->readCounter = pBandwidth->readCounter * transactionSize; + pBandwidth->writeCounter = pBandwidth->writeCounter * transactionSize; + uint32_t timeStampL = 0; std::string timeStamp = vfId + "_TIMESTAMP_L"; result = pPmt->readValue(timeStamp, timeStampL); @@ -257,7 +334,6 @@ ze_result_t LinuxMemoryImp::getHbmBandwidth(uint32_t numHbmModules, zes_mem_band getHbmFrequency(productFamily, stepping, hbmFrequency); pBandwidth->maxBandwidth = memoryBusWidth * hbmFrequency * numHbmModules; - pBandwidth->maxBandwidth /= 8; // Divide by 8 to get bandwidth in bytes/sec return result; } @@ -275,7 +351,7 @@ ze_result_t LinuxMemoryImp::getBandwidth(zes_mem_bandwidth_t *pBandwidth) { break; case IGFX_PVC: numHbmModules = 4u; - result = getHbmBandwidth(numHbmModules, pBandwidth); + result = getHbmBandwidthPVC(numHbmModules, pBandwidth); break; default: result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; diff --git a/level_zero/sysman/source/memory/linux/sysman_os_memory_imp_prelim.h b/level_zero/sysman/source/memory/linux/sysman_os_memory_imp_prelim.h index b3b2df52e0..ac0872bb94 100644 --- a/level_zero/sysman/source/memory/linux/sysman_os_memory_imp_prelim.h +++ b/level_zero/sysman/source/memory/linux/sysman_os_memory_imp_prelim.h @@ -45,6 +45,7 @@ class LinuxMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass { ze_result_t readMcChannelCounters(uint64_t &readCounters, uint64_t &writeCounters); ze_result_t getVFIDString(std::string &vfID); ze_result_t getBandwidthForDg2(zes_mem_bandwidth_t *pBandwidth); + ze_result_t getHbmBandwidthPVC(uint32_t numHbmModules, zes_mem_bandwidth_t *pBandwidth); ze_result_t getHbmBandwidth(uint32_t numHbmModules, zes_mem_bandwidth_t *pBandwidth); static const std::string deviceMemoryHealth; bool isSubdevice = false; diff --git a/level_zero/sysman/source/memory/sysman_memory.h b/level_zero/sysman/source/memory/sysman_memory.h index 88cfb7ae3f..646624e040 100644 --- a/level_zero/sysman/source/memory/sysman_memory.h +++ b/level_zero/sysman/source/memory/sysman_memory.h @@ -23,7 +23,6 @@ class Memory : _zes_mem_handle_t { virtual ze_result_t memoryGetProperties(zes_mem_properties_t *pProperties) = 0; virtual ze_result_t memoryGetBandwidth(zes_mem_bandwidth_t *pBandwidth) = 0; virtual ze_result_t memoryGetState(zes_mem_state_t *pState) = 0; - virtual ze_result_t memoryGetBandwidthEx(uint64_t *pReadCounters, uint64_t *pWriteCounters, uint64_t *pMaxBandwidth, uint64_t timeout) = 0; static Memory *fromHandle(zes_mem_handle_t handle) { return static_cast(handle); diff --git a/level_zero/sysman/source/memory/sysman_memory_imp.cpp b/level_zero/sysman/source/memory/sysman_memory_imp.cpp index 38e2f2a00d..f85759f48d 100644 --- a/level_zero/sysman/source/memory/sysman_memory_imp.cpp +++ b/level_zero/sysman/source/memory/sysman_memory_imp.cpp @@ -23,10 +23,6 @@ ze_result_t MemoryImp::memoryGetProperties(zes_mem_properties_t *pProperties) { return ZE_RESULT_SUCCESS; } -ze_result_t MemoryImp::memoryGetBandwidthEx(uint64_t *pReadCounters, uint64_t *pWriteCounters, uint64_t *pMaxBandwidth, uint64_t timeout) { - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - void MemoryImp::init() { this->initSuccess = pOsMemory->isMemoryModuleSupported(); if (this->initSuccess == true) { diff --git a/level_zero/sysman/source/memory/sysman_memory_imp.h b/level_zero/sysman/source/memory/sysman_memory_imp.h index 0036da88e9..3387342895 100644 --- a/level_zero/sysman/source/memory/sysman_memory_imp.h +++ b/level_zero/sysman/source/memory/sysman_memory_imp.h @@ -20,7 +20,6 @@ class MemoryImp : public Memory, NEO::NonCopyableOrMovableClass { ze_result_t memoryGetProperties(zes_mem_properties_t *pProperties) override; ze_result_t memoryGetBandwidth(zes_mem_bandwidth_t *pBandwidth) override; ze_result_t memoryGetState(zes_mem_state_t *pState) override; - ze_result_t memoryGetBandwidthEx(uint64_t *pReadCounters, uint64_t *pWriteCounters, uint64_t *pMaxBandwidth, uint64_t timeout) override; MemoryImp(OsSysman *pOsSysman, bool onSubdevice, uint32_t subDeviceId); ~MemoryImp() override; diff --git a/level_zero/sysman/source/sysman_const.h b/level_zero/sysman/source/sysman_const.h index 417fbbbd2e..ec78bdf35b 100644 --- a/level_zero/sysman/source/sysman_const.h +++ b/level_zero/sysman/source/sysman_const.h @@ -11,6 +11,7 @@ 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; diff --git a/level_zero/sysman/test/unit_tests/sources/memory/linux/mock_memory_prelim.h b/level_zero/sysman/test/unit_tests/sources/memory/linux/mock_memory_prelim.h index f21522cfce..c2af397a60 100644 --- a/level_zero/sysman/test/unit_tests/sources/memory/linux/mock_memory_prelim.h +++ b/level_zero/sysman/test/unit_tests/sources/memory/linux/mock_memory_prelim.h @@ -43,6 +43,14 @@ constexpr uint16_t vF1Hbm2ReadIndex = 344; constexpr uint16_t vF1Hbm2WriteIndex = 348; constexpr uint16_t vF1Hbm3ReadIndex = 360; constexpr uint16_t vF1Hbm3WriteIndex = 364; +constexpr uint32_t VF0HbmLRead = 16; +constexpr uint32_t VF0HbmHRead = 2; +constexpr uint32_t VF0HbmLWrite = 8; +constexpr uint32_t VF0HbmHWrite = 2; +constexpr uint32_t VF1HbmLRead = 16; +constexpr uint32_t VF1HbmHRead = 2; +constexpr uint32_t VF1HbmLWrite = 8; +constexpr uint32_t VF1HbmHWrite = 2; constexpr uint8_t vF0VfidValue = 1; constexpr uint8_t vF0Hbm0ReadValue = 92; @@ -239,6 +247,7 @@ struct MockMemoryNeoDrm : public NEO::Drm { struct MockMemoryPmt : public L0::Sysman::PlatformMonitoringTech { + using L0::Sysman::PlatformMonitoringTech::guid; using L0::Sysman::PlatformMonitoringTech::keyOffsetMap; std::vector mockReadValueReturnStatus{}; std::vector mockReadArgumentValue{}; @@ -250,6 +259,10 @@ struct MockMemoryPmt : public L0::Sysman::PlatformMonitoringTech { bool mockVfid1Status = false; bool isRepeated = false; + void setGuid(std::string guid) { + this->guid = guid; + } + MockMemoryPmt(L0::Sysman::FsAccess *pFsAccess, ze_bool_t onSubdevice, uint32_t subdeviceId) : L0::Sysman::PlatformMonitoringTech(pFsAccess, onSubdevice, subdeviceId) {} ze_result_t readValue(const std::string key, uint32_t &val) override { ze_result_t result = ZE_RESULT_SUCCESS; @@ -303,6 +316,14 @@ struct MockMemoryPmt : public L0::Sysman::PlatformMonitoringTech { val = vF0Hbm3ReadValue; } else if (key.compare("VF0_HBM3_WRITE") == 0) { val = vF0Hbm3WriteValue; + } else if (key.compare("VF0_HBM_READ_L") == 0) { + val = VF0HbmLRead; + } else if (key.compare("VF0_HBM_READ_H") == 0) { + val = VF0HbmHRead; + } else if (key.compare("VF0_HBM_WRITE_L") == 0) { + val = VF0HbmLWrite; + } else if (key.compare("VF0_HBM_WRITE_H") == 0) { + val = VF0HbmHWrite; } else { return ZE_RESULT_ERROR_NOT_AVAILABLE; } @@ -334,6 +355,14 @@ struct MockMemoryPmt : public L0::Sysman::PlatformMonitoringTech { val = vF1Hbm3ReadValue; } else if (key.compare("VF1_HBM3_WRITE") == 0) { val = vF1Hbm3WriteValue; + } else if (key.compare("VF1_HBM_READ_L") == 0) { + val = VF1HbmLRead; + } else if (key.compare("VF1_HBM_READ_H") == 0) { + val = VF1HbmHRead; + } else if (key.compare("VF1_HBM_WRITE_L") == 0) { + val = VF1HbmLWrite; + } else if (key.compare("VF1_HBM_WRITE_H") == 0) { + val = VF1HbmHWrite; } else { return ZE_RESULT_ERROR_NOT_AVAILABLE; } diff --git a/level_zero/sysman/test/unit_tests/sources/memory/linux/test_sysman_memory_prelim.cpp b/level_zero/sysman/test/unit_tests/sources/memory/linux/test_sysman_memory_prelim.cpp index e5fe89deea..cf6b2aeb97 100644 --- a/level_zero/sysman/test/unit_tests/sources/memory/linux/test_sysman_memory_prelim.cpp +++ b/level_zero/sysman/test/unit_tests/sources/memory/linux/test_sysman_memory_prelim.cpp @@ -358,7 +358,7 @@ HWTEST2_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingzesSysmanM for (auto &handle : handles) { zes_mem_bandwidth_t bandwidth{}; uint64_t expectedReadCounters = 0, expectedWriteCounters = 0; - uint64_t expectedTimestamp = 0, expectedBandwidth = 0; + uint64_t expectedBandwidth = 0; zes_mem_properties_t properties = {ZES_STRUCTURE_TYPE_MEM_PROPERTIES}; zesMemoryGetProperties(handle, &properties); @@ -367,22 +367,21 @@ HWTEST2_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingzesSysmanM hwInfo->platform.usRevId = productHelper.getHwRevIdFromStepping(REVISION_B, *hwInfo); auto pPmt = static_cast(pLinuxSysmanImp->getPlatformMonitoringTechAccess(properties.subdeviceId)); - + pPmt->setGuid(guid64BitMemoryCounters); pPmt->mockVfid0Status = true; pSysfsAccess->mockReadUInt64Value.push_back(hbmRP0Frequency); pSysfsAccess->mockReadReturnStatus.push_back(ZE_RESULT_SUCCESS); EXPECT_EQ(zesMemoryGetBandwidth(handle, &bandwidth), ZE_RESULT_SUCCESS); - expectedReadCounters = vF0Hbm0ReadValue + vF0Hbm1ReadValue + vF0Hbm2ReadValue + vF0Hbm3ReadValue; + expectedReadCounters |= VF0HbmHRead; + expectedReadCounters = (expectedReadCounters << 32) | VF0HbmLRead; + expectedReadCounters = expectedReadCounters * transactionSize; EXPECT_EQ(bandwidth.readCounter, expectedReadCounters); - expectedWriteCounters = vF0Hbm0WriteValue + vF0Hbm1WriteValue + vF0Hbm2WriteValue + vF0Hbm3WriteValue; + expectedWriteCounters |= VF0HbmHWrite; + expectedWriteCounters = (expectedWriteCounters << 32) | VF0HbmLWrite; + expectedWriteCounters = expectedWriteCounters * transactionSize; EXPECT_EQ(bandwidth.writeCounter, expectedWriteCounters); - expectedTimestamp |= vF0TimestampHValue; - expectedTimestamp = (expectedTimestamp << 32) | vF0TimestampLValue; - EXPECT_EQ(bandwidth.timestamp, expectedTimestamp); - EXPECT_EQ(bandwidth.timestamp, expectedTimestamp); expectedBandwidth = 128 * hbmRP0Frequency * 1000 * 1000 * 4; - expectedBandwidth /= 8; EXPECT_EQ(bandwidth.maxBandwidth, expectedBandwidth); } } @@ -394,7 +393,7 @@ HWTEST2_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingzesSysmanM for (auto &handle : handles) { zes_mem_bandwidth_t bandwidth{}; uint64_t expectedReadCounters = 0, expectedWriteCounters = 0; - uint64_t expectedTimestamp = 0, expectedBandwidth = 0; + uint64_t expectedBandwidth = 0; zes_mem_properties_t properties = {ZES_STRUCTURE_TYPE_MEM_PROPERTIES}; zesMemoryGetProperties(handle, &properties); @@ -403,21 +402,21 @@ HWTEST2_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingzesSysmanM hwInfo->platform.usRevId = productHelper.getHwRevIdFromStepping(REVISION_B, *hwInfo); auto pPmt = static_cast(pLinuxSysmanImp->getPlatformMonitoringTechAccess(properties.subdeviceId)); - + pPmt->setGuid(guid64BitMemoryCounters); pPmt->mockVfid1Status = true; pSysfsAccess->mockReadUInt64Value.push_back(hbmRP0Frequency); pSysfsAccess->mockReadReturnStatus.push_back(ZE_RESULT_SUCCESS); EXPECT_EQ(zesMemoryGetBandwidth(handle, &bandwidth), ZE_RESULT_SUCCESS); - expectedReadCounters = vF1Hbm0ReadValue + vF1Hbm1ReadValue + vF1Hbm2ReadValue + vF1Hbm3ReadValue; + expectedReadCounters |= VF0HbmHRead; + expectedReadCounters = (expectedReadCounters << 32) | VF0HbmLRead; + expectedReadCounters = expectedReadCounters * transactionSize; EXPECT_EQ(bandwidth.readCounter, expectedReadCounters); - expectedWriteCounters = vF1Hbm0WriteValue + vF1Hbm1WriteValue + vF1Hbm2WriteValue + vF1Hbm3WriteValue; + expectedWriteCounters |= VF0HbmHWrite; + expectedWriteCounters = (expectedWriteCounters << 32) | VF0HbmLWrite; + expectedWriteCounters = expectedWriteCounters * transactionSize; EXPECT_EQ(bandwidth.writeCounter, expectedWriteCounters); - expectedTimestamp |= vF1TimestampHValue; - expectedTimestamp = (expectedTimestamp << 32) | vF1TimestampLValue; - EXPECT_EQ(bandwidth.timestamp, expectedTimestamp); expectedBandwidth = 128 * hbmRP0Frequency * 1000 * 1000 * 4; - expectedBandwidth /= 8; EXPECT_EQ(bandwidth.maxBandwidth, expectedBandwidth); } } @@ -436,13 +435,13 @@ HWTEST2_F(SysmanDeviceMemoryFixture, GivenValidUsRevIdForRevisionBWhenCallingzes hwInfo->platform.usRevId = productHelper.getHwRevIdFromStepping(REVISION_B, *hwInfo); auto pPmt = static_cast(pLinuxSysmanImp->getPlatformMonitoringTechAccess(properties.subdeviceId)); + pPmt->setGuid(guid64BitMemoryCounters); pPmt->mockVfid1Status = true; pSysfsAccess->mockReadUInt64Value.push_back(hbmRP0Frequency); pSysfsAccess->mockReadReturnStatus.push_back(ZE_RESULT_SUCCESS); EXPECT_EQ(zesMemoryGetBandwidth(handle, &bandwidth), ZE_RESULT_SUCCESS); uint64_t expectedBandwidth = 128 * hbmRP0Frequency * 1000 * 1000 * 4; - expectedBandwidth /= 8; EXPECT_EQ(bandwidth.maxBandwidth, expectedBandwidth); } } @@ -622,6 +621,7 @@ TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenBothVfid0AndVfid1Are zes_mem_bandwidth_t bandwidth; auto pPmt = static_cast(pLinuxSysmanImp->getPlatformMonitoringTechAccess(properties.subdeviceId)); + pPmt->setGuid(guid64BitMemoryCounters); pPmt->mockReadArgumentValue.push_back(1); pPmt->mockReadValueReturnStatus.push_back(ZE_RESULT_SUCCESS); // Return success after reading VF0_VFID pPmt->mockReadArgumentValue.push_back(1); @@ -643,6 +643,7 @@ TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenBothVfid0AndVfid1Are zes_mem_bandwidth_t bandwidth; auto pPmt = static_cast(pLinuxSysmanImp->getPlatformMonitoringTechAccess(properties.subdeviceId)); + pPmt->setGuid(guid64BitMemoryCounters); pPmt->mockReadArgumentValue.push_back(0); pPmt->mockReadValueReturnStatus.push_back(ZE_RESULT_SUCCESS); // Return success after reading VF0_VFID pPmt->mockReadArgumentValue.push_back(0); diff --git a/level_zero/tools/source/sysman/memory/linux/os_memory_imp.cpp b/level_zero/tools/source/sysman/memory/linux/os_memory_imp.cpp index 18137528b1..5e63be429b 100644 --- a/level_zero/tools/source/sysman/memory/linux/os_memory_imp.cpp +++ b/level_zero/tools/source/sysman/memory/linux/os_memory_imp.cpp @@ -41,10 +41,6 @@ ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) { return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; } -ze_result_t LinuxMemoryImp::getBandwidthEx(uint64_t *pReadCounters, uint64_t *pWriteCounters, uint64_t *pMaxBandwidth, uint64_t timeout) { - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - std::unique_ptr OsMemory::create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId) { std::unique_ptr pLinuxMemoryImp = std::make_unique(pOsSysman, onSubdevice, subdeviceId); return pLinuxMemoryImp; diff --git a/level_zero/tools/source/sysman/memory/linux/os_memory_imp.h b/level_zero/tools/source/sysman/memory/linux/os_memory_imp.h index b42fd89936..d40a8f4f66 100644 --- a/level_zero/tools/source/sysman/memory/linux/os_memory_imp.h +++ b/level_zero/tools/source/sysman/memory/linux/os_memory_imp.h @@ -21,7 +21,6 @@ class LinuxMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass { ze_result_t getProperties(zes_mem_properties_t *pProperties) override; ze_result_t getBandwidth(zes_mem_bandwidth_t *pBandwidth) override; ze_result_t getState(zes_mem_state_t *pState) override; - ze_result_t getBandwidthEx(uint64_t *pReadCounters, uint64_t *pWriteCounters, uint64_t *pMaxBandwidth, uint64_t timeout) override; bool isMemoryModuleSupported() override; LinuxMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId); diff --git a/level_zero/tools/source/sysman/memory/linux/os_memory_imp_dg1.cpp b/level_zero/tools/source/sysman/memory/linux/os_memory_imp_dg1.cpp index 59546e34b8..55da3914d3 100644 --- a/level_zero/tools/source/sysman/memory/linux/os_memory_imp_dg1.cpp +++ b/level_zero/tools/source/sysman/memory/linux/os_memory_imp_dg1.cpp @@ -41,10 +41,6 @@ ze_result_t LinuxMemoryImp::getBandwidth(zes_mem_bandwidth_t *pBandwidth) { return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; } -ze_result_t LinuxMemoryImp::getBandwidthEx(uint64_t *pReadCounters, uint64_t *pWriteCounters, uint64_t *pMaxBandwidth, uint64_t timeout) { - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) { std::vector deviceRegions; if (pDrm->queryMemoryInfo() == false) { diff --git a/level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.cpp b/level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.cpp index cb8ce0392b..d07b4296d5 100644 --- a/level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.cpp +++ b/level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.cpp @@ -354,92 +354,6 @@ ze_result_t LinuxMemoryImp::getBandwidth(zes_mem_bandwidth_t *pBandwidth) { return result; } -uint64_t getCounterIncrement(uint32_t counterMaxValue, uint64_t prevValue, uint64_t currentValue) { - if (currentValue < prevValue) { - return (counterMaxValue - prevValue + currentValue); - } - return (currentValue - prevValue); -} -ze_result_t LinuxMemoryImp::getHbmBandwidthEx(uint32_t numHbmModules, uint32_t counterMaxValue, uint64_t *pReadCounters, uint64_t *pWriteCounters, uint64_t *pMaxBandwidth, uint64_t timeout) { - std::vector prevReadCounters(numHbmModules, 0); - std::vector prevWriteCounters(numHbmModules, 0); - uint64_t totalReadCounters = 0; - uint64_t totalWriteCounters = 0; - bool counterInit = false; - ze_result_t result = ZE_RESULT_ERROR_UNKNOWN; - std::string vfId = ""; - result = getVFIDString(vfId); - if (result != ZE_RESULT_SUCCESS) { - NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():getVFIDString returning error:0x%x while retriving VFID string \n", __FUNCTION__, result); - return result; - } - auto &hwInfo = pDevice->getNEODevice()->getHardwareInfo(); - auto productFamily = hwInfo.platform.eProductFamily; - auto &productHelper = pDevice->getNEODevice()->getProductHelper(); - auto stepping = productHelper.getSteppingFromHwRevId(hwInfo); - auto timeToExitLoop = std::chrono::steady_clock::now() + std::chrono::duration(timeout); - do { - for (auto hbmModuleIndex = 0u; hbmModuleIndex < numHbmModules; hbmModuleIndex++) { - uint32_t counterValue = 0; - // To read counters from VFID 0 and HBM module 0, key would be: VF0_HBM0_READ - std::string readCounterKey = vfId + "_HBM" + std::to_string(hbmModuleIndex) + "_READ"; - result = pPmt->readValue(readCounterKey, counterValue); - if (result != ZE_RESULT_SUCCESS) { - NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for readCounterKey returning error:0x%x \n", __FUNCTION__, result); - return result; - } - if (counterInit) { - totalReadCounters += getCounterIncrement(counterMaxValue, prevReadCounters[hbmModuleIndex], counterValue); - } - prevReadCounters[hbmModuleIndex] = counterValue; - counterValue = 0; - // To write counters to VFID 0 and HBM module 0, key would be: VF0_HBM0_Write - std::string writeCounterKey = vfId + "_HBM" + std::to_string(hbmModuleIndex) + "_WRITE"; - result = pPmt->readValue(writeCounterKey, counterValue); - if (result != ZE_RESULT_SUCCESS) { - NEO::printDebugString(NEO::DebugManager.flags.PrintDebugMessages.get(), stderr, "Error@ %s():readValue for writeCounterKey returning error:0x%x \n", __FUNCTION__, result); - return result; - } - if (counterInit) { - totalWriteCounters += getCounterIncrement(counterMaxValue, prevWriteCounters[hbmModuleIndex], counterValue); - } - prevWriteCounters[hbmModuleIndex] = counterValue; - } - counterInit = true; - } while (std::chrono::steady_clock::now() <= timeToExitLoop); - - constexpr uint64_t transactionSize = 32; - *pReadCounters = (totalReadCounters * transactionSize); - *pWriteCounters = (totalWriteCounters * transactionSize); - uint64_t hbmFrequency = 0; - getHbmFrequency(productFamily, stepping, hbmFrequency); - - *pMaxBandwidth = memoryBusWidth * hbmFrequency * numHbmModules; // Value in bytes/secs - return result; -} - -ze_result_t LinuxMemoryImp::getBandwidthEx(uint64_t *pReadCounters, uint64_t *pWriteCounters, uint64_t *pMaxBw, uint64_t timeout) { - if (pPmt == nullptr) { - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; - } - ze_result_t result = ZE_RESULT_ERROR_UNKNOWN; - auto &hwInfo = pDevice->getNEODevice()->getHardwareInfo(); - auto productFamily = hwInfo.platform.eProductFamily; - uint32_t numHbmModules = 0u; - uint32_t counterMaxValue; - switch (productFamily) { - case IGFX_PVC: - numHbmModules = 4u; - counterMaxValue = UINT32_MAX; - result = getHbmBandwidthEx(numHbmModules, counterMaxValue, pReadCounters, pWriteCounters, pMaxBw, timeout); - break; - default: - result = ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; - break; - } - return result; -} - ze_result_t LinuxMemoryImp::getState(zes_mem_state_t *pState) { pState->health = ZES_MEM_HEALTH_UNKNOWN; FirmwareUtil *pFwInterface = pLinuxSysmanImp->getFwUtilInterface(); diff --git a/level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.h b/level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.h index a4cc2f1712..cfeac5cc4f 100644 --- a/level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.h +++ b/level_zero/tools/source/sysman/memory/linux/os_memory_imp_prelim.h @@ -24,7 +24,6 @@ class LinuxMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass { ze_result_t getProperties(zes_mem_properties_t *pProperties) override; ze_result_t getBandwidth(zes_mem_bandwidth_t *pBandwidth) override; ze_result_t getState(zes_mem_state_t *pState) override; - ze_result_t getBandwidthEx(uint64_t *pReadCounters, uint64_t *pWriteCounters, uint64_t *pMaxBandwidth, uint64_t timeout) override; bool isMemoryModuleSupported() override; LinuxMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId); diff --git a/level_zero/tools/source/sysman/memory/memory.h b/level_zero/tools/source/sysman/memory/memory.h index 4b853534a2..7a6e39917e 100644 --- a/level_zero/tools/source/sysman/memory/memory.h +++ b/level_zero/tools/source/sysman/memory/memory.h @@ -22,8 +22,6 @@ class Memory : _zes_mem_handle_t { virtual ze_result_t memoryGetProperties(zes_mem_properties_t *pProperties) = 0; virtual ze_result_t memoryGetBandwidth(zes_mem_bandwidth_t *pBandwidth) = 0; virtual ze_result_t memoryGetState(zes_mem_state_t *pState) = 0; - virtual ze_result_t memoryGetBandwidthEx(uint64_t *pReadCounters, uint64_t *pWriteCounters, uint64_t *pMaxBandwidth, uint64_t timeout) = 0; - static Memory *fromHandle(zes_mem_handle_t handle) { return static_cast(handle); } diff --git a/level_zero/tools/source/sysman/memory/memory_imp.cpp b/level_zero/tools/source/sysman/memory/memory_imp.cpp index aac027c46d..00da5229f1 100644 --- a/level_zero/tools/source/sysman/memory/memory_imp.cpp +++ b/level_zero/tools/source/sysman/memory/memory_imp.cpp @@ -24,10 +24,6 @@ ze_result_t MemoryImp::memoryGetProperties(zes_mem_properties_t *pProperties) { return ZE_RESULT_SUCCESS; } -ze_result_t MemoryImp::memoryGetBandwidthEx(uint64_t *pReadCounters, uint64_t *pWriteCounters, uint64_t *pMaxBandwidth, uint64_t timeout) { - return pOsMemory->getBandwidthEx(pReadCounters, pWriteCounters, pMaxBandwidth, timeout); -} - void MemoryImp::init() { this->initSuccess = pOsMemory->isMemoryModuleSupported(); if (this->initSuccess == true) { diff --git a/level_zero/tools/source/sysman/memory/memory_imp.h b/level_zero/tools/source/sysman/memory/memory_imp.h index 1ab4739be7..f529366198 100644 --- a/level_zero/tools/source/sysman/memory/memory_imp.h +++ b/level_zero/tools/source/sysman/memory/memory_imp.h @@ -19,7 +19,6 @@ class MemoryImp : public Memory, NEO::NonCopyableOrMovableClass { ze_result_t memoryGetProperties(zes_mem_properties_t *pProperties) override; ze_result_t memoryGetBandwidth(zes_mem_bandwidth_t *pBandwidth) override; ze_result_t memoryGetState(zes_mem_state_t *pState) override; - ze_result_t memoryGetBandwidthEx(uint64_t *pReadCounters, uint64_t *pWriteCounters, uint64_t *pMaxBandwidth, uint64_t timeout) override; MemoryImp(OsSysman *pOsSysman, ze_device_handle_t handle); ~MemoryImp() override; diff --git a/level_zero/tools/source/sysman/memory/os_memory.h b/level_zero/tools/source/sysman/memory/os_memory.h index d72b589f99..35cb01956f 100644 --- a/level_zero/tools/source/sysman/memory/os_memory.h +++ b/level_zero/tools/source/sysman/memory/os_memory.h @@ -19,7 +19,6 @@ class OsMemory { virtual ze_result_t getProperties(zes_mem_properties_t *pProperties) = 0; virtual ze_result_t getBandwidth(zes_mem_bandwidth_t *pBandwidth) = 0; virtual ze_result_t getState(zes_mem_state_t *pState) = 0; - virtual ze_result_t getBandwidthEx(uint64_t *pReadCounters, uint64_t *pWriteCounters, uint64_t *pMaxBandwidth, uint64_t timeout) = 0; virtual bool isMemoryModuleSupported() = 0; static std::unique_ptr create(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId); virtual ~OsMemory() {} diff --git a/level_zero/tools/source/sysman/memory/windows/os_memory_imp.cpp b/level_zero/tools/source/sysman/memory/windows/os_memory_imp.cpp index 9089192046..776f80208d 100644 --- a/level_zero/tools/source/sysman/memory/windows/os_memory_imp.cpp +++ b/level_zero/tools/source/sysman/memory/windows/os_memory_imp.cpp @@ -168,10 +168,6 @@ ze_result_t WddmMemoryImp::getProperties(zes_mem_properties_t *pProperties) { return ZE_RESULT_SUCCESS; } -ze_result_t WddmMemoryImp::getBandwidthEx(uint64_t *pReadCounters, uint64_t *pWriteCounters, uint64_t *pMaxBandwidth, uint64_t timeout) { - return ZE_RESULT_ERROR_UNSUPPORTED_FEATURE; -} - ze_result_t WddmMemoryImp::getBandwidth(zes_mem_bandwidth_t *pBandwidth) { uint32_t retValu32 = 0; uint64_t retValu64 = 0; diff --git a/level_zero/tools/source/sysman/memory/windows/os_memory_imp.h b/level_zero/tools/source/sysman/memory/windows/os_memory_imp.h index 2584902e28..a00972d861 100644 --- a/level_zero/tools/source/sysman/memory/windows/os_memory_imp.h +++ b/level_zero/tools/source/sysman/memory/windows/os_memory_imp.h @@ -28,7 +28,6 @@ class WddmMemoryImp : public OsMemory, NEO::NonCopyableOrMovableClass { ze_result_t getProperties(zes_mem_properties_t *pProperties) override; ze_result_t getBandwidth(zes_mem_bandwidth_t *pBandwidth) override; ze_result_t getState(zes_mem_state_t *pState) override; - ze_result_t getBandwidthEx(uint64_t *pReadCounters, uint64_t *pWriteCounters, uint64_t *pMaxBandwidth, uint64_t timeout) override; bool isMemoryModuleSupported() override; WddmMemoryImp(OsSysman *pOsSysman, ze_bool_t onSubdevice, uint32_t subdeviceId); WddmMemoryImp() = default; diff --git a/level_zero/tools/test/unit_tests/sources/sysman/memory/linux/test_sysman_memory_prelim.cpp b/level_zero/tools/test/unit_tests/sources/sysman/memory/linux/test_sysman_memory_prelim.cpp index 4f29802a3d..542e2ef497 100644 --- a/level_zero/tools/test/unit_tests/sources/sysman/memory/linux/test_sysman_memory_prelim.cpp +++ b/level_zero/tools/test/unit_tests/sources/sysman/memory/linux/test_sysman_memory_prelim.cpp @@ -500,6 +500,26 @@ HWTEST2_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingzesSysmanM } } +HWTEST2_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingzesSysmanMemoryGetBandwidthAndVF1_VFIDFailsForOldGuidThenFailureIsReturned, IsPVC) { + setLocalSupportedAndReinit(true); + auto handles = getMemoryHandles(memoryHandleComponentCount); + + for (auto &handle : handles) { + zes_mem_properties_t properties = {}; + zesMemoryGetProperties(handle, &properties); + + zes_mem_bandwidth_t bandwidth; + + auto pPmt = static_cast(pLinuxSysmanImp->getPlatformMonitoringTechAccess(properties.subdeviceId)); + pPmt->setGuid("0xb15a0edd"); + pPmt->mockReadArgumentValue.push_back(1); + pPmt->mockReadValueReturnStatus.push_back(ZE_RESULT_SUCCESS); + pPmt->mockReadArgumentValue.push_back(0); + pPmt->mockReadValueReturnStatus.push_back(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + EXPECT_EQ(zesMemoryGetBandwidth(handle, &bandwidth), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); + } +} + HWTEST2_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingzesSysmanMemoryGetBandwidthAndVF0_HBM_READ_HFailsThenFailureIsReturned, IsPVC) { setLocalSupportedAndReinit(true); auto handles = getMemoryHandles(memoryHandleComponentCount); @@ -537,9 +557,9 @@ HWTEST2_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingzesSysmanM auto pPmt = static_cast(pLinuxSysmanImp->getPlatformMonitoringTechAccess(properties.subdeviceId)); pPmt->setGuid(guid64BitMemoryCounters); pPmt->mockReadArgumentValue.push_back(1); - pPmt->mockReadValueReturnStatus.push_back(ZE_RESULT_SUCCESS); // Return success after reading VF0_VFID + pPmt->mockReadValueReturnStatus.push_back(ZE_RESULT_SUCCESS); pPmt->mockReadArgumentValue.push_back(0); - pPmt->mockReadValueReturnStatus.push_back(ZE_RESULT_SUCCESS); // Return success after reading VF1_VFID + pPmt->mockReadValueReturnStatus.push_back(ZE_RESULT_SUCCESS); pPmt->mockReadArgumentValue.push_back(4); pPmt->mockReadValueReturnStatus.push_back(ZE_RESULT_SUCCESS); pPmt->mockReadArgumentValue.push_back(4); @@ -645,79 +665,6 @@ HWTEST2_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingzesSysmanM } } -HWTEST2_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingGetBandwidthExWhenVFID1IsActiveThenSuccessIsReturnedAndBandwidthIsValid, IsPVC) { - setLocalSupportedAndReinit(true); - auto hwInfo = pLinuxSysmanImp->getDeviceHandle()->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo(); - auto &productHelper = pLinuxSysmanImp->getDeviceHandle()->getNEODevice()->getProductHelper(); - hwInfo->platform.usRevId = productHelper.getHwRevIdFromStepping(REVISION_B, *hwInfo); - auto pPmt = static_cast(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0)); - pPmt->setGuid(guid64BitMemoryCounters); - pPmt->mockVfid1Status = true; - pSysfsAccess->mockReadUInt64Value.push_back(hbmRP0Frequency); - pSysfsAccess->mockReadReturnStatus.push_back(ZE_RESULT_SUCCESS); - uint64_t readCounters = 0; - uint64_t writeCounters = 0; - uint64_t maxBandwidth = 0; - uint64_t timeout = 1; - std::unique_ptr pLinuxMemoryImp = std::make_unique(pOsSysman, true, 0); - EXPECT_EQ(pLinuxMemoryImp->getBandwidthEx(&readCounters, &writeCounters, &maxBandwidth, timeout), ZE_RESULT_SUCCESS); - EXPECT_EQ(readCounters, 0u); - EXPECT_EQ(writeCounters, 0u); - uint64_t expectedBandwidth = 128 * hbmRP0Frequency * 1000 * 1000 * 4; - EXPECT_EQ(maxBandwidth, expectedBandwidth); -} - -HWTEST2_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingGetBandwidthExWhenVFID0IsActiveThenSuccessIsReturnedAndBandwidthIsValid, IsPVC) { - setLocalSupportedAndReinit(true); - auto hwInfo = pLinuxSysmanImp->getDeviceHandle()->getNEODevice()->getRootDeviceEnvironment().getMutableHardwareInfo(); - auto &productHelper = pLinuxSysmanImp->getDeviceHandle()->getNEODevice()->getProductHelper(); - hwInfo->platform.usRevId = productHelper.getHwRevIdFromStepping(REVISION_B, *hwInfo); - auto pPmt = static_cast(pLinuxSysmanImp->getPlatformMonitoringTechAccess(0)); - pPmt->setGuid(guid64BitMemoryCounters); - pPmt->mockVfid0Status = true; - pSysfsAccess->mockReadUInt64Value.push_back(hbmRP0Frequency); - pSysfsAccess->mockReadReturnStatus.push_back(ZE_RESULT_SUCCESS); - uint64_t readCounters = 0; - uint64_t writeCounters = 0; - uint64_t maxBandwidth = 0; - uint64_t timeout = 1; - std::unique_ptr pLinuxMemoryImp = std::make_unique(pOsSysman, true, 0); - EXPECT_EQ(pLinuxMemoryImp->getBandwidthEx(&readCounters, &writeCounters, &maxBandwidth, timeout), ZE_RESULT_SUCCESS); - EXPECT_EQ(readCounters, 0u); - EXPECT_EQ(writeCounters, 0u); - uint64_t expectedBandwidth = 128 * hbmRP0Frequency * 1000 * 1000 * 4; - EXPECT_EQ(maxBandwidth, expectedBandwidth); -} - -TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingGetBandwidthExForUnknownPlatformThenFailureIsReturned) { - setLocalSupportedAndReinit(true); - auto hwInfo = *NEO::defaultHwInfo.get(); - hwInfo.platform.eProductFamily = IGFX_UNKNOWN; - pLinuxSysmanImp->getDeviceHandle()->getNEODevice()->getRootDeviceEnvironmentRef().setHwInfoAndInitHelpers(&hwInfo); - uint64_t readCounters = 0; - uint64_t writeCounters = 0; - uint64_t maxBandwidth = 0; - uint64_t timeout = 1; - std::unique_ptr pLinuxMemoryImp = std::make_unique(pOsSysman, true, 0); - EXPECT_EQ(pLinuxMemoryImp->getBandwidthEx(&readCounters, &writeCounters, &maxBandwidth, timeout), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); -} - -TEST_F(SysmanDeviceMemoryFixture, GivenValidMemoryHandleWhenCallingGetMemoryGetBandwidthExWhenPmtObjectIsNullThenFailureRetuned) { - for (auto &subDeviceIdToPmtEntry : pLinuxSysmanImp->mapOfSubDeviceIdToPmtObject) { - if (subDeviceIdToPmtEntry.second != nullptr) { - delete subDeviceIdToPmtEntry.second; - subDeviceIdToPmtEntry.second = nullptr; - } - } - setLocalSupportedAndReinit(true); - uint64_t readCounters = 0; - uint64_t writeCounters = 0; - uint64_t maxBandwidth = 0; - uint64_t timeout = 1; - std::unique_ptr pLinuxMemoryImp = std::make_unique(pOsSysman, true, 0); - EXPECT_EQ(pLinuxMemoryImp->getBandwidthEx(&readCounters, &writeCounters, &maxBandwidth, timeout), ZE_RESULT_ERROR_UNSUPPORTED_FEATURE); -} - HWTEST2_F(SysmanDeviceMemoryFixture, GivenValidUsRevIdForRevisionBWhenCallingzesSysmanMemoryGetBandwidthThenSuccessIsReturnedAndBandwidthIsValid, IsPVC) { setLocalSupportedAndReinit(true); auto handles = getMemoryHandles(memoryHandleComponentCount);