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
28 changes: 22 additions & 6 deletions src/cpucounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ bool PCM::isHWTMAL1Supported() const
void PCM::readCPUMicrocodeLevel()
{
if (MSR.empty()) return;
const int ref_core = 0;
const int32 ref_core = socketRefCore[0];
TemporalThreadAffinity affinity(ref_core);
if (affinity.supported() && isCoreOnline(ref_core))
{ // see "Update Signature and Verification" and "Determining the Signature"
Expand Down Expand Up @@ -1110,7 +1110,22 @@ bool PCM::discoverSystemTopology()
};
std::unordered_map<int, domain> topologyDomainMap;
{
TemporalThreadAffinity aff0(0);
Comment thread
144026 marked this conversation as resolved.
const int32 maxTopoDomainAff = 1<<16;
int32 topoDomainAff = -1;

for (int32 core = 0; core < maxTopoDomainAff; ++core)
{
try {
TemporalThreadAffinity _(core);
topoDomainAff = core;
}
catch (...)
{
}
if (topoDomainAff != -1) break;
}

TemporalThreadAffinity _(topoDomainAff);

if (initCoreMasks(smtMaskWidth, coreMaskWidth, l2CacheMaskShift, l3CacheMaskShift) == false)
{
Expand Down Expand Up @@ -4637,7 +4652,7 @@ uint64 RDTSC();

void PCM::computeNominalFrequency()
{
const int ref_core = 0;
const int32 ref_core = socketRefCore[0];
const uint64 before = getInvariantTSC_Fast(ref_core);
MySleepMs(100);
const uint64 after = getInvariantTSC_Fast(ref_core);
Expand Down Expand Up @@ -4809,11 +4824,11 @@ void PCM::computeQPISpeedBeckton(int core_nr)
MSR[core_nr]->read(R_MSR_PMON_CTR0, &startFlits);

const uint64 timerGranularity = 1000000ULL; // mks
uint64 startTSC = getTickCount(timerGranularity, (uint32) core_nr);
uint64 startTSC = getTickCount(timerGranularity, core_nr);
uint64 endTSC;
do
{
endTSC = getTickCount(timerGranularity, (uint32) core_nr);
endTSC = getTickCount(timerGranularity, core_nr);
} while (endTSC - startTSC < 200000ULL); // spin for 200 ms

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


uint64 PCM::getTickCount(uint64 multiplier, uint32 core)
uint64 PCM::getTickCount(uint64 multiplier, int32 core)
{
if (core == -1) core = socketRefCore[0];
return (multiplier * getInvariantTSC_Fast(core)) / getNominalFrequency();
}

Expand Down
4 changes: 2 additions & 2 deletions src/cpucounters.h
Original file line number Diff line number Diff line change
Expand Up @@ -2304,9 +2304,9 @@ class PCM_API PCM
}
//! \brief Return TSC timer value in time units
//! \param multiplier use 1 for seconds, 1000 for ms, 1000000 for mks, etc (default is 1000: ms)
//! \param core core to read on-chip TSC value (default is 0)
//! \param core core to read on-chip TSC value (default is -1: socketRefCore[0])
//! \return time counter value
uint64 getTickCount(uint64 multiplier = 1000 /* ms */, uint32 core = 0);
uint64 getTickCount(uint64 multiplier = 1000 /* ms */, int32 core = -1);

uint64 getInvariantTSC_Fast(uint32 core = 0);

Expand Down
Loading