Skip to content

Commit e51bae8

Browse files
committed
use UPI_SPEED_REGISTER on SPR
Change-Id: Idf650056f7d6968c50121ad275681b5d862646c5
1 parent 3d6926c commit e51bae8

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/cpucounters.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9053,6 +9053,37 @@ uint64 ServerUncorePMUs::computeQPISpeed(const uint32 core_nr, const int cpumode
90539053
value &= 7; // extract lower 3 bits
90549054
if(value) result = static_cast<uint64>((4000000000ULL + ((uint64)value)*800000000ULL)*2ULL);
90559055
}
9056+
std::unordered_map<uint32, size_t> UPISpeedMap{};
9057+
std::pair<uint32, uint32> regBits{};
9058+
switch (cpumodel)
9059+
{
9060+
case PCM::SPR:
9061+
UPISpeedMap = {
9062+
{0, 2500},
9063+
{1, 12800},
9064+
{2, 14400},
9065+
{3, 16000},
9066+
{4, 20000}
9067+
};
9068+
regBits = std::make_pair(0, 2);
9069+
break;
9070+
}
9071+
if (UPISpeedMap.empty() == false && i < XPIRegisterLocation.size())
9072+
{
9073+
const auto UPI_SPEED_REGISTER_FUNC_ADDR = 2;
9074+
const auto UPI_SPEED_REGISTER_OFFSET = 0x2e0;
9075+
PciHandleType reg(groupnr, UPIbus, XPIRegisterLocation[i].first, UPI_SPEED_REGISTER_FUNC_ADDR);
9076+
uint32 value = 0;
9077+
if (reg.read32(UPI_SPEED_REGISTER_OFFSET, &value) == sizeof(uint32))
9078+
{
9079+
const size_t speedMT = UPISpeedMap[extract_bits_ui(value, regBits.first, regBits.second)];
9080+
if (false)
9081+
{
9082+
std::cerr << "speedMT: " << speedMT << "\n";
9083+
}
9084+
result = speedMT * 1000000ULL * pcm->getBytesPerLinkTransfer();
9085+
}
9086+
}
90569087
if(result == 0ULL)
90579088
{
90589089
if (PCM::hasUPI(cpumodel) == false)

0 commit comments

Comments
 (0)