Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push 2025 01 17 #902

Merged
merged 23 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
10369f9
Change protocol to IPv6, this should work fine on Linux dual stack sy…
ogbrugge-work Dec 13, 2024
911b59c
update to simdjson v3.11.2
rdementi Dec 13, 2024
95d6016
Merge remote-tracking branch 'opcm-github/master'
rdementi Dec 17, 2024
0c83112
populate sys energy field in additional SystemCounterState getters
rdementi Dec 17, 2024
e978167
fix getThreadsPerCore function on non-Linux OSes
rdementi Jan 7, 2025
4a2db0b
cppcheck: exclude pugixml
rdementi Dec 17, 2024
c9b4b65
pcm-iio: improve an error message
rdementi Jan 8, 2025
0a6c61e
use read32 for unaligned 8B pcicfg msr.sys reads
rdementi Jan 8, 2025
6c56570
Add pugixml as a submodule
rdementi Dec 17, 2024
731a08b
pcm-raw: add PMT XML lookup
rdementi Dec 18, 2024
9b2c06e
address warnings
rdementi Dec 19, 2024
449ad8c
Add Intel-PMT as a submodule
rdementi Dec 19, 2024
f1c5b1d
change error to info
rdementi Dec 19, 2024
cf75a4b
tpmi and uncore discovery is available on server cpus only
rdementi Jan 9, 2025
8618fe2
update dependencies
rdementi Jan 9, 2025
b802d0d
include cctype
rdementi Jan 9, 2025
a293fd6
introduce socketUniqueCoreID to again create a unique Core ID for the…
ogbrugge-work Jan 14, 2025
baf5870
cmake 3.12+ is now required
rdementi Jan 10, 2025
bd1325a
reduce required cmake version
rdementi Jan 11, 2025
5b00bd8
Merge remote-tracking branch 'opcm-github/master'
rdementi Jan 14, 2025
455d1ee
Refactor ccr class (#740)
antonovalexnn Jan 16, 2025
4887dd6
pcm: introduce --no-color option
rdementi Jan 17, 2025
ce57f4c
pcm: make --color default on UNIX-like OSes
rdementi Jan 17, 2025
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
13 changes: 13 additions & 0 deletions src/cpucounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,19 @@ bool PCM::discoverSystemTopology()
entry.die_id = getID(apic_id, TopologyEntry::DomainTypeID::DieDomain);
entry.die_grp_id = getID(apic_id, TopologyEntry::DomainTypeID::DieGrpDomain);
entry.socket_id = getID(apic_id, TopologyEntry::DomainTypeID::SocketPackageDomain);

auto getDomain = [&topologyDomainMap](const TopologyEntry::DomainTypeID t)
{
auto di = topologyDomainMap.find(t);
if (di != topologyDomainMap.end())
{
return di->second;
}
throw std::runtime_error("DomainType not found");
};
domain d1 = getDomain( TopologyEntry::DomainTypeID::CoreDomain );
domain d2 = getDomain( TopologyEntry::DomainTypeID::SocketPackageDomain );
entry.socket_unique_core_id = extract_bits_ui( apic_id, d1.levelShift, d2.levelShift - 1 );
}
else
{
Expand Down
300 changes: 127 additions & 173 deletions src/lspci.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,185 +35,139 @@ typedef std::map<std::pair<h_id,v_id>,uint64_t> ctr_data;
typedef std::vector<ctr_data> stack_content;
typedef std::vector<stack_content> result_content;

class ccr {
public:
virtual uint64_t get_event_select() const = 0;
virtual void set_event_select(uint64_t value) = 0;
virtual uint64_t get_umask() const = 0;
virtual void set_umask(uint64_t value) = 0;
virtual uint64_t get_reset() const = 0;
virtual void set_reset(uint64_t value) = 0;
virtual uint64_t get_edge() const = 0;
virtual void set_edge(uint64_t value) = 0;
virtual uint64_t get_ov_en() const = 0;
virtual void set_ov_en(uint64_t value) = 0;
virtual uint64_t get_enable() const = 0;
virtual void set_enable(uint64_t value) = 0;
virtual uint64_t get_invert() const = 0;
virtual void set_invert(uint64_t value) = 0;
virtual uint64_t get_thresh() const = 0;
virtual void set_thresh(uint64_t value) = 0;
virtual uint64_t get_ch_mask() const = 0;
virtual void set_ch_mask(uint64_t value) = 0;
virtual uint64_t get_fc_mask() const = 0;
virtual void set_fc_mask(uint64_t value) = 0;
virtual uint64_t get_ccr_value() const = 0;
virtual void set_ccr_value(uint64_t value) = 0;
virtual ~ccr() {};
struct ccr_config {
static constexpr uint64_t EVENT_SELECT_MASK = 0xFFULL;
static constexpr uint8_t UMASK_SHIFT = 8;
static constexpr uint64_t UMASK_MASK = 0xFFULL << UMASK_SHIFT;
static constexpr uint8_t RESET_SHIFT = 17;
static constexpr uint64_t RESET_MASK = 0x01ULL << RESET_SHIFT;
static constexpr uint8_t EDGE_SHIFT = 18;
static constexpr uint64_t EDGE_MASK = 0x01ULL << EDGE_SHIFT;
static constexpr uint8_t OV_EN_SHIFT = 20;
static constexpr uint64_t OV_EN_MASK = 0x01ULL << OV_EN_SHIFT;
static constexpr uint8_t ENABLE_SHIFT = 22;
static constexpr uint64_t ENABLE_MASK = 0x01ULL << ENABLE_SHIFT;
static constexpr uint8_t INVERT_SHIFT = 23;
static constexpr uint64_t INVERT_MASK = 0x01ULL << INVERT_SHIFT;
static constexpr uint8_t THRESH_SHIFT = 24;
static constexpr uint64_t THRESH_MASK = 0xFFFULL << THRESH_SHIFT;
static constexpr uint8_t CH_MASK_SHIFT = 36;

uint8_t FC_MASK_SHIFT;
uint64_t FC_MASK;
uint64_t CH_MASK;

ccr_config(uint8_t fc_mask_shift, uint64_t ch_mask)
: FC_MASK_SHIFT(fc_mask_shift), FC_MASK(0x07ULL << fc_mask_shift), CH_MASK(ch_mask << CH_MASK_SHIFT) {}
};

class skx_ccr: public ccr {
public:
skx_ccr(uint64_t &v){
ccr_value = &v;
}
virtual uint64_t get_event_select() const {
return (*ccr_value & 0xFF);
}
virtual void set_event_select(uint64_t value) {
*ccr_value |= value;
}
virtual uint64_t get_umask() const {
return ((*ccr_value >> 8) & 0xFF);
}
virtual void set_umask(uint64_t value) {
*ccr_value |= (value << 8);
}
virtual uint64_t get_reset() const {
return ((*ccr_value >> 17) & 0x01);
}
virtual void set_reset(uint64_t value) {
*ccr_value |= (value << 17);
}
virtual uint64_t get_edge() const {
return ((*ccr_value >> 18) & 0x01);
}
virtual void set_edge(uint64_t value) {
*ccr_value |= (value << 18);
}
virtual uint64_t get_ov_en() const {
return ((*ccr_value >> 20) & 0x01);
}
virtual void set_ov_en(uint64_t value) {
*ccr_value |= (value << 20);
}
virtual uint64_t get_enable() const {
return ((*ccr_value >> 22) & 0x01);
}
virtual void set_enable(uint64_t value) {
*ccr_value |= (value << 22);
}
virtual uint64_t get_invert() const {
return ((*ccr_value >> 23) & 0x01);
}
virtual void set_invert(uint64_t value) {
*ccr_value |= (value << 23);
}
virtual uint64_t get_thresh() const {
return ((*ccr_value >> 24) & 0xFFF);
}
virtual void set_thresh(uint64_t value) {
*ccr_value |= (value << 24);
}
virtual uint64_t get_ch_mask() const {
return ((*ccr_value >> 36) & 0xFF);
}
virtual void set_ch_mask(uint64_t value) {
*ccr_value |= (value << 36);
}
virtual uint64_t get_fc_mask() const {
return ((*ccr_value >> 44) & 0x07);
}
virtual void set_fc_mask(uint64_t value) {
*ccr_value |= (value << 44);
}
virtual uint64_t get_ccr_value() const {
return *ccr_value;
}
virtual void set_ccr_value(uint64_t value) {
*ccr_value = value;
}
class ccr {
public:
enum class ccr_type {
skx,
icx
};

private:
uint64_t* ccr_value = NULL;
};
ccr(uint64_t &v, const ccr_type &type) : ccr_value(v), config(type == ccr_type::skx ? skx_ccrs : icx_ccrs) { }

ccr() = delete;

~ccr() = default;

uint64_t get_event_select() const {
return (ccr_value & config.EVENT_SELECT_MASK);
}

void set_event_select(uint64_t value) {
ccr_value = (ccr_value & ~config.EVENT_SELECT_MASK) | (value & config.EVENT_SELECT_MASK);
}

uint64_t get_umask() const {
return (ccr_value & config.UMASK_MASK) >> config.UMASK_SHIFT;
}

void set_umask(uint64_t value) {
ccr_value = (ccr_value & ~config.UMASK_MASK) | ((value << config.UMASK_SHIFT) & config.UMASK_MASK);
}

uint64_t get_reset() const {
return (ccr_value & config.RESET_MASK) >> config.RESET_SHIFT;
}

void set_reset(uint64_t value) {
ccr_value = (ccr_value & ~config.RESET_MASK) | ((value << config.RESET_SHIFT) & config.RESET_MASK);
}

uint64_t get_edge() const {
return (ccr_value & config.EDGE_MASK) >> config.EDGE_SHIFT;
}

void set_edge(uint64_t value) {
ccr_value = (ccr_value & ~config.EDGE_MASK) | ((value << config.EDGE_SHIFT) & config.EDGE_MASK);
}

uint64_t get_ov_en() const {
return (ccr_value & config.OV_EN_MASK) >> config.OV_EN_SHIFT;
}

void set_ov_en(uint64_t value) {
ccr_value = (ccr_value & ~config.OV_EN_MASK) | ((value << config.OV_EN_SHIFT) & config.OV_EN_MASK);
}

uint64_t get_enable() const {
return (ccr_value & config.ENABLE_MASK) >> config.ENABLE_SHIFT;
}

void set_enable(uint64_t value) {
ccr_value = (ccr_value & ~config.ENABLE_MASK) | ((value << config.ENABLE_SHIFT) & config.ENABLE_MASK);
}

uint64_t get_invert() const {
return (ccr_value & config.INVERT_MASK) >> config.INVERT_SHIFT;
}

void set_invert(uint64_t value) {
ccr_value = (ccr_value & ~config.INVERT_MASK) | ((value << config.INVERT_SHIFT) & config.INVERT_MASK);
}

uint64_t get_thresh() const {
return (ccr_value & config.THRESH_MASK) >> config.THRESH_SHIFT;
}

void set_thresh(uint64_t value) {
ccr_value = (ccr_value & ~config.THRESH_MASK) | ((value << config.THRESH_SHIFT) & config.THRESH_MASK);
}

uint64_t get_ch_mask() const {
return (ccr_value & config.CH_MASK) >> config.CH_MASK_SHIFT;
}

class icx_ccr: public ccr {
public:
icx_ccr(uint64_t &v){
ccr_value = &v;
}
virtual uint64_t get_event_select() const {
return (*ccr_value & 0xFF);
}
virtual void set_event_select(uint64_t value) {
*ccr_value |= value;
}
virtual uint64_t get_umask() const {
return ((*ccr_value >> 8) & 0xFF);
}
virtual void set_umask(uint64_t value) {
*ccr_value |= (value << 8);
}
virtual uint64_t get_reset() const {
return ((*ccr_value >> 17) & 0x01);
}
virtual void set_reset(uint64_t value) {
*ccr_value |= (value << 17);
}
virtual uint64_t get_edge() const {
return ((*ccr_value >> 18) & 0x01);
}
virtual void set_edge(uint64_t value) {
*ccr_value |= (value << 18);
}
virtual uint64_t get_ov_en() const {
return ((*ccr_value >> 20) & 0x01);
}
virtual void set_ov_en(uint64_t value) {
*ccr_value |= (value << 20);
}
virtual uint64_t get_enable() const {
return ((*ccr_value >> 22) & 0x01);
}
virtual void set_enable(uint64_t value) {
*ccr_value |= (value << 22);
}
virtual uint64_t get_invert() const {
return ((*ccr_value >> 23) & 0x01);
}
virtual void set_invert(uint64_t value) {
*ccr_value |= (value << 23);
}
virtual uint64_t get_thresh() const {
return ((*ccr_value >> 24) & 0xFFF);
}
virtual void set_thresh(uint64_t value) {
*ccr_value |= (value << 24);
}
virtual uint64_t get_ch_mask() const {
return ((*ccr_value >> 36) & 0xFFF);
}
virtual void set_ch_mask(uint64_t value) {
*ccr_value |= (value << 36);
}
virtual uint64_t get_fc_mask() const {
return ((*ccr_value >> 48) & 0x07);
}
virtual void set_fc_mask(uint64_t value) {
*ccr_value |= (value << 48);
}
virtual uint64_t get_ccr_value() const {
return *ccr_value;
}
virtual void set_ccr_value(uint64_t value) {
*ccr_value = value;
}

private:
uint64_t* ccr_value = NULL;
void set_ch_mask(uint64_t value) {
ccr_value = (ccr_value & ~config.CH_MASK) | ((value << config.CH_MASK_SHIFT) & config.CH_MASK);
}

uint64_t get_fc_mask() const {
return (ccr_value & config.FC_MASK) >> config.FC_MASK_SHIFT;
}

void set_fc_mask(uint64_t value) {
ccr_value = (ccr_value & ~config.FC_MASK) | ((value << config.FC_MASK_SHIFT) & config.FC_MASK);
}

uint64_t get_ccr_value() const { return ccr_value; }

void set_ccr_value(uint64_t value) { ccr_value = value; }
private:
uint64_t &ccr_value;
const ccr_config &config;

static const ccr_config skx_ccrs;
static const ccr_config icx_ccrs;
};

const ccr_config ccr::skx_ccrs(44, 0xFFULL);
const ccr_config ccr::icx_ccrs(48, 0xFFFULL);

struct bdf {
uint32_t domainno;
uint8_t busno;
Expand Down
4 changes: 2 additions & 2 deletions src/pcm-iio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1912,15 +1912,15 @@ ccr* get_ccr(PCM* m, uint64_t& ccr)
switch (m->getCPUFamilyModel())
{
case PCM::SKX:
return new skx_ccr(ccr);
return new pcm::ccr(ccr, ccr::ccr_type::skx);
case PCM::ICX:
case PCM::SNOWRIDGE:
case PCM::SPR:
case PCM::EMR:
case PCM::GRR:
case PCM::SRF:
case PCM::GNR:
return new icx_ccr(ccr);
return new pcm::ccr(ccr, ccr::ccr_type::icx);
default:
cerr << m->getCPUFamilyModelString() << " is not supported! Program aborted" << endl;
exit(EXIT_FAILURE);
Expand Down
15 changes: 8 additions & 7 deletions src/pcm-sensor-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,14 @@ class JSONPrinter : Visitor
iterateVectorAndCallAccept( vec );
endObject( JSONPrinter::LineEndAction::DelimiterAndNewLine, END_LIST );

// For backward compatibility we use socketUniqueCoreID to create a unique number inside the socket for a core
// and introduce HW Core ID as the physical core id inside a module, keep in mind this core id is not unique inside a socket
printCounter( "Core ID", c->socketUniqueCoreID() );
printCounter( "HW Core ID", c->coreID() );
printCounter( "Module ID", c->moduleID() );
printCounter( "Tile ID", c->tileID() );
printCounter( "Core ID", c->coreID() );
printCounter( "Die ID", c->dieID() );
printCounter( "Die Group ID", c->dieGroupID() );
printCounter( "Socket ID", c->socketID() );
}

Expand Down Expand Up @@ -645,14 +651,9 @@ class PrometheusPrinter : Visitor
}

virtual void dispatch( Core* c ) override {
addToHierarchy( std::string( "core=\"" ) + std::to_string( c->dieGroupID()*256 + c->dieID()*64 + c->tileID()*16 + c->moduleID()*4 + c->coreID() ) + "\"" );
addToHierarchy( std::string( "core=\"" ) + std::to_string( c->socketUniqueCoreID() ) + "\"" );
auto vec = c->threads();
iterateVectorAndCallAccept( vec );

// Useless?
//printCounter( "Tile ID", c->tileID() );
//printCounter( "Core ID", c->coreID() );
//printCounter( "Socket ID", c->socketID() );
removeFromHierarchy();
}

Expand Down
Loading
Loading