Skip to content

Commit fd66271

Browse files
Rename socket to socket_id to make TopologyEntry members consistent (#700)
* Rename socket to socket_id to make TopologyEntry members consistent
1 parent 8a92c84 commit fd66271

File tree

5 files changed

+36
-36
lines changed

5 files changed

+36
-36
lines changed

src/MacMSRDriver/PcmMsr/PcmMsr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ IOReturn PcmMsrDriverClassName::buildTopology(TopologyEntry* odata, uint32_t inp
194194
odata[i].thread_id = topologies[i].thread_id;
195195
odata[i].core_id = topologies[i].core_id;
196196
odata[i].tile_id = topologies[i].tile_id;
197-
odata[i].socket = topologies[i].socket;
197+
odata[i].socket_id = topologies[i].socket_id;
198198
}
199199

200200
IOFreeAligned(topologies, topologyBufferSize);

src/cpucounters.cpp

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -652,14 +652,14 @@ void PCM::initRDT()
652652
MSR[core]->read(IA32_PQR_ASSOC, &msr_pqr_assoc);
653653
//std::cout << "initRMID reading IA32_PQR_ASSOC 0x" << std::hex << msr_pqr_assoc << std::dec << "\n";
654654

655-
//std::cout << "Socket Id : " << topology[core].socket;
655+
//std::cout << "Socket Id : " << topology[core].socket_id;
656656
msr_pqr_assoc &= 0xffffffff00000000ULL;
657-
msr_pqr_assoc |= (uint64)(rmid[topology[core].socket] & ((1ULL<<10)-1ULL));
657+
msr_pqr_assoc |= (uint64)(rmid[topology[core].socket_id] & ((1ULL<<10)-1ULL));
658658
//std::cout << "initRMID writing IA32_PQR_ASSOC 0x" << std::hex << msr_pqr_assoc << std::dec << "\n";
659659
//Write 0xC8F MSR with new RMID for each core
660660
MSR[core]->write(IA32_PQR_ASSOC,msr_pqr_assoc);
661661

662-
msr_qm_evtsel = static_cast<uint64>(rmid[topology[core].socket] & ((1ULL<<10)-1ULL));
662+
msr_qm_evtsel = static_cast<uint64>(rmid[topology[core].socket_id] & ((1ULL<<10)-1ULL));
663663
msr_qm_evtsel <<= 32;
664664
//Write 0xC8D MSR with new RMID for each core
665665
//std::cout << "initRMID writing IA32_QM_EVTSEL 0x" << std::hex << msr_qm_evtsel << std::dec << "\n";
@@ -675,7 +675,7 @@ void PCM::initRDT()
675675
memory_bw_total.push_back(std::make_shared<CounterWidthExtender>(new CounterWidthExtender::MBTCounter(MSR[core]), 24, 1000));
676676
}
677677
}
678-
rmid[topology[core].socket] --;
678+
rmid[topology[core].socket_id] --;
679679
//std::cout << std::flush; // Explicitly flush after each iteration
680680
}
681681
/* Get The scaling factor by running CPUID.0xF.0x1 instruction */
@@ -1188,7 +1188,7 @@ bool PCM::discoverSystemTopology()
11881188
}
11891189
entry.die_id = getID(apic_id, TopologyEntry::DomainTypeID::DieDomain);
11901190
entry.die_grp_id = getID(apic_id, TopologyEntry::DomainTypeID::DieGrpDomain);
1191-
entry.socket = getID(apic_id, TopologyEntry::DomainTypeID::SocketPackageDomain);
1191+
entry.socket_id = getID(apic_id, TopologyEntry::DomainTypeID::SocketPackageDomain);
11921192
}
11931193
else
11941194
{
@@ -1281,7 +1281,7 @@ bool PCM::discoverSystemTopology()
12811281
}
12821282

12831283
topology.push_back(entry);
1284-
socketIdMap[entry.socket] = 0;
1284+
socketIdMap[entry.socket_id] = 0;
12851285
}
12861286

12871287
deleteAndNullifyArray(base_slpi);
@@ -1329,7 +1329,7 @@ bool PCM::discoverSystemTopology()
13291329
}
13301330

