Skip to content

Commit c09cb5a

Browse files
committed
Merge remote-tracking branch 'opcm-github/master'
Change-Id: I484a305c7a3b2528bfee44b241018ef934ebd393
2 parents 56b79de + 4661471 commit c09cb5a

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

doc/PCM_IIO_README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Inbound (PCIe device DMA into system) metrics:
1111

1212
Outbound (CPU MMIO to the PCIe device) metrics:
1313

14-
* OB read (outbound write): the number of bytes per second that the CPU requested to write to the PCIe device through MMIO (Memory-mapped I/O)
15-
* OB write (outbound read): the number of bytes per second that the CPU requested to read from the PCIe device through MMIO
14+
* OB read (outbound read): the number of bytes per second that the CPU requested to read from the PCIe device through MMIO (memory-mapped I/O)
15+
* OB write (outbound write): the number of bytes per second that the CPU requested to write to the PCIe device through MMIO (memory-mapped I/O)
1616

1717
IOMMU metrics:
1818

src/cpucounters.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ bool PCM::isHWTMAL1Supported() const
359359
void PCM::readCPUMicrocodeLevel()
360360
{
361361
if (MSR.empty()) return;
362-
const int ref_core = 0;
362+
const int32 ref_core = socketRefCore[0];
363363
TemporalThreadAffinity affinity(ref_core);
364364
if (affinity.supported() && isCoreOnline(ref_core))
365365
{ // see "Update Signature and Verification" and "Determining the Signature"
@@ -1110,7 +1110,22 @@ bool PCM::discoverSystemTopology()
11101110
};
11111111
std::unordered_map<int, domain> topologyDomainMap;
11121112
{
1113-
TemporalThreadAffinity aff0(0);
1113+
const int32 maxTopoDomainAff = 1<<16;
1114+
int32 topoDomainAff = -1;
1115+
1116+
for (int32 core = 0; core < maxTopoDomainAff; ++core)
1117+
{
1118+
try {
1119+
TemporalThreadAffinity _(core);
1120+
topoDomainAff = core;
1121+
}
1122+
catch (...)
1123+
{
1124+
}
1125+
if (topoDomainAff != -1) break;
1126+
}
1127+
1128+
TemporalThreadAffinity _(topoDomainAff);
11141129

11151130
if (initCoreMasks(smtMaskWidth, coreMaskWidth, l2CacheMaskShift, l3CacheMaskShift) == false)
11161131
{
@@ -4637,7 +4652,7 @@ uint64 RDTSC();
46374652

46384653
void PCM::computeNominalFrequency()
46394654
{
4640-
const int ref_core = 0;
4655+
const int32 ref_core = socketRefCore[0];
46414656
const uint64 before = getInvariantTSC_Fast(ref_core);
46424657
MySleepMs(100);
46434658
const uint64 after = getInvariantTSC_Fast(ref_core);
@@ -4809,11 +4824,11 @@ void PCM::computeQPISpeedBeckton(int core_nr)
48094824
MSR[core_nr]->read(R_MSR_PMON_CTR0, &startFlits);
48104825

48114826
const uint64 timerGranularity = 1000000ULL; // mks
4812-
uint64 startTSC = getTickCount(timerGranularity, (uint32) core_nr);
4827+
uint64 startTSC = getTickCount(timerGranularity, core_nr);
48134828
uint64 endTSC;
48144829
do
48154830
{
4816-
endTSC = getTickCount(timerGranularity, (uint32) core_nr);
4831+
endTSC = getTickCount(timerGranularity, core_nr);
48174832
} while (endTSC - startTSC < 200000ULL); // spin for 200 ms
48184833

48194834
uint64 endFlits = 0;
@@ -5401,8 +5416,9 @@ int convertUnknownToInt(size_t size, char* value)
54015416
#endif
54025417

54035418

5404-
uint64 PCM::getTickCount(uint64 multiplier, uint32 core)
5419+
uint64 PCM::getTickCount(uint64 multiplier, int32 core)
54055420
{
5421+
if (core == -1) core = socketRefCore[0];
54065422
return (multiplier * getInvariantTSC_Fast(core)) / getNominalFrequency();
54075423
}
54085424

src/cpucounters.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,9 +2304,9 @@ class PCM_API PCM
23042304
}
23052305
//! \brief Return TSC timer value in time units
23062306
//! \param multiplier use 1 for seconds, 1000 for ms, 1000000 for mks, etc (default is 1000: ms)
2307-
//! \param core core to read on-chip TSC value (default is 0)
2307+
//! \param core core to read on-chip TSC value (default is -1: socketRefCore[0])
23082308
//! \return time counter value
2309-
uint64 getTickCount(uint64 multiplier = 1000 /* ms */, uint32 core = 0);
2309+
uint64 getTickCount(uint64 multiplier = 1000 /* ms */, int32 core = -1);
23102310

23112311
uint64 getInvariantTSC_Fast(uint32 core = 0);
23122312

0 commit comments

Comments
 (0)