Skip to content

Commit

Permalink
Merge pull request #663 from intel/push-2024-01-25
Browse files Browse the repository at this point in the history
push 2024 01 25
  • Loading branch information
rdementi authored Jan 25, 2024
2 parents 1c77ba8 + a6e24d9 commit 2612158
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 15 deletions.
17 changes: 11 additions & 6 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 Expand Up @@ -6564,9 +6574,7 @@ ServerUncoreCounterState PCM::getServerUncoreCounterState(uint32 socket)
uint32 refCore = socketRefCore[socket];
TemporalThreadAffinity tempThreadAffinity(refCore);

readUncoreCounterValues(result, socket, CBO_PMU_ID);

readUncoreCounterValues(result, socket, MDF_PMU_ID);
readUncoreCounterValues(result, socket);

for (uint32 stack = 0; socket < iioPMUs.size() && stack < iioPMUs[socket].size() && stack < ServerUncoreCounterState::maxIIOStacks; ++stack)
{
Expand All @@ -6586,11 +6594,8 @@ ServerUncoreCounterState PCM::getServerUncoreCounterState(uint32 socket)
}
}

readUncoreCounterValues(result, socket, UBOX_PMU_ID);
result.UncClocks = getUncoreClocks(socket);

readUncoreCounterValues(result, socket, PCU_PMU_ID);

for (size_t p = 0; p < getNumCXLPorts(socket); ++p)
{
for (int i = 0; i < ServerUncoreCounterState::maxCounters && socket < cxlPMUs.size() && size_t(i) < cxlPMUs[socket][p].first.size(); ++i)
Expand Down
15 changes: 12 additions & 3 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 Expand Up @@ -714,7 +723,7 @@ class PCM_API PCM
}

template <class T>
void readUncoreCounterValues(T& result, const size_t socket, const int pmu_id) const
void readUncoreCounterValues(T& result, const size_t socket) const
{
if (socket < uncorePMUs.size())
{
Expand All @@ -723,9 +732,9 @@ class PCM_API PCM
{
TemporalThreadAffinity tempThreadAffinity(socketRefCore[socket]); // speedup trick for Linux

const auto& pmuIter = uncorePMUs[socket][die].find(pmu_id);
if (pmuIter != uncorePMUs[socket][die].end())
for (auto pmuIter = uncorePMUs[socket][die].begin(); pmuIter != uncorePMUs[socket][die].end(); ++pmuIter)
{
const auto & pmu_id = pmuIter->first;
result.Counters[die][pmu_id].resize(pmuIter->second.size());
for (size_t unit = 0; unit < pmuIter->second.size(); ++unit)
{
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
44 changes: 38 additions & 6 deletions src/uncore_pmu_discovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,37 @@ class UncorePMUDiscovery
}
return "unknown";
};
union PCICFGAddress
{
uint64 raw;
struct {
uint64 offset:12;
uint64 function:3;
uint64 device:5;
uint64 bus:8;
} fields;
std::string getStr() const
{
std::ostringstream out(std::ostringstream::out);
out << std::hex << fields.bus << ":" << fields.device << "." << fields.function << "@" << fields.offset;
out << std::dec;
return out.str();
}
};
static void printHelper(const accessTypeEnum accessType, const uint64 addr)
{
if (accessType == PCICFG)
{
PCICFGAddress Addr;
Addr.raw = addr;
std::cout << " (" << Addr.getStr() << ")";
}
else
{
std::cout << " (-)";
}
std::cout << " with access type " << std::dec << accessTypeStr(accessType);
}
protected:
struct GlobalPMU
{
Expand All @@ -53,9 +84,9 @@ class UncorePMUDiscovery
{
std::cout << "global PMU " <<
" of type " << std::dec << type <<
" globalCtrl: 0x" << std::hex << globalCtrlAddr <<
" with access type " << std::dec << accessTypeStr(accessType) <<
" stride: " << std::dec << stride
" globalCtrl: 0x" << std::hex << globalCtrlAddr;
UncorePMUDiscovery::printHelper((accessTypeEnum)accessType, globalCtrlAddr);
std::cout << " stride: " << std::dec << stride
<< "\n";
}
};
Expand All @@ -77,9 +108,10 @@ class UncorePMUDiscovery
std::cout << "unit PMU " <<
" of type " << std::dec << boxType <<
" ID " << boxID <<
" box ctrl: 0x" << std::hex << boxCtrlAddr <<
" width " << std::dec << bitWidth <<
" with access type " << accessTypeStr(accessType) <<
" box ctrl: 0x" << std::hex << boxCtrlAddr;
UncorePMUDiscovery::printHelper((accessTypeEnum)accessType, boxCtrlAddr);
std::cout <<
" width " << bitWidth <<
" numRegs " << numRegs <<
" ctrlOffset " << ctrlOffset <<
" ctrOffset " << ctrOffset <<
Expand Down

0 comments on commit 2612158

Please sign in to comment.