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
24 changes: 14 additions & 10 deletions src/pcm-raw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1877,10 +1877,11 @@ void printTransposed(const PCM::RawPMUConfigs& curPMUConfigs,
}
else if (type == "ubox")
{
const auto numPMUs = (uint32)m->getMaxNumOfUncorePMUs(PCM::UBOX_PMU_ID);
choose(outputType,
[&]() { printUncoreRows(nullptr, 1U, ""); },
[&]() { printUncoreRows(nullptr, 1U, type); },
[&]() { printUncoreRows([](const uint32, const uint32 i, const ServerUncoreCounterState& before, const ServerUncoreCounterState& after) { return getUncoreCounter(PCM::UBOX_PMU_ID, 0, i, before, after); }, 1U,
[&]() { printUncoreRows(nullptr, numPMUs, ""); },
[&]() { printUncoreRows(nullptr, numPMUs, type); },
[&]() { printUncoreRows([](const uint32 u, const uint32 i, const ServerUncoreCounterState& before, const ServerUncoreCounterState& after) { return getUncoreCounter(PCM::UBOX_PMU_ID, u, i, before, after); }, numPMUs,
"UncoreClocks", [](const uint32, const ServerUncoreCounterState& before, const ServerUncoreCounterState& after) { return getUncoreClocks(before, after); });
});
}
Expand Down Expand Up @@ -2260,14 +2261,17 @@ void print(const PCM::RawPMUConfigs& curPMUConfigs,
[&fixedEvents]() { cout << "UncoreClocks" << fixedEvents[0].second << separator; },
[&]() { cout << getUncoreClocks(BeforeUncoreState[s], AfterUncoreState[s]) << separator; });
}
int i = 0;
for (auto& event : events)
for (uint32 u = 0; u < m->getMaxNumOfUncorePMUs(PCM::UBOX_PMU_ID); ++u)
{
choose(outputType,
[s]() { cout << "SKT" << s << separator; },
[&event, &i]() { if (event.second.empty()) cout << "UBOXEvent" << i << separator; else cout << event.second << separator; },
[&]() { cout << getUncoreCounter(PCM::UBOX_PMU_ID, 0, i, BeforeUncoreState[s], AfterUncoreState[s]) << separator; });
++i;
int i = 0;
for (auto& event : events)
{
choose(outputType,
[s, u]() { cout << "SKT" << s << "U" << u << separator; },
[&event, &i]() { if (event.second.empty()) cout << "UBOXEvent" << i << separator; else cout << event.second << separator; },
[&]() { cout << getUncoreCounter(PCM::UBOX_PMU_ID, u, i, BeforeUncoreState[s], AfterUncoreState[s]) << separator; });
++i;
}
}
}
}
Expand Down
89 changes: 64 additions & 25 deletions src/uncore_pmu_discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,74 @@ UncorePMUDiscovery::UncorePMUDiscovery()
{
return;
}
auto processTables = [this](const uint64 bar, const VSEC &)
const auto debug = (safe_getenv("PCM_DEBUG_PMU_DISCOVERY") == std::string("1"));

auto processTables = [this, &debug](const uint64 bar, const VSEC & vsec)
{
constexpr size_t UncoreDiscoverySize = 3UL;
union UncoreGlobalDiscovery {
GlobalPMU pmu;
uint64 table[UncoreDiscoverySize];
};
UncoreGlobalDiscovery global;
mmio_memcpy(global.table, bar, UncoreDiscoverySize * sizeof(uint64), true);
globalPMUs.push_back(global.pmu);
union UncoreUnitDiscovery {
BoxPMU pmu;
uint64 table[UncoreDiscoverySize];
};
UncoreUnitDiscovery unit;
const auto step = global.pmu.stride * 8;
BoxPMUMap boxPMUMap;
for (size_t u = 0; u < global.pmu.maxUnits; ++u)
{
mmio_memcpy(unit.table, bar + (u+1) * step, UncoreDiscoverySize * sizeof(uint64), true);
if (unit.table[0] == 0 && unit.table[1] == 0)
try {
DBG(2, "Uncore discovery detection. Reading from bar 0x", std::hex, bar, std::dec);
constexpr size_t UncoreDiscoverySize = 3UL;
union UncoreGlobalDiscovery {
GlobalPMU pmu;
uint64 table[UncoreDiscoverySize];
};
UncoreGlobalDiscovery global;
mmio_memcpy(global.table, bar, UncoreDiscoverySize * sizeof(uint64), true);
globalPMUs.push_back(global.pmu);
if (debug)
{
// invalid entry
continue;
std::cerr << "Read global.pmu from 0x" << std::hex << bar << std::dec << "\n";
global.pmu.print();
std::cout.flush();
}
union UncoreUnitDiscovery {
BoxPMU pmu;
uint64 table[UncoreDiscoverySize];
};
UncoreUnitDiscovery unit;
const auto step = global.pmu.stride * 8;
BoxPMUMap boxPMUMap;
for (size_t u = 0; u < global.pmu.maxUnits; ++u)
{
mmio_memcpy(unit.table, bar + (u + 1) * step, UncoreDiscoverySize * sizeof(uint64), true);
if (debug)
{
std::cerr << "Read unit.pmu " << u << " from 0x" << std::hex << (bar + (u + 1) * step) << std::dec << "\n";
unit.pmu.print();
std::cout.flush();
}
if (unit.table[0] == 0 && unit.table[1] == 0)
{
if (debug)
{
std::cerr << "Invalid entry\n";
}
// invalid entry
continue;
}
// unit.pmu.print();
boxPMUMap[unit.pmu.boxType].push_back(unit.pmu);
}
// unit.pmu.print();
boxPMUMap[unit.pmu.boxType].push_back(unit.pmu);
boxPMUs.push_back(boxPMUMap);
}
catch (const std::exception & e)
{
std::cerr << "WARNING: enumeration of devices in UncorePMUDiscovery failed on bar 0x"
<< std::hex << bar << "\n" << e.what() << "\n" <<
" CAP_ID: 0x" << vsec.fields.cap_id << "\n" <<
" CAP_VERSION: 0x" << vsec.fields.cap_version << "\n" <<
" CAP_NEXT: 0x" << vsec.fields.cap_next << "\n" <<
" VSEC_ID: 0x" << vsec.fields.vsec_id << "\n" <<
" VSEC_VERSION: 0x" << vsec.fields.vsec_version << "\n" <<
" VSEC_LENGTH: 0x" << vsec.fields.vsec_length << "\n" <<
" ENTRY_ID: 0x" << vsec.fields.entryID << "\n" <<
" NUM_ENTRIES: 0x" << vsec.fields.NumEntries << "\n" <<
" ENTRY_SIZE: 0x" << vsec.fields.EntrySize << "\n" <<
" TBIR: 0x" << vsec.fields.tBIR << "\n" <<
" ADDRESS: 0x" << vsec.fields.Address <<
std::dec << "\n";
std::cerr << "INFO: discovery has " << boxPMUs.size() << " entries\n";
}
boxPMUs.push_back(boxPMUMap);
};
try {
processDVSEC([](const VSEC & vsec)
Expand Down
3 changes: 3 additions & 0 deletions src/uncore_pmu_discovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ class UncorePMUDiscovery
" globalCtrl: 0x" << std::hex << globalCtrlAddr;
UncorePMUDiscovery::printHelper((accessTypeEnum)accessType, globalCtrlAddr);
std::cout << " stride: " << std::dec << stride
<< " maxUnits: " << maxUnits
<< " statusOffset: " << statusOffset
<< " numStatus: " << numStatus
<< "\n";
}
};
Expand Down
Loading