Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push 2024 12 03 #886

Merged
merged 4 commits into from
Dec 4, 2024
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
2 changes: 1 addition & 1 deletion perfmon
Submodule perfmon updated 97 files
+3 −3 .github/workflows/bandit.yml
+2 −2 .github/workflows/create-perf-json.yml
+2 −2 .github/workflows/scorecard.yml
+2 −2 .github/workflows/verify-mapfile.yml
+55 −314 ADL/events/alderlake_goldencove_core.json
+1,201 −239 ADL/events/alderlake_gracemont_core.json
+3 −3 ADL/events/alderlake_uncore.json
+3 −3 ADL/events/alderlake_uncore_experimental.json
+7,001 −8,053 ADL/metrics/alderlake_metrics_goldencove_core.json
+1,806 −0 ADL/metrics/perf/alderlake_metrics_goldencove_core_perf.json
+489 −129 ARL/events/arrowlake_crestmont_core.json
+865 −336 ARL/events/arrowlake_lioncove_core.json
+1,627 −501 ARL/events/arrowlake_skymont_core.json
+3 −3 ARL/events/arrowlake_uncore.json
+10,812 −0 ARL/metrics/arrowlake_metrics_lioncove_core.json
+1,756 −0 ARL/metrics/perf/arrowlake_metrics_lioncove_core_perf.json
+478 −294 BDW/metrics/broadwell_metrics.json
+262 −171 BDW/metrics/perf/broadwell_metrics_perf.json
+398 −208 BDX/metrics/broadwellx_metrics.json
+315 −215 BDX/metrics/perf/broadwellx_metrics_perf.json
+3 −3 CLX/events/cascadelakex_core.json
+3 −3 CLX/events/cascadelakex_fp_arith_inst.json
+3 −288 CLX/events/cascadelakex_uncore.json
+3 −3,137 CLX/events/cascadelakex_uncore_experimental.json
+5,767 −5,057 CLX/metrics/cascadelakex_metrics.json
+607 −409 CLX/metrics/perf/cascadelakex_metrics_perf.json
+5 −394 EMR/events/emeraldrapids_core.json
+3 −3 EMR/events/emeraldrapids_uncore.json
+3 −3 EMR/events/emeraldrapids_uncore_experimental.json
+6,047 −4,831 EMR/metrics/emeraldrapids_metrics.json
+724 −484 EMR/metrics/perf/emeraldrapids_metrics_perf.json
+80 −378 GNR/events/graniterapids_core.json
+11 −11 GNR/events/graniterapids_uncore.json
+111 −3 GNR/events/graniterapids_uncore_experimental.json
+14,024 −70 GNR/metrics/graniterapids_metrics.json
+2,083 −59 GNR/metrics/perf/graniterapids_metrics_perf.json
+3 −161 GRR/events/grandridge_core.json
+6 −6 GRR/events/grandridge_uncore.json
+111 −3 GRR/events/grandridge_uncore_experimental.json
+465 −1,469 HSW/metrics/haswell_metrics.json
+223 −153 HSW/metrics/perf/haswell_metrics_perf.json
+340 −182 HSX/metrics/haswellx_metrics.json
+264 −181 HSX/metrics/perf/haswellx_metrics_perf.json
+442 −346 ICL/events/icelake_core.json
+5 −5 ICL/events/icelake_uncore.json
+0 −102 ICL/events/icelake_uncore_experimental.json
+6,043 −4,655 ICL/metrics/icelake_metrics.json
+712 −421 ICL/metrics/perf/icelake_metrics_perf.json
+416 −368 ICX/events/icelakex_core.json
+3 −3 ICX/events/icelakex_uncore.json
+3 −3 ICX/events/icelakex_uncore_experimental.json
+5,824 −4,729 ICX/metrics/icelakex_metrics.json
+708 −431 ICX/metrics/perf/icelakex_metrics_perf.json
+892 −338 LNL/events/lunarlake_lioncove_core.json
+309 −303 LNL/events/lunarlake_skymont_core.json
+3 −3 LNL/events/lunarlake_uncore.json
+11,911 −0 LNL/metrics/lunarlake_metrics_lioncove_core.json
+1,805 −0 LNL/metrics/perf/lunarlake_metrics_lioncove_core_perf.json
+12,965 −0 MTL/metrics/meteorlake_metrics_redwoodcove_core.json
+1,880 −0 MTL/metrics/perf/meteorlake_metrics_redwoodcove_core_perf.json
+442 −346 RKL/events/rocketlake_core.json
+5 −5 RKL/events/rocketlake_uncore.json
+3 −16 RKL/events/rocketlake_uncore_experimental.json
+712 −421 RKL/metrics/perf/rocketlake_metrics_perf.json
+6,044 −4,655 RKL/metrics/rocketlake_metrics.json
+516 −309 SKL/metrics/perf/skylake_metrics_perf.json
+5,384 −4,393 SKL/metrics/skylake_metrics.json
+3 −3 SKX/events/skylakex_core.json
+3 −3 SKX/events/skylakex_fp_arith_inst.json
+3 −272 SKX/events/skylakex_uncore.json
+3 −3,042 SKX/events/skylakex_uncore_experimental.json
+600 −377 SKX/metrics/perf/skylakex_metrics_perf.json
+5,390 −4,385 SKX/metrics/skylakex_metrics.json
+5 −401 SPR/events/sapphirerapids_core.json
+3 −3 SPR/events/sapphirerapids_uncore.json
+3 −3 SPR/events/sapphirerapids_uncore_experimental.json
+0 −2,051 SPR/metrics/perf/sapphirerapids-hbmonly_metrics_perf.json
+755 −464 SPR/metrics/perf/sapphirerapids_metrics_perf.json
+765 −473 SPR/metrics/perf/sapphirerapidshbm_metrics_perf.json
+6,355 −5,220 SPR/metrics/sapphirerapids_metrics.json
+5,994 −4,725 SPR/metrics/sapphirerapidshbm_metrics.json
+53 −161 SRF/events/sierraforest_core.json
+52 −16 SRF/events/sierraforest_uncore.json
+111 −39 SRF/events/sierraforest_uncore_experimental.json
+1 −1 SRF/metrics/sierraforest_metrics.json
+389 −269 TGL/events/tigerlake_core.json
+9 −9 TGL/events/tigerlake_uncore.json
+3 −3 TGL/events/tigerlake_uncore_experimental.json
+1,750 −0 TGL/metrics/perf/tigerlake_metrics_perf.json
+12,352 −0 TGL/metrics/tigerlake_metrics.json
+106 −104 mapfile.csv
+1 −1 scripts/ci/verify_mapfile/verify_mapfile.py
+236 −0 scripts/config/platform_config.json
+7 −3 scripts/config/replacements_config.json
+326 −309 scripts/create_perf_json.py
+11 −7 scripts/metric.py
+194 −51 scripts/perf_format_converter.py
11 changes: 11 additions & 0 deletions src/cpucounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,12 @@ void PCM::initEnergyMonitoring()
pp_energy_status.push_back(std::make_shared<CounterWidthExtender>(
new CounterWidthExtender::MsrHandleCounter(MSR[socketRefCore[0]], MSR_PP1_ENERGY_STATUS), 32, 10000));
}

