Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/freebsd_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ jobs:
submodules: recursive
- name: build in FreeBSD VM
id: build
uses: cross-platform-actions/action@cdc9ee69ef84a5f2e59c9058335d9c57bcb4ac86 # v0.25.0
uses: cross-platform-actions/action@2d97d42e1972a17b045fd709a422f7e55a86230d
with:
memory: 2048
shell: sh
operating_system: freebsd
version: '14.1'
version: '14.2'
run: |
sudo mkdir -p /usr/local/etc/pkg/repos
sudo sh -c 'echo "FreeBSD: { url: \"https://pkg.FreeBSD.org/\${ABI}/quarterly\", mirror_type: \"srv\", enabled: yes }" > /usr/local/etc/pkg/repos/FreeBSD.conf'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/freebsd_scan_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ jobs:
submodules: recursive
- name: clang scan build in FreeBSD VM
id: clang-scan-build
uses: cross-platform-actions/action@cdc9ee69ef84a5f2e59c9058335d9c57bcb4ac86 # v0.25.0
uses: cross-platform-actions/action@2d97d42e1972a17b045fd709a422f7e55a86230d
with:
memory: 2048
shell: sh
operating_system: freebsd
version: '14.1'
version: '14.2'
run: |
sudo mkdir -p /usr/local/etc/pkg/repos
sudo sh -c 'echo "FreeBSD: { url: \"https://pkg.FreeBSD.org/\${ABI}/quarterly\", mirror_type: \"srv\", enabled: yes }" > /usr/local/etc/pkg/repos/FreeBSD.conf'
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ if(UNIX) # APPLE, LINUX, FREE_BSD
message(STATUS "CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}")
message(STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")

install(DIRECTORY "perfmon" DESTINATION ${CMAKE_INSTALL_DATADIR}/pcm)

endif(UNIX)

if(PCM_FUZZ)
Expand Down
2 changes: 1 addition & 1 deletion perfmon
Submodule perfmon updated 57 files
+1 −1 .github/workflows/bandit.yml
+1 −1 .github/workflows/create-perf-json.yml
+1 −1 .github/workflows/verify-mapfile.yml
+13 −13 ADL/events/alderlake_goldencove_core.json
+41 −41 ADL/events/alderlake_gracemont_core.json
+4 −4 ADL/events/alderlake_uncore.json
+4 −4 ADL/events/alderlake_uncore_experimental.json
+0 −1,806 ADL/metrics/perf/alderlake_metrics_goldencove_core_perf.json
+304 −7 ARL/events/arrowlake_crestmont_core.json
+58 −4 ARL/events/arrowlake_lioncove_core.json
+4 −4 ARL/events/arrowlake_skymont_core.json
+4 −4 ARL/events/arrowlake_uncore.json
+4 −4 ARL/events/arrowlake_uncore_experimental.json
+0 −1,756 ARL/metrics/perf/arrowlake_metrics_lioncove_core_perf.json
+0 −1,059 BDW/metrics/perf/broadwell_metrics_perf.json
+0 −1,104 BDX/metrics/perf/broadwellx_metrics_perf.json
+0 −1,707 CLX/metrics/perf/cascadelakex_metrics_perf.json
+7 −7 EMR/metrics/emeraldrapids_metrics.json
+0 −1,949 EMR/metrics/perf/emeraldrapids_metrics_perf.json
+53 −28 GNR/events/graniterapids_core.json
+21 −3 GNR/events/graniterapids_uncore.json
+579 −39 GNR/events/graniterapids_uncore_experimental.json
+146 −0 GNR/metrics/graniterapids_retire_latency.json
+0 −2,016 GNR/metrics/perf/graniterapids_metrics_perf.json
+515 −15 GRR/events/grandridge_core.json
+29 −11 GRR/events/grandridge_uncore.json
+616 −22 GRR/events/grandridge_uncore_experimental.json
+0 −544 GRR/metrics/perf/grandridge_metrics_perf.json
+0 −874 HSW/metrics/perf/haswell_metrics_perf.json
+0 −919 HSX/metrics/perf/haswellx_metrics_perf.json
+0 −1,744 ICL/metrics/perf/icelake_metrics_perf.json
+0 −1,801 ICX/metrics/perf/icelakex_metrics_perf.json
+0 −1,805 LNL/metrics/perf/lunarlake_metrics_lioncove_core_perf.json
+354 −29 MTL/events/meteorlake_crestmont_core.json
+13 −13 MTL/events/meteorlake_redwoodcove_core.json
+4 −4 MTL/events/meteorlake_uncore.json
+32 −4 MTL/events/meteorlake_uncore_experimental.json
+0 −1,880 MTL/metrics/perf/meteorlake_metrics_redwoodcove_core_perf.json
+30 −4 README.md
+0 −1,750 RKL/metrics/perf/rocketlake_metrics_perf.json
+0 −1,588 SKL/metrics/perf/skylake_metrics_perf.json
+0 −1,692 SKX/metrics/perf/skylakex_metrics_perf.json
+0 −1,949 SPR/metrics/perf/sapphirerapids_metrics_perf.json
+0 −1,970 SPR/metrics/perf/sapphirerapidshbm_metrics_perf.json
+7 −7 SPR/metrics/sapphirerapids_metrics.json
+271 −227 SPR/metrics/sapphirerapidshbm_metrics.json
+3 −3 SRF/events/sierraforest_core.json
+21 −3 SRF/events/sierraforest_uncore.json
+435 −3 SRF/events/sierraforest_uncore_experimental.json
+0 −544 SRF/metrics/perf/sierraforest_metrics_perf.json
+0 −1,750 TGL/metrics/perf/tigerlake_metrics_perf.json
+60 −58 mapfile.csv
+1 −1 scripts/ci/verify_mapfile/mapfile_schema.json
+8 −1 scripts/ci/verify_mapfile/verify_mapfile.py
+2 −0 scripts/config/replacements_config.json
+72 −18 scripts/create_perf_json.py
+116 −120 scripts/perf_format_converter.py
119 changes: 87 additions & 32 deletions src/pcm-raw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ void print_usage(const string & progname)
cout << " -e cha/config=0,name=UNC_CHA_CLOCKTICKS/ -e imc/fixed,name=DRAM_CLOCKS/\n";
#ifdef PCM_SIMDJSON_AVAILABLE
cout << " -e NAME where the NAME is an event from https://github.com/intel/perfmon event lists\n";
cout << " -? | /? => print all events that can be monitored on the host platform along with a description\n";
cout << " -ep path | /ep path => path to event list directory (default is the current directory)\n";
#endif
cout << " -yc | --yescores | /yc => enable specific cores to output\n";
Expand Down Expand Up @@ -217,16 +218,24 @@ bool initPMUEventMap()
inited = true;
const auto mapfile = "mapfile.csv";
const auto mapfilePath = eventFileLocationPrefix + "/" + mapfile;
const auto mapfilePathAlt = getInstallPathPrefix() + "perfmon/" + mapfile;
std::ifstream in(mapfilePath);
std::string line, item;

if (!in.is_open())
{
cerr << "ERROR: File " << mapfilePath << " can't be open. \n";
cerr << " Use -ep <pcm_source_directory>/perfmon option if you cloned PCM source repository recursively with submodules,\n";
cerr << " or run 'git clone https://github.com/intel/perfmon' to download the perfmon event repository and use -ep <perfmon_directory> option\n";
cerr << " or download the file from https://raw.githubusercontent.com/intel/perfmon/main/" << mapfile << " \n";
return false;
in.open(mapfilePathAlt);
if (!in.is_open())
{
cerr << "ERROR: File " << mapfilePath << " or " << mapfilePathAlt << " can't be open. \n";
#ifndef _MSC_VER
cerr << " run 'make install' in the pcm build directory if you cloned PCM source repository recursively with submodules, or\n";
#endif
cerr << " use -ep <pcm_source_directory>/perfmon option if you cloned PCM source repository recursively with submodules,\n";
cerr << " or run 'git clone https://github.com/intel/perfmon' to download the perfmon event repository and use -ep <perfmon_directory> option\n";
cerr << " or download the file from https://raw.githubusercontent.com/intel/perfmon/main/" << mapfile << " \n";
return false;
}
}
int32 FMSPos = -1;
int32 FilenamePos = -1;
Expand Down Expand Up @@ -255,12 +264,12 @@ bool initPMUEventMap()
cerr << "Can't read first line from " << mapfile << " \n";
return false;
}
// cout << FMSPos << " " << FilenamePos << " " << EventTypetPos << "\n";
DBG(1, FMSPos , " " , FilenamePos , " " , EventTypetPos);
assert(FMSPos >= 0);
assert(FilenamePos >= 0);
assert(EventTypetPos >= 0);
const std::string ourFMS = PCM::getInstance()->getCPUFamilyModelString();
// cout << "Our FMS: " << ourFMS << "\n";
DBG(1, "Our FMS: " , ourFMS);
std::multimap<std::string, std::string> eventFiles;
cerr << "Matched event files:\n";
while (std::getline(in, line))
Expand Down Expand Up @@ -300,6 +309,7 @@ bool initPMUEventMap()
{
const std::string path1 = eventFileLocationPrefix + evfile.second;
const std::string path2 = eventFileLocationPrefix + evfile.second.substr(evfile.second.rfind('/'));
const std::string path3 = getInstallPathPrefix() + "perfmon" + evfile.second;

if (std::ifstream(path1).good())
{
Expand All @@ -309,9 +319,13 @@ bool initPMUEventMap()
{
path = path2;
}
else if (std::ifstream(path3).good())
{
path = path3;
}
else
{
std::cerr << "ERROR: Can't open event file at location " << path1 << " or " << path2 << "\n";
std::cerr << "ERROR: Can't open event file at location " << path1 << " or " << path2 << " or " << path3 << "\n";
printError();
return false;
}
Expand Down Expand Up @@ -351,7 +365,7 @@ bool initPMUEventMap()
catch (std::exception& e)
{
cerr << "Error while opening and/or parsing " << path << " : " << e.what() << "\n";
printError();
printError();
return false;
}
}
Expand Down Expand Up @@ -418,6 +432,15 @@ class EventMap {
return res;
}

static void print_event_description(const std::string &eventStr) {
if (PMUEventMapJSON.find(eventStr) != PMUEventMapJSON.end()) {
const auto eventObj = PMUEventMapJSON[eventStr];
for (const auto & key : {"BriefDescription", "PublicDescription"})
std::cout << key << " : " << eventObj[key] << "\n";
return;
}
}

static void print_event(const std::string &eventStr) {
if (PMUEventMapJSON.find(eventStr) != PMUEventMapJSON.end()) {
const auto eventObj = PMUEventMapJSON[eventStr];
Expand All @@ -437,19 +460,52 @@ class EventMap {
}
}
}
}

