Skip to content

Commit 5f90ef4

Browse files
committed
pcm-raw: add generic uncore PMU path
1 parent 304389d commit 5f90ef4

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

src/cpucounters.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5721,6 +5721,16 @@ PCM::ErrorCode PCM::program(const RawPMUConfigs& curPMUConfigs_, const bool sile
57215721
{
57225722
programCXLDP(events64);
57235723
}
5724+
else if (strToUncorePMUID(type) != INVALID_PMU_ID)
5725+
{
5726+
const auto pmu_id = strToUncorePMUID(type);
5727+
programUncorePMUs(pmu_id, [&events64, &events, &pmu_id](UncorePMU& pmu)
5728+
{
5729+
uint64 * eventsIter = (uint64 *)events64;
5730+
pmu.initFreeze(UNC_PMON_UNIT_CTL_FRZ_EN);
5731+
PCM::program(pmu, eventsIter, eventsIter + (std::min)(events.programmable.size(), (size_t)ServerUncoreCounterState::maxCounters), UNC_PMON_UNIT_CTL_FRZ_EN);
5732+
});
5733+
}
57245734
else
57255735
{
57265736
std::cerr << "ERROR: unrecognized PMU type \"" << type << "\" when trying to program PMUs.\n";

src/cpucounters.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,15 @@ class PCM_API PCM
651651
UBOX_PMU_ID,
652652
INVALID_PMU_ID
653653
};
654+
private:
655+
std::unordered_map<std::string, int> strToUncorePMUID_ {
656+
};
657+
public:
658+
UncorePMUIDs strToUncorePMUID(const std::string & type) const
659+
{
660+
const auto iter = strToUncorePMUID_.find(type);
661+
return (iter == strToUncorePMUID_.end()) ? INVALID_PMU_ID : (UncorePMUIDs)iter->second;
662+
}
654663
private:
655664
typedef std::unordered_map<int, UncorePMUArrayType> UncorePMUMapType;
656665
// socket -> die -> pmu map -> pmu ref array

src/pcm-raw.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,8 @@ uint32 numTMAEvents(PCM* m)
12391239
return (m->isHWTMAL2Supported() ? 8 : 4);
12401240
}
12411241

1242+
uint32 pmu_type = PCM::INVALID_PMU_ID;
1243+
12421244
void printTransposed(const PCM::RawPMUConfigs& curPMUConfigs,
12431245
PCM* m,
12441246
SystemCounterState& SysBeforeState, SystemCounterState& SysAfterState,
@@ -1719,6 +1721,14 @@ void printTransposed(const PCM::RawPMUConfigs& curPMUConfigs,
17191721
[&]() { printUncoreRows([](const uint32 u, const uint32 i, const ServerUncoreCounterState& before, const ServerUncoreCounterState& after) { return getCXLDPCounter(u, i, before, after); }, ServerUncoreCounterState::maxCXLPorts, "CXLDP");
17201722
});
17211723
}
1724+
else if ((pmu_type = m->strToUncorePMUID(type)) != PCM::INVALID_PMU_ID)
1725+
{
1726+
choose(outputType,
1727+
[&]() { printUncoreRows(nullptr, (uint32) m->getMaxNumOfUncorePMUs(pmu_type), type); },
1728+
[&]() { printUncoreRows(nullptr, (uint32) m->getMaxNumOfUncorePMUs(pmu_type), type); },
1729+
[&]() { printUncoreRows([](const uint32 u, const uint32 i, const ServerUncoreCounterState& before, const ServerUncoreCounterState& after) { return getUncoreCounter(pmu_type, u, i, before, after); }, (uint32)m->getMaxNumOfUncorePMUs(pmu_type), type);
1730+
});
1731+
}
17221732
else
17231733
{
17241734
std::cerr << "ERROR: unrecognized PMU type \"" << type << "\"\n";
@@ -2150,6 +2160,24 @@ void print(const PCM::RawPMUConfigs& curPMUConfigs,
21502160
}
21512161
}
21522162
}
2163+
else if ((pmu_type = m->strToUncorePMUID(type)) != PCM::INVALID_PMU_ID)
2164+
{
2165+
for (uint32 s = 0; s < m->getNumSockets(); ++s)
2166+
{
2167+
for (uint32 unit = 0; unit < m->getMaxNumOfUncorePMUs(pmu_type); ++unit)
2168+
{
2169+
int i = 0;
2170+
for (auto& event : events)
2171+
{
2172+
choose(outputType,
2173+
[s, unit, &type]() { cout << "SKT" << s << type << unit << separator; },
2174+
[&event, &i, &type]() { if (event.second.empty()) cout << type << "Event" << i << separator; else cout << event.second << separator; },
2175+
[&]() { cout << getUncoreCounter(pmu_type, unit, i, BeforeUncoreState[s], AfterUncoreState[s]) << separator; });
2176+
++i;
2177+
}
2178+
}
2179+
}
2180+
}
21532181
else
21542182
{
21552183
std::cerr << "ERROR: unrecognized PMU type \"" << type << "\"\n";

0 commit comments

Comments
 (0)