if (systemEnergyMetricAvailable() && MSR.size() && (system_energy_status.get() == nullptr))
{
system_energy_status = std::make_shared<CounterWidthExtender>(
new CounterWidthExtender::MsrHandleCounter(MSR[socketRefCore[0]], MSR_SYS_ENERGY_STATUS, 0x00000000FFFFFFFF), 32, 10000);
}
}

static const uint32 UBOX0_DEV_IDS[] = {
Expand Down Expand Up @@ -6964,6 +6970,11 @@ void PCM::getAllCounterStates(SystemCounterState & systemState, std::vector<Sock
// aggregate socket uncore iMC, energy and package C state counters into system
systemState += socketStates[s];
}

if (systemEnergyMetricAvailable() && system_energy_status.get() != nullptr)
{
systemState.systemEnergyStatus = system_energy_status->read();
}
}

void PCM::getUncoreCounterStates(SystemCounterState & systemState, std::vector<SocketCounterState> & socketStates)
Expand Down
71 changes: 70 additions & 1 deletion src/cpucounters.h
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,7 @@ class PCM_API PCM
std::vector<std::shared_ptr<CounterWidthExtender> > energy_status;
std::vector<std::shared_ptr<CounterWidthExtender> > dram_energy_status;
std::vector<std::shared_ptr<CounterWidthExtender> > pp_energy_status;
std::shared_ptr<CounterWidthExtender> system_energy_status;
std::vector<std::vector<std::pair<UncorePMU, UncorePMU>>> cxlPMUs; // socket X CXL ports X UNIT {0,1}

