@@ -1926,22 +1926,15 @@ void PCM::initUncoreObjects()
19261926 initUncorePMUsDirect ();
19271927 }
19281928
1929- auto countPMUs = [&](const uint32 s, const int pmu_id)
1930- {
1931- size_t count = 0 ;
1932- forAllUncorePMUs (s, pmu_id, [&count](UncorePMU&) { ++count; });
1933- return count;
1934- };
1935-
1936- std::cerr << " Info: " << uboxPMUs.size () << " UBOX units detected.\n " ;
19371929 for (uint32 s = 0 ; s < (uint32)num_sockets; ++s)
19381930 {
19391931 std::cerr << " Socket " << s << " :" <<
1940- " " << countPMUs (s, PCU_PMU_ID ) << " PCU units detected."
1932+ " " << getMaxNumOfUncorePMUs (PCU_PMU_ID, s ) << " PCU units detected."
19411933 " " << ((s < iioPMUs.size ()) ? iioPMUs[s].size () : 0 ) << " IIO units detected."
19421934 " " << ((s < irpPMUs.size ()) ? irpPMUs[s].size () : 0 ) << " IRP units detected."
1943- " " << countPMUs (s, CBO_PMU_ID) << " CHA/CBO units detected."
1944- " " << countPMUs (s, MDF_PMU_ID) << " MDF units detected."
1935+ " " << getMaxNumOfUncorePMUs (CBO_PMU_ID, s) << " CHA/CBO units detected."
1936+ " " << getMaxNumOfUncorePMUs (MDF_PMU_ID, s) << " MDF units detected."
1937+ " " << getMaxNumOfUncorePMUs (UBOX_PMU_ID, s) << " UBOX units detected."
19451938 " " << ((s < cxlPMUs.size ()) ? cxlPMUs[s].size () : 0 ) << " CXL units detected."
19461939 " \n " ;
19471940 }
@@ -1996,53 +1989,62 @@ void PCM::initUncorePMUsDirect()
19961989
19971990 if (IVYTOWN == cpu_model || JAKETOWN == cpu_model)
19981991 {
1999- uboxPMUs.push_back (
2000- UncorePMU (
2001- std::shared_ptr<MSRRegister>(),
1992+ uncorePMUs[s].resize (1 );
1993+ std::vector<std::shared_ptr<HWRegister> > CounterControlRegs{
20021994 std::make_shared<MSRRegister>(handle, JKTIVT_UBOX_MSR_PMON_CTL0_ADDR),
2003- std::make_shared<MSRRegister>(handle, JKTIVT_UBOX_MSR_PMON_CTL1_ADDR),
2004- std::shared_ptr<MSRRegister>() ,
2005- std::shared_ptr<MSRRegister>(),
1995+ std::make_shared<MSRRegister>(handle, JKTIVT_UBOX_MSR_PMON_CTL1_ADDR)
1996+ } ,
1997+ CounterValueRegs{
20061998 std::make_shared<MSRRegister>(handle, JKTIVT_UBOX_MSR_PMON_CTR0_ADDR),
2007- std::make_shared<MSRRegister>(handle, JKTIVT_UBOX_MSR_PMON_CTR1_ADDR),
2008- std::shared_ptr<MSRRegister>(),
1999+ std::make_shared<MSRRegister>(handle, JKTIVT_UBOX_MSR_PMON_CTR1_ADDR)
2000+ };
2001+ uncorePMUs[s][0 ][UBOX_PMU_ID].push_back (
2002+ std::make_shared<UncorePMU>(
20092003 std::shared_ptr<MSRRegister>(),
2004+ CounterControlRegs,
2005+ CounterValueRegs,
20102006 std::make_shared<MSRRegister>(handle, JKTIVT_UCLK_FIXED_CTL_ADDR),
20112007 std::make_shared<MSRRegister>(handle, JKTIVT_UCLK_FIXED_CTR_ADDR)
20122008 )
20132009 );
20142010 }
20152011 else if (SPR == cpu_model)
20162012 {
2017- uboxPMUs.push_back (
2018- UncorePMU (
2019- std::make_shared<MSRRegister>(handle, SPR_UBOX_MSR_PMON_BOX_CTL_ADDR),
2013+ uncorePMUs[s].resize (1 );
2014+ std::vector<std::shared_ptr<HWRegister> > CounterControlRegs{
20202015 std::make_shared<MSRRegister>(handle, SPR_UBOX_MSR_PMON_CTL0_ADDR),
2021- std::make_shared<MSRRegister>(handle, SPR_UBOX_MSR_PMON_CTL1_ADDR),
2022- std::shared_ptr<MSRRegister>() ,
2023- std::shared_ptr<MSRRegister>(),
2016+ std::make_shared<MSRRegister>(handle, SPR_UBOX_MSR_PMON_CTL1_ADDR)
2017+ } ,
2018+ CounterValueRegs{
20242019 std::make_shared<MSRRegister>(handle, SPR_UBOX_MSR_PMON_CTR0_ADDR),
2025- std::make_shared<MSRRegister>(handle, SPR_UBOX_MSR_PMON_CTR1_ADDR),
2026- std::shared_ptr<MSRRegister>(),
2027- std::shared_ptr<MSRRegister>(),
2020+ std::make_shared<MSRRegister>(handle, SPR_UBOX_MSR_PMON_CTR1_ADDR)
2021+ };
2022+ uncorePMUs[s][0 ][UBOX_PMU_ID].push_back (
2023+ std::make_shared<UncorePMU>(
2024+ std::make_shared<MSRRegister>(handle, SPR_UBOX_MSR_PMON_BOX_CTL_ADDR),
2025+ CounterControlRegs,
2026+ CounterValueRegs,
20282027 std::make_shared<MSRRegister>(handle, SPR_UCLK_FIXED_CTL_ADDR),
20292028 std::make_shared<MSRRegister>(handle, SPR_UCLK_FIXED_CTR_ADDR)
20302029 )
20312030 );
20322031 }
20332032 else if (isServerCPU () && hasPCICFGUncore ())
20342033 {
2035- uboxPMUs.push_back (
2036- UncorePMU (
2037- std::shared_ptr<MSRRegister>(),
2034+ uncorePMUs[s].resize (1 );
2035+ std::vector<std::shared_ptr<HWRegister> > CounterControlRegs{
20382036 std::make_shared<MSRRegister>(handle, UBOX_MSR_PMON_CTL0_ADDR),
20392037 std::make_shared<MSRRegister>(handle, UBOX_MSR_PMON_CTL1_ADDR),
2040- std::shared_ptr<MSRRegister>() ,
2041- std::shared_ptr<MSRRegister>(),
2038+ } ,
2039+ CounterValueRegs{
20422040 std::make_shared<MSRRegister>(handle, UBOX_MSR_PMON_CTR0_ADDR),
20432041 std::make_shared<MSRRegister>(handle, UBOX_MSR_PMON_CTR1_ADDR),
2042+ };
2043+ uncorePMUs[s][0 ][UBOX_PMU_ID].push_back (
2044+ std::make_shared<UncorePMU>(
20442045 std::shared_ptr<MSRRegister>(),
2045- std::shared_ptr<MSRRegister>(),
2046+ CounterControlRegs,
2047+ CounterValueRegs,
20462048 std::make_shared<MSRRegister>(handle, UCLK_FIXED_CTL_ADDR),
20472049 std::make_shared<MSRRegister>(handle, UCLK_FIXED_CTR_ADDR)
20482050 )
@@ -2554,7 +2556,7 @@ void PCM::initUncorePMUsPerf()
25542556 {
25552557 uncorePMUs[s].resize (1 );
25562558 populatePerfPMUs (s, enumeratePerfPMUs (" pcu" , 100 ), uncorePMUs[s][0 ][PCU_PMU_ID], false , true );
2557- populatePerfPMUs (s, enumeratePerfPMUs (" ubox" , 100 ), uboxPMUs , true );
2559+ populatePerfPMUs (s, enumeratePerfPMUs (" ubox" , 100 ), uncorePMUs[s][ 0 ][UBOX_PMU_ID] , true );
25582560 populatePerfPMUs (s, enumeratePerfPMUs (" cbox" , 100 ), uncorePMUs[s][0 ][CBO_PMU_ID], false , true , true );
25592561 populatePerfPMUs (s, enumeratePerfPMUs (" cha" , 200 ), uncorePMUs[s][0 ][CBO_PMU_ID], false , true , true );
25602562 populatePerfPMUs (s, enumeratePerfPMUs (" mdf" , 200 ), uncorePMUs[s][0 ][MDF_PMU_ID], false , true , true );
@@ -6590,11 +6592,9 @@ ServerUncoreCounterState PCM::getServerUncoreCounterState(uint32 socket)
65906592 }
65916593 }
65926594 }
6593- for (int i = 0 ; i < 2 && socket < uboxPMUs.size (); ++i)
6594- {
6595- result.UBOXCounter [i] = *(uboxPMUs[socket].counterValue [i]);
6596- result.UncClocks = getUncoreClocks (socket);
6597- }
6595+
6596+ readUncoreCounterValues (result, socket, UBOX_PMU_ID);
6597+ result.UncClocks = getUncoreClocks (socket);
65986598
65996599 readUncoreCounterValues (result, socket, PCU_PMU_ID);
66006600
@@ -9347,19 +9347,17 @@ void PCM::programMDF(const uint64* events)
93479347
93489348void PCM::programUBOX (const uint64* events)
93499349{
9350- for ( size_t s = 0 ; (s < uboxPMUs. size ()) && MSR. size (); ++s )
9350+ programUncorePMUs (UBOX_PMU_ID, [&events](UncorePMU& pmu )
93519351 {
9352- uint32 refCore = socketRefCore[s];
9353- TemporalThreadAffinity tempThreadAffinity (refCore); // speedup trick for Linux
9354- uboxPMUs[s].initFreeze (UNC_PMON_UNIT_CTL_FRZ_EN);
9352+ pmu.initFreeze (UNC_PMON_UNIT_CTL_FRZ_EN);
93559353
9356- *uboxPMUs[s] .fixedCounterControl = UCLK_FIXED_CTL_EN;
9354+ *pmu .fixedCounterControl = UCLK_FIXED_CTL_EN;
93579355
93589356 if (events)
93599357 {
9360- PCM::program (uboxPMUs[s] , events, events + 2 , 0 );
9358+ PCM::program (pmu , events, events + 2 , 0 );
93619359 }
9362- }
9360+ });
93639361}
93649362
93659363void PCM::controlQATTelemetry (uint32 dev, uint32 operation)
@@ -9577,12 +9575,25 @@ uint64 PCM::getUncoreCounterState(const int pmu_id, const size_t socket, const u
95779575 return result;
95789576}
95799577
9580- uint64 PCM::getUncoreClocks (const uint32 socket_ )
9578+ uint64 PCM::getUncoreClocks (const uint32 socket_id )
95819579{
95829580 uint64 result = 0 ;
9583- if (socket_ < uboxPMUs .size ())
9581+ if (socket_id < uncorePMUs .size ())
95849582 {
9585- result = *uboxPMUs[socket_].fixedCounterValue ;
9583+ for (auto & d : uncorePMUs[socket_id])
9584+ {
9585+ const auto iter = d.find (UBOX_PMU_ID);
9586+ if (iter != d.end ())
9587+ {
9588+ for (auto & pmu : iter->second )
9589+ {
9590+ if (pmu.get ())
9591+ {
9592+ result += *pmu->fixedCounterValue ;
9593+ }
9594+ }
9595+ }
9596+ }
95869597 }
95879598 return result;
95889599}
0 commit comments