Skip to content

Commit

Permalink
fix getThreadsPerCore function on non-Linux OSes
Browse files Browse the repository at this point in the history
Change-Id: I99bc061126d96e6fc94f0a22c8e330874fdf6543
  • Loading branch information
rdementi committed Jan 8, 2025
1 parent f91f0d2 commit 6bb0dfb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions src/cpucounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1255,9 +1255,9 @@ bool PCM::discoverSystemTopology()
pi = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX)slpi;
if (pi->Relationship == RelationProcessorCore)
{
threads_per_core = (pi->Processor.Flags == LTP_PC_SMT) ? 2 : 1;
// std::cout << "thr per core: " << threads_per_core << "\n";
num_cores += threads_per_core;
const auto current_threads_per_core = (pi->Processor.Flags == LTP_PC_SMT) ? 2 : 1;
// std::cout << "thr per core: " << current_threads_per_core << "\n";
num_cores += current_threads_per_core;
}
}
// std::cout << std::flush;
Expand Down Expand Up @@ -1372,8 +1372,6 @@ bool PCM::discoverSystemTopology()
return false;
}

if (entry.socket_id == 0 && entry.core_id == 0) ++threads_per_core;

topology.push_back(entry);
socketIdMap[entry.socket_id] = 0;
}
Expand Down Expand Up @@ -1426,7 +1424,6 @@ bool PCM::discoverSystemTopology()
socketIdMap[entries[i].socket_id] = 0;
if(entries[i].os_id >= 0)
{
if(entries[i].core_id == 0 && entries[i].socket_id == 0) ++threads_per_core;
if (populateHybridEntry(entries[i], i) == false)
{
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ class Core : public SystemObject
void addHyperThreadInfo( int32 osID, TopologyEntry te ) {
if ( te.thread_id >= MAX_THREADS_PER_CORE ) {
std::stringstream ss;
ss << "ERROR: Core: thread_id cannot be larger than " << MAX_THREADS_PER_CORE << ".\n";
ss << "ERROR: Core: thread_id " << te.thread_id << " cannot be larger than " << MAX_THREADS_PER_CORE << ".\n";
throw std::runtime_error( ss.str() );
}
if ( threads_.size() == 0 ||
Expand Down

0 comments on commit 6bb0dfb

Please sign in to comment.