std::vector<std::shared_ptr<CounterWidthExtender> > memory_bw_local;
Expand Down Expand Up @@ -2510,6 +2511,25 @@ class PCM_API PCM
);
}

bool systemEnergyMetricAvailable() const
{
return (
useSKLPath()
|| cpu_family_model == PCM::SKX
|| cpu_family_model == PCM::ICX
|| cpu_family_model == PCM::ADL
|| cpu_family_model == PCM::RPL
|| cpu_family_model == PCM::MTL
|| cpu_family_model == PCM::LNL
|| cpu_family_model == PCM::ARL
|| cpu_family_model == PCM::SPR
|| cpu_family_model == PCM::EMR
|| cpu_family_model == PCM::GNR
|| cpu_family_model == PCM::SRF
|| cpu_family_model == PCM::GRR
);
}

bool packageThermalMetricsAvailable() const
{
return packageEnergyMetricsAvailable();
Expand Down Expand Up @@ -3368,6 +3388,25 @@ uint64 getConsumedEnergy(const int powerPlane, const CounterStateType& before, c
return after.PPEnergyStatus[powerPlane] - before.PPEnergyStatus[powerPlane];
}

/*! \brief Returns energy consumed by system
\param before CPU counter state before the experiment
\param after CPU counter state after the experiment
*/
template <class CounterStateType>
uint64 getSystemConsumedEnergy(const CounterStateType& before, const CounterStateType& after)
{
return after.systemEnergyStatus - before.systemEnergyStatus;
}

/*! \brief Checks is systemEnergyStatusValid is valid in the state
* \param s CPU counter state
*/
template <class CounterStateType>
bool systemEnergyStatusValid(const CounterStateType& s)
{
return s.systemEnergyStatus != 0;
}

/*! \brief Returns energy consumed by DRAM (measured in internal units)
\param before CPU counter state before the experiment
\param after CPU counter state after the experiment
Expand Down Expand Up @@ -3435,6 +3474,31 @@ double getConsumedJoules(const int powerPlane, const CounterStateType& before, c
return double(getConsumedEnergy(powerPlane, before, after)) * m->getJoulesPerEnergyUnit();
}

/*! \brief Returns Joules consumed by system
\param before CPU counter state before the experiment
\param after CPU counter state after the experiment
*/
template <class CounterStateType>
double getSystemConsumedJoules(const CounterStateType& before, const CounterStateType& after)
{
PCM* m = PCM::getInstance();
if (!m) return -1.;

auto unit = m->getJoulesPerEnergyUnit();

switch (m->getCPUFamilyModel())
{
case PCM::SPR:
case PCM::EMR:
case PCM::GNR:
case PCM::SRF:
unit = 1.0;
break;
}

return double(getSystemConsumedEnergy(before, after)) * unit;
}

/*! \brief Returns Joules consumed by DRAM
\param before CPU counter state before the experiment
\param after CPU counter state after the experiment
Expand Down Expand Up @@ -3860,11 +3924,14 @@ class SystemCounterState : public SocketCounterState
friend std::vector<uint64> getPCICFGEvent(const PCM::RawEventEncoding& eventEnc, const SystemCounterState& before, const SystemCounterState& after);
friend std::vector<uint64> getMMIOEvent(const PCM::RawEventEncoding& eventEnc, const SystemCounterState& before, const SystemCounterState& after);
friend std::vector<uint64> getPMTEvent(const PCM::RawEventEncoding& eventEnc, const SystemCounterState& before, const SystemCounterState& after);
template <class CounterStateType> friend bool systemEnergyStatusValid(const CounterStateType& s);
template <class CounterStateType> friend uint64 getSystemConsumedEnergy(const CounterStateType& before, const CounterStateType& after);

std::vector<std::vector<uint64> > incomingQPIPackets; // each 64 byte
std::vector<std::vector<uint64> > outgoingQPIFlits; // idle or data/non-data flits depending on the architecture
std::vector<std::vector<uint64> > TxL0Cycles;
uint64 uncoreTSC;
uint64 systemEnergyStatus;
std::unordered_map<PCM::RawEventEncoding, std::vector<uint64> , PCM::PCICFGRegisterEncodingHash, PCM::PCICFGRegisterEncodingCmp> PCICFGValues{};
std::unordered_map<PCM::RawEventEncoding, std::vector<uint64>, PCM::MMIORegisterEncodingHash, PCM::MMIORegisterEncodingCmp> MMIOValues{};
std::unordered_map<PCM::RawEventEncoding, std::vector<uint64>, PCM::PMTRegisterEncodingHash2> PMTValues{};
Expand All @@ -3890,7 +3957,8 @@ class SystemCounterState : public SocketCounterState
friend uint64 getOutgoingQPILinkBytes(uint32 socketNr, uint32 linkNr, const SystemCounterState & now);

SystemCounterState() :
uncoreTSC(0)
uncoreTSC(0),
systemEnergyStatus(0)
{
PCM * m = PCM::getInstance();
accel_counters.resize(m->getNumberofAccelCounters());
Expand Down Expand Up @@ -3922,6 +3990,7 @@ class SystemCounterState : public SocketCounterState

return *this;
}

virtual ~ SystemCounterState() {}
};

Expand Down
26 changes: 19 additions & 7 deletions src/pcm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,19 +334,25 @@ void print_output(PCM * m,

cout << setNextColor() << " N/A\n";
cout << resetColor();
cout << setNextColor() <<"\n Instructions retired: " << unit_format(getInstructionsRetired(sstate1, sstate2)) << " ;"
<< setNextColor() <<" Active cycles: " << unit_format(getCycles(sstate1, sstate2)) << " ;"
<< setNextColor() <<" Time (TSC): " << unit_format(getInvariantTSC(cstates1[0], cstates2[0])) << "ticks ;"
<< setNextColor() << " C0 (active,non-halted) core residency: " << (getCoreCStateResidency(0, sstate1, sstate2)*100.) << " %\n";
cout << "\n";
cout << setNextColor() << "\n Instructions retired: " << unit_format(getInstructionsRetired(sstate1, sstate2)) << " ;"
<< setNextColor() << " Active cycles: " << unit_format(getCycles(sstate1, sstate2)) << " ;"
<< setNextColor() << " Time (TSC): " << unit_format(getInvariantTSC(cstates1[0], cstates2[0])) << "ticks;";
if (m->systemEnergyMetricAvailable() && systemEnergyStatusValid(sstate1) && systemEnergyStatusValid(sstate2))
{
cout << setNextColor() << " SYS energy: " << getSystemConsumedJoules(sstate1, sstate2) << " J;";
}
cout << "\n\n";

cout << resetColor() << setNextColor() << " Core C-state residencies: "<< setNextColor() << "C0 (active,non-halted): " << (getCoreCStateResidency(0, sstate1, sstate2)*100.) << " %;";
for (int s = 1; s <= PCM::MAX_C_STATE; ++s)
{
if (m->isCoreCStateResidencySupported(s))
{
std::cout << setNextColor() << " C" << s << " core residency: " << (getCoreCStateResidency(s, sstate1, sstate2)*100.) << " %;";
std::cout << setNextColor() << " C" << s << ": " << (getCoreCStateResidency(s, sstate1, sstate2)*100.) << " %;";
}
}
cout << "\n" ;
cout << resetColor() << setNextColor() << " Package C-state residencies: ";
std::vector<StackedBarItem> CoreCStateStackedBar, PackageCStateStackedBar;
for (int s = 0; s <= PCM::MAX_C_STATE; ++s)
{
Expand All @@ -359,7 +365,7 @@ void print_output(PCM * m,
}
if (m->isPackageCStateResidencySupported(s))
{
std::cout << setNextColor() << " C" << s << " package residency: " << (getPackageCStateResidency(s, sstate1, sstate2)*100.) << " %;";
std::cout << setNextColor() << " C" << s << ": " << (getPackageCStateResidency(s, sstate1, sstate2)*100.) << " %;";
PackageCStateStackedBar.push_back(StackedBarItem(getPackageCStateResidency(s, sstate1, sstate2), "", fill));
}
}
Expand Down Expand Up @@ -760,6 +766,8 @@ void print_csv_header(PCM * m,
print_csv_header_helper(header, 2);
if (m->dramEnergyMetricsAvailable())
print_csv_header_helper(header);
if (m->systemEnergyMetricAvailable())
print_csv_header_helper(header);
if (m->LLCReadMissLatencyMetricsAvailable())
print_csv_header_helper(header);
if (m->uncoreFrequencyMetricAvailable())
Expand Down Expand Up @@ -940,6 +948,8 @@ void print_csv_header(PCM * m,
}
if (m->dramEnergyMetricsAvailable())
cout << "DRAM Energy (Joules),";
if (m->systemEnergyMetricAvailable())
cout << "SYSTEM Energy (Joules),";
if (m->LLCReadMissLatencyMetricsAvailable())
cout << "LLCRDMISSLAT (ns),";
if (m->uncoreFrequencyMetricAvailable())
Expand Down Expand Up @@ -1194,6 +1204,8 @@ void print_csv(PCM * m,
cout << getConsumedJoules(0, sstate1, sstate2) << "," << getConsumedJoules(1, sstate1, sstate2) << ",";
if (m->dramEnergyMetricsAvailable())
cout << getDRAMConsumedJoules(sstate1, sstate2) << ",";
if (m->systemEnergyMetricAvailable())
cout << getSystemConsumedJoules(sstate1, sstate2) << ",";
if (m->LLCReadMissLatencyMetricsAvailable())
cout << getLLCReadMissLatency(sstate1, sstate2) << ",";
if (m->uncoreFrequencyMetricAvailable())
Expand Down
1 change: 1 addition & 0 deletions src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ constexpr auto MSR_SMI_COUNT = 0x34;
*/

constexpr auto MSR_PKG_ENERGY_STATUS = 0x611;
constexpr auto MSR_SYS_ENERGY_STATUS = 0x64D;
constexpr auto MSR_RAPL_POWER_UNIT = 0x606;
constexpr auto MSR_PKG_POWER_INFO = 0x614;

Expand Down
12 changes: 10 additions & 2 deletions src/width_extender.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,20 @@ class CounterWidthExtender
{
std::shared_ptr<SafeMsrHandle> msr;
uint64 msr_addr;
MsrHandleCounter(std::shared_ptr<SafeMsrHandle> msr_, uint64 msr_addr_) : msr(msr_), msr_addr(msr_addr_) { }
uint64 msr_mask;
MsrHandleCounter( std::shared_ptr<SafeMsrHandle> msr_,
const uint64 msr_addr_,
const uint64 msr_mask_ = ~uint64(0ULL)) :
msr(msr_),
msr_addr(msr_addr_),
msr_mask(msr_mask_)
{
}
uint64 operator () ()
{
uint64 value = 0;
msr->read(msr_addr, &value);
return value;
return value & msr_mask;
}
};

Expand Down
Loading