From 10369f951679c3cbff5b5356cf6bba6b6b0e6dda Mon Sep 17 00:00:00 2001 From: "Bruggeman, Otto G" Date: Fri, 13 Dec 2024 12:56:38 +0100 Subject: [PATCH 01/16] Change protocol to IPv6, this should work fine on Linux dual stack systems --- src/pcm-sensor-server.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/pcm-sensor-server.cpp b/src/pcm-sensor-server.cpp index f8c3c3b4..45f9c30b 100644 --- a/src/pcm-sensor-server.cpp +++ b/src/pcm-sensor-server.cpp @@ -1301,10 +1301,10 @@ class Server { SignalHandler* shi = SignalHandler::getInstance(); shi->setSocket( serverSocket_ ); shi->ignoreSignal( SIGPIPE ); // Sorry Dennis Ritchie, we do not care about this, we always check return codes - #ifndef UNIT_TEST // libFuzzer installs own signal handlers +#ifndef UNIT_TEST // libFuzzer installs own signal handlers shi->installHandler( SignalHandler::handleSignal, SIGTERM ); shi->installHandler( SignalHandler::handleSignal, SIGINT ); - #endif +#endif } Server( Server const & ) = delete; Server & operator = ( Server const & ) = delete; @@ -1320,26 +1320,26 @@ class Server { if ( port_ == 0 ) throw std::runtime_error( "Server Constructor: No port specified." ); - int sockfd = ::socket( AF_INET, SOCK_STREAM, 0 ); + int sockfd = ::socket( AF_INET6, SOCK_STREAM, 0 ); if ( -1 == sockfd ) throw std::runtime_error( "Server Constructor: CanĀ“t create socket" ); int retval = 0; - struct sockaddr_in serv; - serv.sin_family = AF_INET; - serv.sin_port = htons( port_ ); + struct sockaddr_in6 serv; + serv.sin6_family = AF_INET6; + serv.sin6_port = htons( port_ ); if ( listenIP_.empty() ) - serv.sin_addr.s_addr = INADDR_ANY; + serv.sin6_addr = in6addr_any; else { - if ( 1 != ::inet_pton( AF_INET, listenIP_.c_str(), &(serv.sin_addr) ) ) + if ( 1 != ::inet_pton( AF_INET6, listenIP_.c_str(), &(serv.sin6_addr) ) ) { DBG( 3, "close clientsocketFD" ); ::close(sockfd); throw std::runtime_error( "Server Constructor: Cannot convert IP string" ); } } - socklen_t len = sizeof( struct sockaddr_in ); + socklen_t len = sizeof( struct sockaddr_in6 ); retval = ::bind( sockfd, reinterpret_cast(&serv), len ); if ( 0 != retval ) { DBG( 3, "close clientsocketFD" ); From 911b59cfbaacd30a7d11be85c7483e8610693dfb Mon Sep 17 00:00:00 2001 From: "Dementiev, Roman" Date: Fri, 13 Dec 2024 15:55:53 +0100 Subject: [PATCH 02/16] update to simdjson v3.11.2 Change-Id: Iabe3340b98995e52b2c5f0f7fe997b13e6067a62 --- src/simdjson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simdjson b/src/simdjson index b4242d3b..d4bf0cc7 160000 --- a/src/simdjson +++ b/src/simdjson @@ -1 +1 @@ -Subproject commit b4242d3b4ffb97854b035175be077aab712a2d46 +Subproject commit d4bf0cc7ec12c30c68cb7ed443895df546390283 From 0c831127990588dc43b3bdde1fe508bb9db5b6b4 Mon Sep 17 00:00:00 2001 From: "Dementiev, Roman" Date: Tue, 17 Dec 2024 10:49:49 +0100 Subject: [PATCH 03/16] populate sys energy field in additional SystemCounterState getters Change-Id: I90c43c50a1a6fe8bb2b7eb5b1b102d7339a121d1 --- src/cpucounters.cpp | 7 +++++++ src/cpucounters.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/cpucounters.cpp b/src/cpucounters.cpp index f683b380..169ff089 100644 --- a/src/cpucounters.cpp +++ b/src/cpucounters.cpp @@ -6370,6 +6370,7 @@ SystemCounterState PCM::getSystemCounterState() readAndAggregateCXLCMCounters(result); readQPICounters(result); + readSystemEnergyStatus(result); result.ThermalHeadroom = static_cast(PCM_INVALID_THERMAL_HEADROOM); // not available for system } @@ -6977,6 +6978,11 @@ void PCM::getAllCounterStates(SystemCounterState & systemState, std::vectorread(); @@ -7004,6 +7010,7 @@ void PCM::getUncoreCounterStates(SystemCounterState & systemState, std::vector void readMSRs(std::shared_ptr msr, const RawPMUConfig & msrConfig, CounterStateType & result); void readQPICounters(SystemCounterState & counterState); + void readSystemEnergyStatus(SystemCounterState & systemState); void readPCICFGRegisters(SystemCounterState& result); void readMMIORegisters(SystemCounterState& result); void readPMTRegisters(SystemCounterState& result); From e978167187267e8970b8273f96b9498fd278106c Mon Sep 17 00:00:00 2001 From: "Dementiev, Roman" Date: Tue, 7 Jan 2025 10:52:12 +0100 Subject: [PATCH 04/16] fix getThreadsPerCore function on non-Linux OSes Change-Id: I99bc061126d96e6fc94f0a22c8e330874fdf6543 --- src/cpucounters.cpp | 9 +++------ src/topology.h | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/cpucounters.cpp b/src/cpucounters.cpp index 169ff089..27cfd7d3 100644 --- a/src/cpucounters.cpp +++ b/src/cpucounters.cpp @@ -1255,9 +1255,9 @@ bool PCM::discoverSystemTopology() pi = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX)slpi; if (pi->Relationship == RelationProcessorCore) { - threads_per_core = (pi->Processor.Flags == LTP_PC_SMT) ? 2 : 1; - // std::cout << "thr per core: " << threads_per_core << "\n"; - num_cores += threads_per_core; + const auto current_threads_per_core = (pi->Processor.Flags == LTP_PC_SMT) ? 2 : 1; + // std::cout << "thr per core: " << current_threads_per_core << "\n"; + num_cores += current_threads_per_core; } } // std::cout << std::flush; @@ -1372,8 +1372,6 @@ bool PCM::discoverSystemTopology() return false; } - if (entry.socket_id == 0 && entry.core_id == 0) ++threads_per_core; - topology.push_back(entry); socketIdMap[entry.socket_id] = 0; } @@ -1426,7 +1424,6 @@ bool PCM::discoverSystemTopology() socketIdMap[entries[i].socket_id] = 0; if(entries[i].os_id >= 0) { - if(entries[i].core_id == 0 && entries[i].socket_id == 0) ++threads_per_core; if (populateHybridEntry(entries[i], i) == false) { return false; diff --git a/src/topology.h b/src/topology.h index 62529a07..ae6f458a 100644 --- a/src/topology.h +++ b/src/topology.h @@ -172,7 +172,7 @@ class Core : public SystemObject void addHyperThreadInfo( int32 osID, TopologyEntry te ) { if ( te.thread_id >= MAX_THREADS_PER_CORE ) { std::stringstream ss; - ss << "ERROR: Core: thread_id cannot be larger than " << MAX_THREADS_PER_CORE << ".\n"; + ss << "ERROR: Core: thread_id " << te.thread_id << " cannot be larger than " << MAX_THREADS_PER_CORE << ".\n"; throw std::runtime_error( ss.str() ); } if ( threads_.size() == 0 || From 4a2db0ba5aae868ea58071542d5b95f375d818b1 Mon Sep 17 00:00:00 2001 From: "Dementiev, Roman" Date: Tue, 17 Dec 2024 16:39:04 +0100 Subject: [PATCH 05/16] cppcheck: exclude pugixml Change-Id: I8975c6829724adb2fdf000fd7e3ce8ef989dd950 --- scripts/cppcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cppcheck.sh b/scripts/cppcheck.sh index 1069abe0..1db0e23a 100755 --- a/scripts/cppcheck.sh +++ b/scripts/cppcheck.sh @@ -1,5 +1,5 @@ -cppcheck $1 --force --enable=warning --inline-suppr -iPCMService.cpp -isimdjson -iPcmMsrDriver_info.c -igoogletest -DTEXT -j $2 2> cppcheck.out +cppcheck $1 --force --enable=warning --inline-suppr -iPCMService.cpp -isimdjson -ipugixml -iPcmMsrDriver_info.c -igoogletest -DTEXT -j $2 2> cppcheck.out if [ -s cppcheck.out ] then From c9b4b65cd2c13689e31a681eab3be94db5e925f4 Mon Sep 17 00:00:00 2001 From: "Dementiev, Roman" Date: Wed, 8 Jan 2025 11:55:57 +0100 Subject: [PATCH 06/16] pcm-iio: improve an error message Change-Id: I9f81210bcab6d690dd58fdcd5a6340893e4c49f3 --- src/pcm-iio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pcm-iio.cpp b/src/pcm-iio.cpp index 8c77f038..9351e6ff 100644 --- a/src/pcm-iio.cpp +++ b/src/pcm-iio.cpp @@ -2240,7 +2240,7 @@ int mainThrows(int argc, char * argv[]) catch (std::exception & e) { std::cerr << "Error info:" << e.what() << "\n"; - std::cerr << "Event configure file have the problem and cause the program exit, please double check it!\n"; + std::cerr << "The event configuration file (" << ev_file_name << ") cannot be loaded. Please verify the file. Exiting.\n"; exit(EXIT_FAILURE); } From 0a6c61ea663acacc6b48371becf5d5a7c6e53b41 Mon Sep 17 00:00:00 2001 From: "Dementiev, Roman" Date: Wed, 8 Jan 2025 17:45:19 +0100 Subject: [PATCH 07/16] use read32 for unaligned 8B pcicfg msr.sys reads Change-Id: I6c4fb0a9ec8e645834a435cd2aa2c54a8d9a5ab9 --- src/pci.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pci.cpp b/src/pci.cpp index d7f485df..89259937 100644 --- a/src/pci.cpp +++ b/src/pci.cpp @@ -145,8 +145,14 @@ int32 PciHandle::read64(uint64 offset, uint64 * value) warnAlignment<4>("PciHandle::read64", false, offset); if (hDriver != INVALID_HANDLE_VALUE) { + if (offset & 7) + { + // this driver supports only 8-byte aligned reads + // use read32 for unaligned reads + uint32* value32Ptr = (uint32*)value; + return read32(offset, value32Ptr) + read32(offset + sizeof(uint32), value32Ptr + 1); + } PCICFG_Request req; - // ULONG64 result; DWORD reslength = 0; req.bus = bus; req.dev = device; From 6c565708b56c83142bca6a739aca950dcff2b99b Mon Sep 17 00:00:00 2001 From: "Dementiev, Roman" Date: Tue, 17 Dec 2024 16:31:35 +0100 Subject: [PATCH 08/16] Add pugixml as a submodule Change-Id: I7e1bc86fd682696a61ef167f07d4cfe364fe4b84 --- .gitmodules | 3 +++ src/pugixml | 1 + 2 files changed, 4 insertions(+) create mode 160000 src/pugixml diff --git a/.gitmodules b/.gitmodules index 53b7abf1..2415fb6c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "perfmon"] path = perfmon url = https://github.com/intel/perfmon +[submodule "src/pugixml"] + path = src/pugixml + url = https://github.com/zeux/pugixml.git diff --git a/src/pugixml b/src/pugixml new file mode 160000 index 00000000..4bc14418 --- /dev/null +++ b/src/pugixml @@ -0,0 +1 @@ +Subproject commit 4bc14418d12d289dd9978fdce9490a45deeb653e From 731a08b6e895849c09d966ee618a6784895c1ab7 Mon Sep 17 00:00:00 2001 From: "Dementiev, Roman" Date: Wed, 18 Dec 2024 13:45:52 +0100 Subject: [PATCH 09/16] pcm-raw: add PMT XML lookup --- CMakeLists.txt | 22 ++++++++ src/CMakeLists.txt | 4 +- src/pcm-raw.cpp | 44 +++++++++++++++ src/pmt.cpp | 138 +++++++++++++++++++++++++++++++++++++++++++++ src/pmt.h | 28 +++++++++ 5 files changed, 234 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 662e5bff..d10d43ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,6 +150,28 @@ if(PCM_FUZZ) message(STATUS "CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") endif(PCM_FUZZ) +####################### +# pugixml dependency +####################### + +add_library(PCM_PUGIXML INTERFACE) # interface library for pugixml +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/pugixml/src/pugixml.cpp") + message(STATUS "Local pugixml exists: ${CMAKE_CURRENT_SOURCE_DIR}/src/pugixml/src/pugixml.cpp") + set(PCM_PUGIXML_CPP ${CMAKE_CURRENT_SOURCE_DIR}/src/pugixml/src/pugixml.cpp) + add_compile_definitions(PCM_PUGIXML_AVAILABLE) +else() + message(STATUS "Local pugixml doesn't exist") +# message(WARNING +# " ${CMAKE_CURRENT_SOURCE_DIR}/src/pugixml/src/pugixml.cpp doesn't exist\n" +# " Use `git clone --recursive` flag when cloning pcm repository to clone pugixml submodule as well or\n" +# " update submodule with command 'git submodule update --init --recursive' or\n" +# " run 'git clone https//github.com/zeux/pugixml.git' in 'src' directory to get pugixml library") +endif() + +####################### +# End of pugixml dependency section +####################### + ####################### # Install ####################### diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c39770d8..e83434cf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,7 +8,7 @@ set(PROJECT_NAMES pcm pcm-numa pcm-latency pcm-power pcm-msr pcm-memory pcm-tsx set(MINIMUM_OPENSSL_VERSION 1.1.1) -file(GLOB COMMON_SOURCES pcm-accel-common.cpp msr.cpp cpucounters.cpp pci.cpp mmio.cpp tpmi.cpp pmt.cpp bw.cpp utils.cpp topology.cpp debug.cpp threadpool.cpp uncore_pmu_discovery.cpp) +file(GLOB COMMON_SOURCES pcm-accel-common.cpp msr.cpp cpucounters.cpp pci.cpp mmio.cpp tpmi.cpp pmt.cpp bw.cpp utils.cpp topology.cpp debug.cpp threadpool.cpp uncore_pmu_discovery.cpp ${PCM_PUGIXML_CPP}) if (APPLE) file(GLOB UNUX_SOURCES dashboard.cpp) @@ -154,7 +154,7 @@ if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSIO endif() if(SIMDJSON_IS_APPLICABLE) - find_package(simdjson QUIET) # Working form Ububtu 22.04 + find_package(simdjson QUIET) # Working form Ubuntu 22.04 if(simdjson_FOUND) message(STATUS "System SIMDJSON is used") target_link_libraries(PCM_SIMDJSON INTERFACE simdjson::simdjson) diff --git a/src/pcm-raw.cpp b/src/pcm-raw.cpp index a6d4f1f7..84f7d964 100644 --- a/src/pcm-raw.cpp +++ b/src/pcm-raw.cpp @@ -91,6 +91,7 @@ void print_usage(const string & progname) bool verbose = false; double defaultDelay = 1.0; // in seconds +TelemetryDB telemDB; PCM::RawEventConfig initCoreConfig() { @@ -973,6 +974,37 @@ AddEventStatus addEvent(PCM::RawPMUConfigs & curPMUConfigs, string eventStr) } const auto configArray = split(configStr, ','); bool fixed = false; + std::string lookup; + auto pmtAddRecord = [&lookup, &pmuName, &config](const std::vector & records) -> AddEventStatus + { + if (pmuName == "pmt") + { + if (records.empty()) + { + cerr << "ERROR: lookup \"" << lookup << "\" not found in PMT telemetry database\n"; + return AddEventStatus::Failed; + } + if (records.size() > 1) + { + cerr << "ERROR: lookup \"" << lookup << "\" is ambiguous in PMT telemetry database\n\n"; + for (const auto & record : records) + { + cerr << " "; + record.print(cerr); + cerr << "\n"; + } + return AddEventStatus::Failed; + } + config.second = records[0].fullName; + assert(records.size() == 1); + config.first[PCM::PMTEventPosition::UID] = records[0].uid; + config.first[PCM::PMTEventPosition::offset] = records[0].qWordOffset; + config.first[PCM::PMTEventPosition::type] = (records[0].sampleType == "Snapshot") ? PCM::MSRType::Static : PCM::MSRType::Freerun; + config.first[PCM::PMTEventPosition::lsb] = records[0].lsb; + config.first[PCM::PMTEventPosition::msb] = records[0].msb; + } + return AddEventStatus::OK; + }; for (const auto & item : configArray) { if (match(item, "config=", &config.first[0])) @@ -1009,6 +1041,16 @@ AddEventStatus addEvent(PCM::RawPMUConfigs & curPMUConfigs, string eventStr) if (check_for_injections(config.second)) return AddEventStatus::Failed; } + else if (pcm_sscanf(item) >> s_expect("lookup=") >> setw(255) >> lookup) + { + if (pmtAddRecord(telemDB.lookup(lookup)) != AddEventStatus::OK) + return AddEventStatus::Failed; + } + else if (pcm_sscanf(item) >> s_expect("ilookup=") >> setw(255) >> lookup) + { + if (pmtAddRecord(telemDB.ilookup(lookup)) != AddEventStatus::OK) + return AddEventStatus::Failed; + } else if (item == "fixed") { fixed = true; @@ -2343,6 +2385,8 @@ int mainThrows(int argc, char * argv[]) bool reset_pmu = false; PCM* m = PCM::getInstance(); + telemDB.loadFromXML("Intel-PMT"); + parsePID(argc, argv, pid); #ifdef PCM_SIMDJSON_AVAILABLE diff --git a/src/pmt.cpp b/src/pmt.cpp index 9d21a32c..5387a705 100644 --- a/src/pmt.cpp +++ b/src/pmt.cpp @@ -7,6 +7,11 @@ #include #include #include +#include + +#ifdef PCM_PUGIXML_AVAILABLE +#include "pugixml/src/pugixml.hpp" +#endif #ifdef __linux__ #include @@ -79,6 +84,16 @@ class TelemetryArrayLinux : public TelemetryArrayInterface } return t.at(uid).size(); } + static std::vector getUIDs() + { + auto t = getTelemetryFiles(); + std::vector result; + for (auto & guid : t) + { + result.push_back(guid.first); + } + return result; + } virtual ~TelemetryArrayLinux() override { } @@ -124,6 +139,7 @@ class TelemetryArrayDummy : public TelemetryArrayInterface public: TelemetryArrayDummy(const size_t /* uid */, const size_t /* instance */) {}; static size_t numInstances(const size_t /* uid */) { return 0; }; + static std::vector getUIDs() { return std::vector(); }; virtual ~TelemetryArrayDummy() override {}; size_t size() override { return 0;}; // in bytes void load() override {}; @@ -150,6 +166,15 @@ size_t TelemetryArray::numInstances(const size_t uid) #endif } +std::vector TelemetryArray::getUIDs() +{ +#ifdef __linux__ + return TelemetryArrayLinux::getUIDs(); +#else + return TelemetryArrayDummy::getUIDs(); +#endif +} + TelemetryArray::~TelemetryArray() {} size_t TelemetryArray::size() @@ -170,4 +195,117 @@ uint64 TelemetryArray::get(size_t qWordOffset, size_t lsb, size_t msb) return impl->get(qWordOffset, lsb, msb); } + +bool TelemetryDB::loadFromXML(const std::string& pmtXMLPath) +{ +#ifdef PCM_PUGIXML_AVAILABLE + pugi::xml_document doc; + auto result = doc.load_file((pmtXMLPath + "/xml/pmt.xml").c_str()); + + if (!result) + { + std::cerr << "Error: failed to load " << pmtXMLPath << "/xml/pmt.xml" << std::endl; + return false; + } + + constexpr bool debug = false; + + auto guids = TelemetryArray::getUIDs(); + for (pugi::xml_node mapping: doc.child("pmt").child("mappings").children("mapping")) + { + auto guid = read_number(mapping.attribute("guid").value()); + if (std::find(guids.begin(), guids.end(), guid) == guids.end()) + { + // std::cerr << " guid " << std::hex << guid << " not found in telemetry files" << std::endl; + continue; + } + if (debug) std::cout << "Found mapping with guid: " << mapping.attribute("guid").value() << std::endl; + const auto description = mapping.child("description").text().as_string(); + if (debug) std::cout << " Description: " << description << std::endl; + const auto xmlset = mapping.child("xmlset"); + const auto basedir = xmlset.child("basedir").text().as_string(); + const auto aggregator = xmlset.child("aggregator").text().as_string(); + const auto aggregator_path = pmtXMLPath + "/xml/" + basedir + "/" + aggregator; + if (debug) std::cout << " Aggregator XML path: " << aggregator_path << std::endl; + + pugi::xml_document aggregatorDoc; + auto aggregatorResult = aggregatorDoc.load_file(aggregator_path.c_str()); + if (!aggregatorResult) + { + std::cerr << "Error: failed to load " << aggregator_path << std::endl; + return false; + } + + auto aggregatorNode = aggregatorDoc.child("TELEM:Aggregator"); + const std::string aggregatorName = aggregatorNode.child("TELEM:name").text().as_string(); + if (debug) std::cout << " Agregator name: " << aggregatorName << std::endl; + PMTRecord record; + record.uid = guid; + for (pugi::xml_node sampleGroup: aggregatorNode.children("TELEM:SampleGroup")) + { + const auto sampleID = sampleGroup.attribute("sampleID").as_uint(); + if (debug) std::cout << " SampleID: " << sampleID << std::endl; + record.qWordOffset = sampleID; + for (pugi::xml_node sample: sampleGroup.children("TELC:sample")) + { + const auto name = sample.attribute("name").as_string(); + const std::string sampleSubGroup = sample.child("TELC:sampleSubGroup").text().as_string(); + record.fullName = aggregatorName + "." + sampleSubGroup + "." + name; + record.sampleType = sample.child("TELC:sampleType").text().as_string(); + record.lsb = sample.child("TELC:lsb").text().as_uint(); + record.msb = sample.child("TELC:msb").text().as_uint(); + record.description = sample.child("TELC:description").text().as_string(); + if (debug) std::cout << " "; + if (debug) record.print(std::cout); + records.push_back(record); + } + } + + if (debug) std::cout << std::endl; + } + + return true; +#else + (void)pmtXMLPath; // suppress warning + std::cerr << "Error: pugixml library is not available" << std::endl; + return false; +#endif +} + +std::vector TelemetryDB::lookup(const std::string & name) +{ + std::vector result; + for (auto & record : records) + { + if (record.fullName.find(name) != std::string::npos) + { + result.push_back(record); + } + } + return result; +} + +std::vector TelemetryDB::ilookup(const std::string & name) +{ + std::vector result; + auto to_lower = [](const std::string & s) -> std::string + { + std::string result; + for (auto c : s) + { + result.push_back(std::tolower(c)); + } + return result; + }; + for (auto & record : records) + { + if (to_lower(record.fullName).find(to_lower(name)) != std::string::npos) + { + result.push_back(record); + } + } + return result; +} + + }; // namespace pcm \ No newline at end of file diff --git a/src/pmt.h b/src/pmt.h index d3ccc8ab..eba4bed4 100644 --- a/src/pmt.h +++ b/src/pmt.h @@ -5,6 +5,7 @@ #include "types.h" #include +#include namespace pcm { @@ -28,10 +29,37 @@ class TelemetryArray : public TelemetryArrayInterface public: TelemetryArray(const size_t /* uid */, const size_t /* instance */); static size_t numInstances(const size_t /* uid */); + static std::vector getUIDs(); virtual ~TelemetryArray() override; size_t size() override; // in bytes void load() override; uint64 get(size_t qWordOffset, size_t lsb, size_t msb) override; }; +class TelemetryDB +{ +public: + struct PMTRecord + { + size_t uid; + std::string fullName; + std::string sampleType; + size_t qWordOffset; + uint32 lsb; + uint32 msb; + std::string description; + void print(std::ostream & os) const + { + os << "uid: " << uid << " fullName: " << fullName << " description: \"" << description << + "\" sampleType: " << sampleType << " qWordOffset: " << qWordOffset << " lsb: " << lsb << " msb: " << msb << std::endl; + } + }; + std::vector records; + TelemetryDB() = default; + bool loadFromXML(const std::string& pmtXMLPath); + virtual ~TelemetryDB() = default; + std::vector lookup(const std::string & name); + std::vector ilookup(const std::string & name); +}; + } // namespace pcm \ No newline at end of file From 9b2c06ec860b47f103f5f4112b6af8c28e609deb Mon Sep 17 00:00:00 2001 From: "Dementiev, Roman" Date: Thu, 19 Dec 2024 12:18:14 +0100 Subject: [PATCH 10/16] address warnings Change-Id: Iae78f9950f1e82926aef8197dd60cee355a2c0f5 --- src/pmt.cpp | 3 +-- src/pmt.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pmt.cpp b/src/pmt.cpp index 5387a705..6da9702a 100644 --- a/src/pmt.cpp +++ b/src/pmt.cpp @@ -220,8 +220,7 @@ bool TelemetryDB::loadFromXML(const std::string& pmtXMLPath) continue; } if (debug) std::cout << "Found mapping with guid: " << mapping.attribute("guid").value() << std::endl; - const auto description = mapping.child("description").text().as_string(); - if (debug) std::cout << " Description: " << description << std::endl; + if (debug) std::cout << " Description: " << mapping.child("description").text().as_string() << std::endl; const auto xmlset = mapping.child("xmlset"); const auto basedir = xmlset.child("basedir").text().as_string(); const auto aggregator = xmlset.child("aggregator").text().as_string(); diff --git a/src/pmt.h b/src/pmt.h index eba4bed4..71f28103 100644 --- a/src/pmt.h +++ b/src/pmt.h @@ -50,7 +50,7 @@ class TelemetryDB std::string description; void print(std::ostream & os) const { - os << "uid: " << uid << " fullName: " << fullName << " description: \"" << description << + os << "uid: " << uid << " fullName: " << fullName << " description: \"" << description << "\" sampleType: " << sampleType << " qWordOffset: " << qWordOffset << " lsb: " << lsb << " msb: " << msb << std::endl; } }; From 449ad8c1d0b4abb53c707c08794bd5089b11573d Mon Sep 17 00:00:00 2001 From: "Dementiev, Roman" Date: Thu, 19 Dec 2024 12:23:53 +0100 Subject: [PATCH 11/16] Add Intel-PMT as a submodule Change-Id: I095faf303ace0e77e49fd2d75758723963d26edc --- .gitmodules | 3 +++ Intel-PMT | 1 + 2 files changed, 4 insertions(+) create mode 160000 Intel-PMT diff --git a/.gitmodules b/.gitmodules index 2415fb6c..bcd6dc7f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "src/pugixml"] path = src/pugixml url = https://github.com/zeux/pugixml.git +[submodule "Intel-PMT"] + path = Intel-PMT + url = https://github.com/intel/Intel-PMT.git diff --git a/Intel-PMT b/Intel-PMT new file mode 160000 index 00000000..5b741dbc --- /dev/null +++ b/Intel-PMT @@ -0,0 +1 @@ +Subproject commit 5b741dbc95dd71d5f19d178f4a5dfd214df83740 From f1c5b1dea88b7d9dea3122841fc843463485f742 Mon Sep 17 00:00:00 2001 From: "Dementiev, Roman" Date: Thu, 19 Dec 2024 13:56:00 +0100 Subject: [PATCH 12/16] change error to info Change-Id: I754b90bbb66186d244c115d2e18fa833c4e81a77 --- src/pmt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pmt.cpp b/src/pmt.cpp index 6da9702a..18527299 100644 --- a/src/pmt.cpp +++ b/src/pmt.cpp @@ -266,7 +266,7 @@ bool TelemetryDB::loadFromXML(const std::string& pmtXMLPath) return true; #else (void)pmtXMLPath; // suppress warning - std::cerr << "Error: pugixml library is not available" << std::endl; + std::cerr << "INFO: pugixml library is not available" << std::endl; return false; #endif } From cf75a4b4eb9c3870827ecb191fc5fe95d92b87aa Mon Sep 17 00:00:00 2001 From: "Dementiev, Roman" Date: Thu, 9 Jan 2025 09:28:24 +0100 Subject: [PATCH 13/16] tpmi and uncore discovery is available on server cpus only Change-Id: If8cbd45df7c70ff914a24ad5de9d132c8f89772b --- src/cpucounters.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cpucounters.cpp b/src/cpucounters.cpp index 27cfd7d3..ab3299c4 100644 --- a/src/cpucounters.cpp +++ b/src/cpucounters.cpp @@ -2027,7 +2027,7 @@ void PCM::initUncoreObjects() //TPMIHandle::setVerbose(true); try { - if (TPMIHandle::getNumInstances() == (size_t)num_sockets) + if (isServerCPU() && TPMIHandle::getNumInstances() == (size_t)num_sockets) { // std::cerr << "DEBUG: TPMIHandle::getNumInstances(): " << TPMIHandle::getNumInstances() << "\n"; UFSStatus.resize(num_sockets); @@ -3159,7 +3159,10 @@ PCM::PCM() : std::cerr << "\n"; #endif - uncorePMUDiscovery = std::make_shared(); + if (isServerCPU()) + { + uncorePMUDiscovery = std::make_shared(); + } initUncoreObjects(); From 8618fe2713adcb851740d5658d45bbd04e8c8fc0 Mon Sep 17 00:00:00 2001 From: "Dementiev, Roman" Date: Thu, 9 Jan 2025 15:36:03 +0100 Subject: [PATCH 14/16] update dependencies Change-Id: Ia70709df2d0df7e9719df8c3bbaf9b181dd0cccf --- Intel-PMT | 2 +- perfmon | 2 +- src/pugixml | 2 +- src/simdjson | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Intel-PMT b/Intel-PMT index 5b741dbc..76f9e9e5 160000 --- a/Intel-PMT +++ b/Intel-PMT @@ -1 +1 @@ -Subproject commit 5b741dbc95dd71d5f19d178f4a5dfd214df83740 +Subproject commit 76f9e9e5858399ab59225953932117b31a6fef16 diff --git a/perfmon b/perfmon index d8859e3a..3fc7a87f 160000 --- a/perfmon +++ b/perfmon @@ -1 +1 @@ -Subproject commit d8859e3a5480721a13651cf20a35a1727afcd570 +Subproject commit 3fc7a87fde40817b521dbfb079da85b52a0cc96b diff --git a/src/pugixml b/src/pugixml index 4bc14418..06318b08 160000 --- a/src/pugixml +++ b/src/pugixml @@ -1 +1 @@ -Subproject commit 4bc14418d12d289dd9978fdce9490a45deeb653e +Subproject commit 06318b084a0c1043516acbdae39fdf617fee474c diff --git a/src/simdjson b/src/simdjson index d4bf0cc7..57699bfe 160000 --- a/src/simdjson +++ b/src/simdjson @@ -1 +1 @@ -Subproject commit d4bf0cc7ec12c30c68cb7ed443895df546390283 +Subproject commit 57699bfed894706798c2cefb4d40cc262127595b From b802d0d7b15a9b4bc0ce7bd14b7f124cf7564b47 Mon Sep 17 00:00:00 2001 From: "Dementiev, Roman" Date: Thu, 9 Jan 2025 20:58:37 +0100 Subject: [PATCH 15/16] include cctype Change-Id: Ifc5cf2c73a5e65aa029d7b2bf60cf109a5ac58e6 --- src/pmt.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pmt.cpp b/src/pmt.cpp index 18527299..b99f4a5c 100644 --- a/src/pmt.cpp +++ b/src/pmt.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #ifdef PCM_PUGIXML_AVAILABLE #include "pugixml/src/pugixml.hpp" From 92a7656414dc246d573e9f126fc7047ffb5453a4 Mon Sep 17 00:00:00 2001 From: "Dementiev, Roman" Date: Fri, 10 Jan 2025 07:52:30 +0100 Subject: [PATCH 16/16] cmake 3.12+ is now required Change-Id: I6488ba28423edf38b8a578f98655c64e22b106c2 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d10d43ad..9e216abe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright (c) 2022-2024, Intel Corporation +# Copyright (c) 2022-2025, Intel Corporation -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.12) project(PCM)