Skip to content

Commit ce64f66

Browse files
committed
pcm-raw: implement -? option to print all event dscriptions
1 parent fd2bfd5 commit ce64f66

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/pcm-raw.cpp

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ void print_usage(const string & progname)
6565
cout << " -e cha/config=0,name=UNC_CHA_CLOCKTICKS/ -e imc/fixed,name=DRAM_CLOCKS/\n";
6666
#ifdef PCM_SIMDJSON_AVAILABLE
6767
cout << " -e NAME where the NAME is an event from https://github.com/intel/perfmon event lists\n";
68+
cout << " -? | /? => print all events that can be monitored on the host platform along with a description\n";
6869
cout << " -ep path | /ep path => path to event list directory (default is the current directory)\n";
6970
#endif
7071
cout << " -yc | --yescores | /yc => enable specific cores to output\n";
@@ -364,7 +365,7 @@ bool initPMUEventMap()
364365
catch (std::exception& e)
365366
{
366367
cerr << "Error while opening and/or parsing " << path << " : " << e.what() << "\n";
367-
printError();
368+
printError();
368369
return false;
369370
}
370371
}
@@ -431,6 +432,15 @@ class EventMap {
431432
return res;
432433
}
433434

435+
static void print_event_description(const std::string &eventStr) {
436+
if (PMUEventMapJSON.find(eventStr) != PMUEventMapJSON.end()) {
437+
const auto eventObj = PMUEventMapJSON[eventStr];
438+
for (const auto & key : {"BriefDescription", "PublicDescription"})
439+
std::cout << key << " : " << eventObj[key] << "\n";
440+
return;
441+
}
442+
}
443+
434444
static void print_event(const std::string &eventStr) {
435445
if (PMUEventMapJSON.find(eventStr) != PMUEventMapJSON.end()) {
436446
const auto eventObj = PMUEventMapJSON[eventStr];
@@ -454,6 +464,21 @@ class EventMap {
454464
}
455465
};
456466

467+
void printAllEventDescriptions()
468+
{
469+
if (initPMUEventMap() == false)
470+
{
471+
cerr << "ERROR: PMU Event map can not be initialized\n";
472+
return;
473+
}
474+
for (const auto& event : PMUEventMapJSON)
475+
{
476+
std::cout << event.first << "\n";
477+
EventMap::print_event_description(event.first);
478+
std::cout << "\n";
479+
}
480+
}
481+
457482
AddEventStatus addEventFromDB(PCM::RawPMUConfigs& curPMUConfigs, string fullEventStr)
458483
{
459484
if (initPMUEventMap() == false)
@@ -2481,6 +2506,13 @@ int mainThrows(int argc, char * argv[])
24812506
extendPrintout = true;
24822507
continue;
24832508
}
2509+
#if PCM_SIMDJSON_AVAILABLE
2510+
else if (check_argument_equals(*argv, {"-?", "/?"}))
2511+
{
2512+
printAllEventDescriptions();
2513+
return 0;
2514+
}
2515+
#endif
24842516
else if (check_argument_equals(*argv, {"-single-header", "/single-header"}))
24852517
{
24862518
singleHeader = true;

0 commit comments

Comments
 (0)