Skip to content

Commit

Permalink
pcm-raw: add generic uncore PMU path
Browse files Browse the repository at this point in the history
  • Loading branch information
rdementi committed Jan 24, 2024
1 parent 304389d commit 5f90ef4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/cpucounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5721,6 +5721,16 @@ PCM::ErrorCode PCM::program(const RawPMUConfigs& curPMUConfigs_, const bool sile
{
programCXLDP(events64);
}
else if (strToUncorePMUID(type) != INVALID_PMU_ID)
{
const auto pmu_id = strToUncorePMUID(type);
programUncorePMUs(pmu_id, [&events64, &events, &pmu_id](UncorePMU& pmu)
{
uint64 * eventsIter = (uint64 *)events64;
pmu.initFreeze(UNC_PMON_UNIT_CTL_FRZ_EN);
PCM::program(pmu, eventsIter, eventsIter + (std::min)(events.programmable.size(), (size_t)ServerUncoreCounterState::maxCounters), UNC_PMON_UNIT_CTL_FRZ_EN);
});
}
else
{
std::cerr << "ERROR: unrecognized PMU type \"" << type << "\" when trying to program PMUs.\n";
Expand Down
9 changes: 9 additions & 0 deletions src/cpucounters.h
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,15 @@ class PCM_API PCM
UBOX_PMU_ID,
INVALID_PMU_ID
};
private:
std::unordered_map<std::string, int> strToUncorePMUID_ {
};
public:
UncorePMUIDs strToUncorePMUID(const std::string & type) const
{
const auto iter = strToUncorePMUID_.find(type);
return (iter == strToUncorePMUID_.end()) ? INVALID_PMU_ID : (UncorePMUIDs)iter->second;
}
private:
typedef std::unordered_map<int, UncorePMUArrayType> UncorePMUMapType;
// socket -> die -> pmu map -> pmu ref array
Expand Down
28 changes: 28 additions & 0 deletions src/pcm-raw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,8 @@ uint32 numTMAEvents(PCM* m)
return (m->isHWTMAL2Supported() ? 8 : 4);
}

uint32 pmu_type = PCM::INVALID_PMU_ID;

void printTransposed(const PCM::RawPMUConfigs& curPMUConfigs,
PCM* m,
SystemCounterState& SysBeforeState, SystemCounterState& SysAfterState,
Expand Down Expand Up @@ -1719,6 +1721,14 @@ void printTransposed(const PCM::RawPMUConfigs& curPMUConfigs,
[&]() { printUncoreRows([](const uint32 u, const uint32 i, const ServerUncoreCounterState& before, const ServerUncoreCounterState& after) { return getCXLDPCounter(u, i, before, after); }, ServerUncoreCounterState::maxCXLPorts, "CXLDP");
});
}
else if ((pmu_type = m->strToUncorePMUID(type)) != PCM::INVALID_PMU_ID)
{
choose(outputType,
[&]() { printUncoreRows(nullptr, (uint32) m->getMaxNumOfUncorePMUs(pmu_type), type); },
[&]() { printUncoreRows(nullptr, (uint32) m->getMaxNumOfUncorePMUs(pmu_type), type); },
[&]() { 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);
});
}
else
{
std::cerr << "ERROR: unrecognized PMU type \"" << type << "\"\n";
Expand Down Expand Up @@ -2150,6 +2160,24 @@ void print(const PCM::RawPMUConfigs& curPMUConfigs,
}
}
}
else if ((pmu_type = m->strToUncorePMUID(type)) != PCM::INVALID_PMU_ID)
{
for (uint32 s = 0; s < m->getNumSockets(); ++s)
{
for (uint32 unit = 0; unit < m->getMaxNumOfUncorePMUs(pmu_type); ++unit)
{
int i = 0;
for (auto& event : events)
{
choose(outputType,
[s, unit, &type]() { cout << "SKT" << s << type << unit << separator; },
[&event, &i, &type]() { if (event.second.empty()) cout << type << "Event" << i << separator; else cout << event.second << separator; },
[&]() { cout << getUncoreCounter(pmu_type, unit, i, BeforeUncoreState[s], AfterUncoreState[s]) << separator; });
++i;
}
}
}
}
else
{
std::cerr << "ERROR: unrecognized PMU type \"" << type << "\"\n";
Expand Down

0 comments on commit 5f90ef4

Please sign in to comment.