13311331
topology[entry.os_id] = entry;
1332-
socketIdMap[entry.socket] = 0;
1332+
socketIdMap[entry.socket_id] = 0;
13331333
++num_online_cores;
13341334
}
13351335
catch (std::exception &)
@@ -1368,10 +1368,10 @@ bool PCM::discoverSystemTopology()
13681368
return false;
13691369
}
13701370

1371-
if (entry.socket == 0 && entry.core_id == 0) ++threads_per_core;
1371+
if (entry.socket_id == 0 && entry.core_id == 0) ++threads_per_core;
13721372

13731373
topology.push_back(entry);
1374-
socketIdMap[entry.socket] = 0;
1374+
socketIdMap[entry.socket_id] = 0;
13751375
}
13761376

13771377
#else // Getting processor info for Mac OS
@@ -1419,10 +1419,10 @@ bool PCM::discoverSystemTopology()
14191419
return false;
14201420
}
14211421
for(int i = 0; i < num_cores; i++){
1422-
socketIdMap[entries[i].socket] = 0;
1422+
socketIdMap[entries[i].socket_id] = 0;
14231423
if(entries[i].os_id >= 0)
14241424
{
1425-
if(entries[i].core_id == 0 && entries[i].socket == 0) ++threads_per_core;
1425+
if(entries[i].core_id == 0 && entries[i].socket_id == 0) ++threads_per_core;
14261426
if (populateHybridEntry(entries[i], i) == false)
14271427
{
14281428
return false;
@@ -1464,22 +1464,22 @@ bool PCM::discoverSystemTopology()
14641464
for (int i = 0; (i < (int)num_cores) && (!socketIdMap.empty()); ++i)
14651465
{
14661466
if(isCoreOnline((int32)i))
1467-
topology[i].socket = socketIdMap[topology[i].socket];
1467+
topology[i].socket_id = socketIdMap[topology[i].socket_id];
14681468
}
14691469

14701470
#if 0
14711471
std::cerr << "Number of socket ids: " << socketIdMap.size() << "\n";
14721472
std::cerr << "Topology:\nsocket os_id core_id\n";
14731473
for (int i = 0; i < num_cores; ++i)
14741474
{
1475-
std::cerr << topology[i].socket << " " << topology[i].os_id << " " << topology[i].core_id << "\n";
1475+
std::cerr << topology[i].socket_id << " " << topology[i].os_id << " " << topology[i].core_id << "\n";
14761476
}
14771477
#endif
14781478
if (threads_per_core == 0)
14791479
{
14801480
for (int i = 0; i < (int)num_cores; ++i)
14811481
{
1482-
if (topology[i].socket == topology[0].socket && topology[i].core_id == topology[0].core_id)
1482+
if (topology[i].socket_id == topology[0].socket_id && topology[i].core_id == topology[0].core_id)
14831483
++threads_per_core;
14841484
}
14851485
assert(threads_per_core != 0);
@@ -1494,7 +1494,7 @@ bool PCM::discoverSystemTopology()
14941494
{
14951495
if(isCoreOnline(i))
14961496
{
1497-
socketRefCore[topology[i].socket] = i;
1497+
socketRefCore[topology[i].socket_id] = i;
14981498
}
14991499
}
15001500

@@ -3132,16 +3132,16 @@ void PCM::printDetailedSystemTopology(const int detailLevel)
31323132
if (detailLevel > 0) std::cerr << std::setw(16) << it->module_id;
31333133
std::cerr << std::setw(16) << it->tile_id;
31343134
if (detailLevel > 0) std::cerr << std::setw(16) << it->die_id << std::setw(16) << it->die_grp_id;
3135-
std::cerr << std::setw(16) << it->socket
3135+
std::cerr << std::setw(16) << it->socket_id
31363136
<< std::setw(16) << it->getCoreTypeStr()
31373137
<< std::setw(16) << it->native_cpu_model
31383138
<< "\n";
3139-
if (std::find(core_id_by_socket[it->socket].begin(), core_id_by_socket[it->socket].end(), it->core_id)
3140-
== core_id_by_socket[it->socket].end())
3141-
core_id_by_socket[it->socket].push_back(it->core_id);
3139+
if (std::find(core_id_by_socket[it->socket_id].begin(), core_id_by_socket[it->socket_id].end(), it->core_id)
3140+
== core_id_by_socket[it->socket_id].end())
3141+
core_id_by_socket[it->socket_id].push_back(it->core_id);
31423142
// add socket offset to distinguish cores and tiles from different sockets
3143-
os_id_by_core[(it->socket << 15) + it->core_id].push_back(it->os_id);
3144-
os_id_by_tile[(it->socket << 15) + it->tile_id].push_back(it->os_id);
3143+
os_id_by_core[(it->socket_id << 15) + it->core_id].push_back(it->os_id);
3144+
os_id_by_tile[(it->socket_id << 15) + it->tile_id].push_back(it->os_id);
31453145

31463146
++counter;
31473147
}
@@ -3233,7 +3233,7 @@ void PCM::showSpecControlMSRs()
32333233

32343234
bool PCM::isCoreOnline(int32 os_core_id) const
32353235
{
3236-
return (topology[os_core_id].os_id != -1) && (topology[os_core_id].core_id != -1) && (topology[os_core_id].socket != -1);
3236+
return (topology[os_core_id].os_id != -1) && (topology[os_core_id].core_id != -1) && (topology[os_core_id].socket_id != -1);
32373237
}
32383238

32393239
bool PCM::isSocketOnline(int32 socket_id) const
@@ -6674,7 +6674,7 @@ void PCM::readQPICounters(SystemCounterState & result)
66746674

66756675
if(core == socketRefCore[0]) MSR[core]->read(W_MSR_PMON_FIXED_CTR, &(result.uncoreTSC));
66766676

6677-
uint32 s = topology[core].socket;
6677+
uint32 s = topology[core].socket_id;
66786678

66796679
if (!SocketProcessed[s])
66806680
{
@@ -6802,7 +6802,7 @@ SocketCounterState PCM::getSocketCounterState(uint32 socket)
68026802
{
68036803
// reading core and uncore counter states
68046804
for (int32 core = 0; core < num_cores; ++core)
6805-
if (isCoreOnline(core) && (topology[core].socket == int32(socket)))
6805+
if (isCoreOnline(core) && (topology[core].socket_id == int32(socket)))
68066806
result.readAndAggregate(MSR[core]);
68076807

68086808
readAndAggregateUncoreMCCounters(socket, result);
@@ -6836,7 +6836,7 @@ void PCM::getAllCounterStates(SystemCounterState & systemState, std::vector<Sock
68366836
coreStates[core].readAndAggregate(MSR[core]);
68376837
if (readAndAggregateSocketUncoreCounters)
68386838
{
6839-
socketStates[topology[core].socket].UncoreCounterState::readAndAggregate(MSR[core]); // read package C state counters
6839+
socketStates[topology[core].socket_id].UncoreCounterState::readAndAggregate(MSR[core]); // read package C state counters
68406840
}
68416841
readMSRs(MSR[core], threadMSRConfig, coreStates[core]);
68426842
}
@@ -6876,7 +6876,7 @@ void PCM::getAllCounterStates(SystemCounterState & systemState, std::vector<Sock
68766876
for (int32 core = 0; core < num_cores; ++core)
68776877
{ // aggregate core counters into sockets
68786878
if(isCoreOnline(core))
6879-
socketStates[topology[core].socket] += coreStates[core];
6879+
socketStates[topology[core].socket_id] += coreStates[core];
68806880
}
68816881

68826882
for (int32 s = 0; s < num_sockets; ++s)
@@ -6915,7 +6915,7 @@ void PCM::getUncoreCounterStates(SystemCounterState & systemState, std::vector<S
69156915
{
69166916
for(uint32 core=0; core < getNumCores(); ++core)
69176917
{
6918-
if(topology[core].socket == s && isCoreOnline(core))
6918+
if(topology[core].socket_id == s && isCoreOnline(core))
69196919
socketStates[s] += refCoreStates[s];
69206920
}
69216921
}

src/cpucounters.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,7 @@ class PCM_API PCM
19621962
//! \brief Determines socket of given core
19631963
//! \param core_id core identifier
19641964
//! \return socket identifier
1965-
int32 getSocketId(uint32 core_id) const { return (int32)topology[core_id].socket; }
1965+
int32 getSocketId(uint32 core_id) const { return (int32)topology[core_id].socket_id; }
19661966

19671967

19681968
size_t getNumCXLPorts(uint32 socket) const

src/topology.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,19 +372,19 @@ class SystemRoot : public SystemObject {
372372
// assert( te.os_id != -1 && osID == te.os_id );
373373
bool entryAdded = false;
374374
for ( auto& socket : sockets_ ) {
375-
if ( socket->apicId() == te.socket ) {
375+
if ( socket->apicId() == te.socket_id ) {
376376
Core* core = nullptr;
377377
if ( (core = socket->findCoreByTileID( te.tile_id )) == nullptr ) {
378378
// std::cerr << "SystemRoot::addThread: " << te.tile_id << ", " << osID << "\n";
379-
core = new Core( pcm_, te.core_id, te.tile_id, te.socket );
379+
core = new Core( pcm_, te.core_id, te.tile_id, te.socket_id );
380380
// std::cerr << "new Core ThreadID: " << te.thread_id << "\n";
381381
core->addHyperThreadInfo( te.thread_id, osID );
382382
socket->addCore( core );
383-
// std::cerr << "Added core " << te.core_id << " with os_id " << osID << ", threadid " << te.thread_id << " and tileid " << te.tile_id << " to socket " << te.socket << ".\n";
383+
// std::cerr << "Added core " << te.core_id << " with os_id " << osID << ", threadid " << te.thread_id << " and tileid " << te.tile_id << " to socket " << te.socket_id << ".\n";
384384
} else {
385385
// std::cerr << "existing Core ThreadID: " << te.thread_id << "\n";
386386
core->addHyperThreadInfo( te.thread_id, osID );
387-
// std::cerr << "Augmented core " << te.core_id << " with osID " << osID << " and threadid " << te.thread_id << " for the hyperthread to socket " << te.socket << ".\n";
387+
// std::cerr << "Augmented core " << te.core_id << " with osID " << osID << " and threadid " << te.thread_id << " for the hyperthread to socket " << te.socket_id << ".\n";
388388
}
389389
entryAdded = true;
390390
break;

src/topologyentry.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct PCM_API TopologyEntry // describes a core
1717
int32 tile_id; // tile is a constalation of 1 or more cores sharing same L2 cache. Unique for entire system
1818
int32 die_id;
1919
int32 die_grp_id;
20-
int32 socket;
20+
int32 socket_id;
2121
int32 native_cpu_model = -1;
2222
enum DomainTypeID
2323
{
@@ -38,7 +38,7 @@ struct PCM_API TopologyEntry // describes a core
3838
};
3939
CoreType core_type = Invalid;
4040

41-
TopologyEntry() : os_id(-1), thread_id (-1), core_id(-1), module_id(-1), tile_id(-1), die_id(-1), die_grp_id(-1), socket(-1) { }
41+
TopologyEntry() : os_id(-1), thread_id (-1), core_id(-1), module_id(-1), tile_id(-1), die_id(-1), die_grp_id(-1), socket_id(-1) { }
4242
const char* getCoreTypeStr()
4343
{
4444
switch (core_type)
@@ -73,7 +73,7 @@ inline void fillEntry(TopologyEntry & entry, const uint32 & smtMaskWidth, const
7373
{
7474
entry.thread_id = smtMaskWidth ? extract_bits_ui(apic_id, 0, smtMaskWidth - 1) : 0;
7575
entry.core_id = (smtMaskWidth + coreMaskWidth) ? extract_bits_ui(apic_id, smtMaskWidth, smtMaskWidth + coreMaskWidth - 1) : 0;
76-
entry.socket = extract_bits_ui(apic_id, smtMaskWidth + coreMaskWidth, 31);
76+
entry.socket_id = extract_bits_ui(apic_id, smtMaskWidth + coreMaskWidth, 31);
7777
entry.tile_id = extract_bits_ui(apic_id, l2CacheMaskShift, 31);
7878
}
7979

0 commit comments

Comments
 (0)