static void print_event_debug(const std::string &eventStr, const int debugLevel = 1) {
if (PMUEventMapJSON.find(eventStr) != PMUEventMapJSON.end()) {
const auto eventObj = PMUEventMapJSON[eventStr];
for (const auto & keyValue : eventObj)
DBG(debugLevel, "JSON " , keyValue.key , " : " , keyValue.value);
}

for (auto &EventMapTSV : PMUEventMapsTSV) {
if (EventMapTSV.find(eventStr) != EventMapTSV.end()) {
const auto &col_names = EventMapTSV["COL_NAMES"];
const auto event = EventMapTSV[eventStr];
if (EventMapTSV.find(eventStr) != EventMapTSV.end()) {
for (size_t i = 0 ; i < col_names.size() ; i++)
DBG(debugLevel, "TSV " , col_names[i] , " : " , event[i]);
}
}
}
}
};

void printAllEventDescriptions()
{
if (initPMUEventMap() == false)
{
cerr << "ERROR: PMU Event map can not be initialized\n";
return;
}
for (const auto& event : PMUEventMapJSON)
{
std::cout << event.first << "\n";
EventMap::print_event_description(event.first);
std::cout << "\n";
}
}

AddEventStatus addEventFromDB(PCM::RawPMUConfigs& curPMUConfigs, string fullEventStr)
{
if (initPMUEventMap() == false)
{
cerr << "ERROR: PMU Event map can not be initialized\n";
return AddEventStatus::Failed;
}
// cerr << "Parsing event " << fullEventStr << "\n";
// cerr << "size: " << fullEventStr.size() << "\n";
DBG(2, "Parsing event " , fullEventStr);
DBG(2, "size: " , fullEventStr.size());
while (fullEventStr.empty() == false && fullEventStr.back() == ' ')
{
fullEventStr.resize(fullEventStr.size() - 1); // remove trailing spaces
Expand All @@ -469,7 +525,9 @@ AddEventStatus addEventFromDB(PCM::RawPMUConfigs& curPMUConfigs, string fullEven

const auto eventStr = EventTokens[0];

// cerr << "size: " << eventStr.size() << "\n";
EventMap::print_event_debug(eventStr);

DBG(2, "size: " , eventStr.size());
PCM::RawEventConfig config = { {0,0,0,0,0}, "" };
std::string pmuName;

Expand Down Expand Up @@ -623,17 +681,17 @@ AddEventStatus addEventFromDB(PCM::RawPMUConfigs& curPMUConfigs, string fullEven
{
std::string unit = EventMap::getField(eventStr, "Unit");
lowerCase(unit);
// std::cout << eventStr << " is uncore event for unit " << unit << "\n";
DBG(2, eventStr , " is uncore event for unit " , unit);
pmuName = (pmuNameMap.find(unit) == pmuNameMap.end()) ? unit : pmuNameMap[unit];
}

config.second = fullEventStr;

if (1)
{
// cerr << "pmuName: " << pmuName << " full event "<< fullEventStr << " \n";
DBG(2, "pmuName: " , pmuName , " full event ", fullEventStr);
std::string CounterStr = EventMap::getField(eventStr, "Counter");
// cout << "Counter: " << CounterStr << "\n";
DBG(2, "Counter: " , CounterStr);
int fixedCounter = -1;
fixed = (pcm_sscanf(CounterStr) >> s_expect("Fixed counter ") >> fixedCounter) ? true : false;
if (!fixed){
Expand Down Expand Up @@ -707,15 +765,15 @@ AddEventStatus addEventFromDB(PCM::RawPMUConfigs& curPMUConfigs, string fullEven
};
for (const auto & registerKeyValue : PMUDeclObj)
{
// cout << "Setting " << registerKeyValue.key << " : " << registerKeyValue.value << "\n";
DBG(2, "Setting " , registerKeyValue.key , " : " , registerKeyValue.value);
simdjson::dom::object fieldDescriptionObj = registerKeyValue.value;
// cout << " config: " << uint64_t(fieldDescriptionObj["Config"]) << "\n";
// cout << " Position: " << uint64_t(fieldDescriptionObj["Position"]) << "\n";
DBG(2, " config: " , uint64_t(fieldDescriptionObj["Config"]));
DBG(2, " Position: " , uint64_t(fieldDescriptionObj["Position"]));
const std::string fieldNameStr{ registerKeyValue.key.begin(), registerKeyValue.key.end() };
if (fieldNameStr == "MSRIndex")
{
string fieldValueStr = EventMap::getField(eventStr, fieldNameStr);
// cout << "MSR field " << fieldNameStr << " value is " << fieldValueStr << " (" << read_number(fieldValueStr.c_str()) << ") offcore=" << offcore << "\n";
DBG(2, "MSR field " , fieldNameStr , " value is " , fieldValueStr , " (" , read_number(fieldValueStr.c_str()) , ") offcore=" , offcore);;
lowerCase(fieldValueStr);
if (fieldValueStr == "0" || fieldValueStr == "0x00")
{
Expand All @@ -732,7 +790,7 @@ AddEventStatus addEventFromDB(PCM::RawPMUConfigs& curPMUConfigs, string fullEven
}
MSRIndexStr = MSRIndexes[offcoreEventIndex];
}
// cout << " MSR field " << fieldNameStr << " value is " << MSRIndexStr << " (" << read_number(MSRIndexStr.c_str()) << ") offcore=" << offcore << "\n";
DBG(2, " MSR field " , fieldNameStr , " value is " , MSRIndexStr , " (" , read_number(MSRIndexStr.c_str()) , ") offcore=" , offcore);
MSRObject = registerKeyValue.value[MSRIndexStr];
const string msrValueStr = EventMap::getField(eventStr, "MSRValue");
setMSRValue(msrValueStr);
Expand All @@ -745,7 +803,7 @@ AddEventStatus addEventFromDB(PCM::RawPMUConfigs& curPMUConfigs, string fullEven
}
if (!EventMap::isField(eventStr, fieldNameStr))
{
// cerr << fieldNameStr << " not found\n";
DBG(2, fieldNameStr , " not found");
if (fieldDescriptionObj["DefaultValue"].error() == NO_SUCH_FIELD)
{
cerr << "ERROR: DefaultValue not provided for field \"" << fieldNameStr << "\" in " << path << "\n";
Expand Down Expand Up @@ -773,7 +831,7 @@ AddEventStatus addEventFromDB(PCM::RawPMUConfigs& curPMUConfigs, string fullEven
}
fieldValueStr = offcoreCodes[offcoreEventIndex];
}
// cout << " field " << fieldNameStr << " value is " << fieldValueStr << " (" << read_number(fieldValueStr.c_str()) << ") offcore=" << offcore << "\n";
DBG(2, " field " , fieldNameStr , " value is " , fieldValueStr , " (" , read_number(fieldValueStr.c_str()) , ") offcore=" , offcore);
setConfig(config, fieldDescriptionObj, read_number(fieldValueStr.c_str()), position);
}
}
Expand Down Expand Up @@ -921,13 +979,6 @@ AddEventStatus addEventFromDB(PCM::RawPMUConfigs& curPMUConfigs, string fullEven
}
}

/*
for (const auto& keyValue : eventObj)
{
cout << keyValue.key << " : " << keyValue.value << "\n";
}
*/

printEvent(pmuName, fixed, config);

return AddEventStatus::OK;
Expand Down Expand Up @@ -2475,6 +2526,13 @@ int mainThrows(int argc, char * argv[])
extendPrintout = true;
continue;
}
#if PCM_SIMDJSON_AVAILABLE
else if (check_argument_equals(*argv, {"-?", "/?"}))
{
printAllEventDescriptions();
return 0;
}
#endif
else if (check_argument_equals(*argv, {"-single-header", "/single-header"}))
{
singleHeader = true;
Expand Down Expand Up @@ -2736,9 +2794,6 @@ int mainThrows(int argc, char * argv[])
}
m->globalUnfreezeUncoreCounters();

//cout << "Time elapsed: " << dec << fixed << AfterTime - BeforeTime << " ms\n";
//cout << "Called sleep function for " << dec << fixed << delay_ms << " ms\n";

printAll(group, m, SysBeforeState, SysAfterState, BeforeState, AfterState, BeforeUncoreState, AfterUncoreState, BeforeSocketState, AfterSocketState, PMUConfigs, groupNr == nGroups);
if (nGroups == 1)
{
Expand Down