Skip to content

Commit

Permalink
Merge tag '2023-11-09' into push-2023-11-09
Browse files Browse the repository at this point in the history
Change-Id: I3a8e0dab5504a8de4a54f9ee266b70a824b07e14
rdementi committed Nov 10, 2023
2 parents ba42ed9 + 8360600 commit 8fec46e
Showing 13 changed files with 882 additions and 476 deletions.
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
# All pcm-* executables
set(PROJECT_NAMES pcm pcm-numa pcm-latency pcm-power pcm-msr pcm-memory pcm-tsx pcm-pcie pcm-core pcm-iio pcm-lspci pcm-pcicfg pcm-mmio pcm-tpmi pcm-raw pcm-accel)

file(GLOB COMMON_SOURCES msr.cpp cpucounters.cpp pci.cpp mmio.cpp bw.cpp utils.cpp topology.cpp debug.cpp threadpool.cpp uncore_pmu_discovery.cpp)
file(GLOB COMMON_SOURCES pcm-accel-common.cpp msr.cpp cpucounters.cpp pci.cpp mmio.cpp bw.cpp utils.cpp topology.cpp debug.cpp threadpool.cpp uncore_pmu_discovery.cpp)

if (APPLE)
file(GLOB UNUX_SOURCES dashboard.cpp)
@@ -143,6 +143,8 @@ foreach(PROJECT_NAME ${PROJECT_NAMES})
file(READ pcm-sensor-server.service.in SENSOR_SERVICE_IN)
string(REPLACE "@@CMAKE_INSTALL_SBINDIR@@" "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_SBINDIR}" SENSOR_SERVICE "${SENSOR_SERVICE_IN}")
file(WRITE "${CMAKE_BINARY_DIR}/pcm-sensor-server.service" "${SENSOR_SERVICE}")
file(GLOB PROJECT_FILE ${PROJECT_NAME}.cpp pcm-accel-common.h pcm-accel-common.cpp)
target_include_directories(pcm-sensor-server PUBLIC ${CMAKE_SOURCE_DIR})
if(LINUX_SYSTEMD)
install(FILES "${CMAKE_BINARY_DIR}/pcm-sensor-server.service" DESTINATION "${LINUX_SYSTEMD_UNITDIR}")
endif(LINUX_SYSTEMD)
23 changes: 23 additions & 0 deletions src/cpucounters.cpp
Original file line number Diff line number Diff line change
@@ -2737,6 +2737,8 @@ PCM::PCM() :
num_phys_cores_per_socket(0),
num_online_cores(0),
num_online_sockets(0),
accel(0),
accel_counters_num_max(0),
core_gen_counter_num_max(0),
core_gen_counter_num_used(0), // 0 means no core gen counters used
core_gen_counter_width(0),
@@ -3502,6 +3504,7 @@ PCM::ErrorCode PCM::program(const PCM::ProgramMode mode_, const void * parameter
lastProgrammedCustomCounters.clear();
lastProgrammedCustomCounters.resize(num_cores);
core_global_ctrl_value = 0ULL;
isHWTMAL1Supported(); // ínit value to prevent MT races

std::vector<std::future<void> > asyncCoreResults;
std::vector<PCM::ErrorCode> programmingStatuses(num_cores, PCM::Success);
@@ -6480,6 +6483,26 @@ uint32 PCM::getNumSockets() const
return (uint32)num_sockets;
}

uint32 PCM::getAccel() const
{
return accel;
}

void PCM::setAccel(uint32 input)
{
accel = input;
}

uint32 PCM::getNumberofAccelCounters() const
{
return accel_counters_num_max;
}

void PCM::setNumberofAccelCounters(uint32 input)
{
accel_counters_num_max = input;
}

uint32 PCM::getNumOnlineSockets() const
{
return (uint32)num_online_sockets;
30 changes: 29 additions & 1 deletion src/cpucounters.h
Original file line number Diff line number Diff line change
@@ -605,6 +605,8 @@ class PCM_API PCM
int32 num_phys_cores_per_socket;
int32 num_online_cores;
int32 num_online_sockets;
uint32 accel;
uint32 accel_counters_num_max;
uint32 core_gen_counter_num_max;
uint32 core_gen_counter_num_used;
uint32 core_gen_counter_width;
@@ -1506,9 +1508,29 @@ class PCM_API PCM
\return Number of sockets in the system
*/
uint32 getNumSockets() const;

/*! \brief Reads the accel type in the system
\return acceltype
*/
uint32 getAccel() const;

/*! \brief Sets the accel type in the system
\return acceltype
*/
void setAccel(uint32 input);

/*! \brief Reads the Number of AccelCounters in the system
\return None
*/
uint32 getNumberofAccelCounters() const;

/*! \brief Sets the Number of AccelCounters in the system
\return number of counters
*/
void setNumberofAccelCounters(uint32 input);

/*! \brief Reads number of online sockets (CPUs) in the system
\return Number of online sockets in the system
\return Number of online sockets in the system
*/
uint32 getNumOnlineSockets() const;

@@ -3374,6 +3396,11 @@ class SystemCounterState : public SocketCounterState
}

public:
typedef uint32_t h_id;
typedef uint32_t v_id;
typedef std::map<std::pair<h_id,v_id>,uint64_t> ctr_data;
typedef std::vector<ctr_data> dev_content;
std::vector<SimpleCounterState> accel_counters;
std::vector<uint64> CXLWriteMem,CXLWriteCache;
friend uint64 getIncomingQPILinkBytes(uint32 socketNr, uint32 linkNr, const SystemCounterState & before, const SystemCounterState & after);
friend uint64 getIncomingQPILinkBytes(uint32 socketNr, uint32 linkNr, const SystemCounterState & now);
@@ -3385,6 +3412,7 @@ class SystemCounterState : public SocketCounterState
uncoreTSC(0)
{
PCM * m = PCM::getInstance();
accel_counters.resize(m->getNumberofAccelCounters());
CXLWriteMem.resize(m->getNumSockets(),0);
CXLWriteCache.resize(m->getNumSockets(),0);
incomingQPIPackets.resize(m->getNumSockets(),
36 changes: 35 additions & 1 deletion src/dashboard.cpp
Original file line number Diff line number Diff line change
@@ -4,7 +4,8 @@
#include <vector>
#include <memory>
#include <unistd.h>
#include "cpucounters.h"

#include "pcm-accel-common.h"
#include "dashboard.h"

namespace pcm {
@@ -515,6 +516,12 @@ std::string influxDBCore_Aggregate_Core_Counters(const std::string& S, const std
return influxDB_Counters(S, m, "Core Aggregate_Core Counters");
}

std::string influxDBAccel_Counters(const std::string& S, const std::string& m)
{
AcceleratorCounterState * accs = AcceleratorCounterState::getInstance();
return std::string("mean(\\\"Sockets_") + S + "_Accelerators_" +accs->getAccelCounterName()+" Counters Device_" + m + "\\\")";
}

std::string influxDBCore_Aggregate_Core_Counters(const std::string& m)
{
return influxDB_Counters(m, "Core Aggregate_Core Counters");
@@ -542,6 +549,7 @@ std::mutex dashboardGenMutex;
std::string getPCMDashboardJSON(const PCMDashboardType type, int ns, int nu, int nc)
{
auto pcm = PCM::getInstance();
auto accs = AcceleratorCounterState::getInstance();
std::lock_guard<std::mutex> dashboardGenGuard(dashboardGenMutex);
const size_t NumSockets = (ns < 0) ? pcm->getNumSockets() : ns;
const size_t NumUPILinksPerSocket = (nu < 0) ? pcm->getQPILinksPerSocket() : nu;
@@ -783,6 +791,32 @@ std::string getPCMDashboardJSON(const PCMDashboardType type, int ns, int nu, int
dashboard.push(panel);
dashboard.push(panel1);
}
if (pcm->getAccel() != ACCEL_NOCONFIG){
auto accelCounters = [&](const std::string & m)
{
auto panel = std::make_shared<GraphPanel>(0, y, width, height, accs->getAccelCounterName() + " " + m,"Byte/sec", false);
std::shared_ptr<Panel> panel1;
panel1 = std::make_shared<BarGaugePanel>(width, y, max_width - width, height, std::string("Current ") +accs->getAccelCounterName() + " (Byte/sec)");
y += height;
for (size_t s = 0; s < accs->getNumOfAccelDevs(); ++s)
{
const auto S = std::to_string(s);
const auto suffix = "/1";
auto t = createTarget("Device "+S,
"mean(\\\"Accelerators_"+accs->getAccelCounterName()+" Counters Device " + S + "_" + m + "\\\")" + suffix,
"rate(" + prometheusMetric(accs->remove_string_inside_use(m)) + "{instance=\\\"$node\\\", aggregate=\\\"system\\\", source=\\\"accel\\\" ,"+accs->getAccelCounterName()+"device=\\\"" + S + "\\\"}" + interval + ")" + suffix);
panel->push(t);
panel1->push(t);

}
dashboard.push(panel);
dashboard.push(panel1);
};
for (int j =0;j<accs->getNumberOfCounters();j++)
{
accelCounters(accs->getAccelIndexCounterName(j));
}
}
for (size_t s = 0; s < NumSockets; ++s)
{
const auto S = std::to_string(s);
18 changes: 13 additions & 5 deletions src/pci.h
Original file line number Diff line number Diff line change
@@ -178,6 +178,7 @@ inline void forAllIntelDevices(F f, int requestedDevice = -1, int requestedFunct

auto probe = [&f](const uint32 group, const uint32 bus, const uint32 device, const uint32 function)
{
// std::cerr << "Probing " << std::hex << group << ":" << bus << ":" << device << ":" << function << " " << std::dec << "\n";
uint32 value = 0;
try
{
@@ -191,6 +192,7 @@ inline void forAllIntelDevices(F f, int requestedDevice = -1, int requestedFunct
}
const uint32 vendor_id = value & 0xffff;
const uint32 device_id = (value >> 16) & 0xffff;
// std::cerr << "Found dev " << std::hex << vendor_id << ":" << device_id << std::dec << "\n";
if (vendor_id != PCM_INTEL_PCI_VENDOR_ID)
{
return;
@@ -256,12 +258,13 @@ void processDVSEC(MatchFunc matchFunc, ProcessFunc processFunc)
{
forAllIntelDevices([&](const uint32 group, const uint32 bus, const uint32 device, const uint32 function, const uint32 /* device_id */)
{
// std::cerr << "Intel device scan. found " << std::hex << group << ":" << bus << ":" << device << ":" << function << " " << device_id << std::dec;
uint32 status{0};
PciHandleType h(group, bus, device, function);
h.read32(6, &status); // read status
if (status & 0x10) // has capability list
{
// std::cout << "Intel device scan. found "<< std::hex << group << ":" << bus << ":" << device << ":" << function << " " << device_id << " with capability list\n" << std::dec;
// std::cerr << "Intel device scan. found "<< std::hex << group << ":" << bus << ":" << device << ":" << function << " " << device_id << " with capability list\n" << std::dec;
VSEC header;
uint64 offset = 0x100;
do
@@ -274,11 +277,11 @@ void processDVSEC(MatchFunc matchFunc, ProcessFunc processFunc)
{
return;
}
// std::cout << "offset 0x" << std::hex << offset << " header.fields.cap_id: 0x" << header.fields.cap_id << std::dec << "\n";
// std::cout << ".. found entryID: 0x" << std::hex << header.fields.entryID << std::dec << "\n";
if (matchFunc(header)) // UNCORE_DISCOVERY_DVSEC_ID_PMON
// std::cerr << "offset 0x" << std::hex << offset << " header.fields.cap_id: 0x" << header.fields.cap_id << std::dec << "\n";
// std::cerr << ".. found entryID: 0x" << std::hex << header.fields.entryID << std::dec << "\n";
if (matchFunc(header))
{
// std::cout << ".... found UNCORE_DISCOVERY_DVSEC_ID_PMON\n";
// std::cerr << ".... found match\n";
auto barOffset = 0x10 + header.fields.tBIR * 4;
uint32 bar = 0;
if (h.read32(barOffset, &bar) == sizeof(uint32) && bar != 0) // read bar
@@ -291,7 +294,12 @@ void processDVSEC(MatchFunc matchFunc, ProcessFunc processFunc)
std::cerr << "Error: can't read bar from offset " << barOffset << " \n";
}
}
const uint64 lastOffset = offset;
offset = header.fields.cap_next & ~3;
if (lastOffset == offset) // the offset did not change
{
return; // deadlock protection
}
} while (1);
}
});
456 changes: 456 additions & 0 deletions src/pcm-accel-common.cpp

Large diffs are not rendered by default.

158 changes: 158 additions & 0 deletions src/pcm-accel-common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2022-2023, Intel Corporation
// written by White.Hu, Pavithran P

#pragma once
#include "cpucounters.h"
#ifdef __linux__
#include <sys/utsname.h>
#endif
using namespace pcm;

#define PCM_DELAY_DEFAULT 3.0 // in seconds

class idx_ccr {
public:
virtual uint64_t get_event_select() const = 0;
virtual void set_event_select(uint64_t value) = 0;
virtual uint64_t get_event_category() const = 0;
virtual void set_event_category(uint64_t value) = 0;
virtual uint64_t get_enable() const = 0;
virtual void set_enable(uint64_t value) = 0;
virtual uint64_t get_ccr_value() const = 0;
virtual void set_ccr_value(uint64_t value) = 0;
virtual ~idx_ccr() {};
};

class spr_idx_ccr: public idx_ccr {
public:
spr_idx_ccr(uint64_t &v){
ccr_value = &v;
}
virtual uint64_t get_event_select() const { //EVENT bit, bit 32
return ((*ccr_value >> 32) & 0xFFFFFFF);
}
virtual void set_event_select(uint64_t value) {
*ccr_value |= (value << 32);
}
virtual uint64_t get_event_category() const { //EVENT Categorg, bit 8
return ((*ccr_value >> 8) & 0xF);
}
virtual void set_event_category(uint64_t value) {
*ccr_value |= (value << 8);
}
virtual uint64_t get_enable() const { //Enable counter, bit 0
return ((*ccr_value >> 0 ) & 0x01);
}
virtual void set_enable(uint64_t value) {
*ccr_value |= (value << 0);
}
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;
};

idx_ccr* idx_get_ccr(uint64_t& ccr);

typedef enum
{
ACCEL_IAA,
ACCEL_DSA,
ACCEL_QAT,
ACCEL_MAX,
ACCEL_NOCONFIG,
} ACCEL_IP;

enum IDXPerfmonField
{
DPF_BASE = 0x100, //start from 0x100 to different with PerfmonField in cpucounter.h
EVENT_CATEGORY,
FILTER_WQ,
FILTER_ENG,
FILTER_TC,
FILTER_PGSZ,
FILTER_XFERSZ
};

typedef enum
{
SOCKET_MAP,
NUMA_MAP,
} ACCEL_DEV_LOC_MAPPING;

const std::vector<uint32_t> idx_accel_mapping =
{
PCM::IDX_IAA,
PCM::IDX_DSA,
PCM::IDX_QAT
};

#define ACCEL_IP_DEV_COUNT_MAX (16)

typedef uint32_t h_id;
typedef uint32_t v_id;
typedef std::map<std::pair<h_id,v_id>,uint64_t> ctr_data;
typedef std::vector<ctr_data> dev_content;
typedef std::vector<dev_content> accel_content;

struct accel_counter : public counter {
//filter config for IDX Accelerator.
uint32_t cfr_wq = 0;
uint32_t cfr_eng = 0;
uint32_t cfr_tc = 0;
uint32_t cfr_pgsz = 0;
uint32_t cfr_xfersz = 0;
};

typedef struct
{
PCM *m;
ACCEL_IP accel;
accel_counter ctr;
std::vector<struct accel_counter> ctrs;
} accel_evt_parse_context;

typedef int (*pfn_evt_handler)(evt_cb_type, void *, counter &, std::map<std::string, uint32_t> &, std::string, uint64);

int idx_evt_parse_handler(evt_cb_type cb_type, void *cb_ctx, counter &base_ctr, std::map<std::string, uint32_t> &ofm, std::string key, uint64 numValue);
void readAccelCounters(SystemCounterState &sycs_);

class AcceleratorCounterState {

private:
AcceleratorCounterState(){}; // forbidden to call directly because it is a singleton
AcceleratorCounterState & operator = (const AcceleratorCounterState &) = delete;
static AcceleratorCounterState * instance;
accel_evt_parse_context evt_ctx = { {}, {}, {}, {} };
public:
AcceleratorCounterState(const AcceleratorCounterState& obj) = delete;
// std::mutex instanceCreationMutex;
static AcceleratorCounterState * getInstance();
std::map<std::string, uint32_t> opcodeFieldMap;
std::string ev_file_name;
pfn_evt_handler p_evt_handler = NULL;

void setEvents(PCM * m,ACCEL_IP accel,std::string specify_evtfile,bool evtfile);
uint32_t getNumOfAccelDevs();
uint32_t getAccel();
uint32_t getMaxNumOfAccelCtrs();
std::vector<struct accel_counter>& getCounters();
int32_t programAccelCounters();
SimpleCounterState getAccelCounterState(uint32 dev, uint32 ctr_index);
bool isAccelCounterAvailable();
std::string getAccelCounterName();
void setDSA();
bool getAccelDevLocation( uint32_t dev, const ACCEL_DEV_LOC_MAPPING loc_map, uint32_t &location);
// void readAccelCounters(SystemCounterState sycs_);
int getNumberOfCounters();
std::string getAccelIndexCounterName(int ctr_index);
std::string remove_string_inside_use(std::string text);
uint64 getAccelIndexCounter(uint32 dev, const SystemCounterState & before,const SystemCounterState & after,int ctr_index);

};
489 changes: 29 additions & 460 deletions src/pcm-accel.cpp

Large diffs are not rendered by default.

130 changes: 128 additions & 2 deletions src/pcm-sensor-server.cpp
Original file line number Diff line number Diff line change
@@ -5,11 +5,14 @@
// https://github.com/prometheus/prometheus/wiki/Default-port-allocations
constexpr unsigned int DEFAULT_HTTP_PORT = 9738;
constexpr unsigned int DEFAULT_HTTPS_PORT = DEFAULT_HTTP_PORT;
#include "pcm-accel-common.h"

#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include<string>

#include <signal.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -338,6 +341,12 @@ class JSONPrinter : Visitor
endObject( JSONPrinter::LineEndAction::DelimiterAndNewLine, END_LIST );
SystemCounterState before = getSystemCounter( aggPair_.first );
SystemCounterState after = getSystemCounter( aggPair_.second );
PCM * pcm = PCM::getInstance();
if (pcm->getAccel()!=ACCEL_NOCONFIG){
startObject ("Accelerators",BEGIN_OBJECT);
printAccelCounterState(before,after);
endObject( JSONPrinter::LineEndAction::DelimiterAndNewLine, END_OBJECT );
}
startObject( "QPI/UPI Links", BEGIN_OBJECT );
printSystemCounterState( before, after );
endObject( JSONPrinter::LineEndAction::DelimiterAndNewLine, END_OBJECT );
@@ -347,6 +356,7 @@ class JSONPrinter : Visitor
startObject( "Uncore Aggregate", BEGIN_OBJECT );
printUncoreCounterState( before, after );
endObject( JSONPrinter::LineEndAction::NewLineOnly, END_OBJECT );

endObject( JSONPrinter::LineEndAction::NewLineOnly, END_OBJECT );
}

@@ -433,6 +443,23 @@ class JSONPrinter : Visitor
endObject( JSONPrinter::NewLineOnly, END_OBJECT );
}

void printAccelCounterState( SystemCounterState const& before, SystemCounterState const& after ) {
AcceleratorCounterState* accs_ = AcceleratorCounterState::getInstance();
uint32 devs = accs_->getNumOfAccelDevs();
for ( uint32 i=0; i < devs; ++i ) {
startObject( std::string( accs_->getAccelCounterName() + " Counters Device " ) + std::to_string( i ), BEGIN_OBJECT );
for(int j=0;j<accs_->getNumberOfCounters();j++){
printCounter( accs_->getAccelIndexCounterName(j), accs_->getAccelIndexCounter(i, before, after,j) );
}
// debug prints
//for(uint32 j=0;j<accs_->getNumberOfCounters();j++){
// std::cout<<accs_->getAccelIndexCounterName(j) << " "<<accs_->getAccelIndexCounter(i, before, after,j)<<std::endl;
// }
// std::cout <<i << " Influxdb "<<accs_->getAccelIndexCounterName()<< accs_->getAccelInboundBW (i, before, after ) << " "<< accs_->getAccelOutboundBW (i, before, after ) << " "<<accs_->getAccelShareWQ_ReqNb (i, before, after ) << " "<<accs_->getAccelDedicateWQ_ReqNb (i, before, after ) << std::endl;
endObject( JSONPrinter::DelimiterAndNewLine, END_OBJECT );
}
}

void printSystemCounterState( SystemCounterState const& before, SystemCounterState const& after ) {
PCM* pcm = PCM::getInstance();
uint32 sockets = pcm->getNumSockets();
@@ -596,6 +623,10 @@ class PrometheusPrinter : Visitor
SystemCounterState after = getSystemCounter( aggPair_.second );
addToHierarchy( "aggregate=\"system\"" );
PCM* pcm = PCM::getInstance();
if (pcm->getAccel()!=ACCEL_NOCONFIG){
printComment( "Accelerator Counters" );
printAccelCounterState(before,after);
}
if ( pcm->isServerCPU() && pcm->getNumSockets() >= 2 ) {
printComment( "UPI/QPI Counters" );
printSystemCounterState( before, after );
@@ -686,6 +717,23 @@ class PrometheusPrinter : Visitor
removeFromHierarchy();
}

void printAccelCounterState( SystemCounterState const& before, SystemCounterState const& after )
{
addToHierarchy( "source=\"accel\"" );
AcceleratorCounterState* accs_ = AcceleratorCounterState::getInstance();
uint32 devs = accs_->getNumOfAccelDevs();

for ( uint32 i=0; i < devs; ++i )
{
addToHierarchy( std::string( accs_->getAccelCounterName() + "device=\"" ) + std::to_string( i ) + "\"" );
for(int j=0;j<accs_->getNumberOfCounters();j++)
{
printCounter( accs_->remove_string_inside_use(accs_->getAccelIndexCounterName(j)), accs_->getAccelIndexCounter(i, before, after,j) );
}
removeFromHierarchy();
}
removeFromHierarchy();
}
void printSystemCounterState( SystemCounterState const& before, SystemCounterState const& after ) {
addToHierarchy( "source=\"uncore\"" );
PCM* pcm = PCM::getInstance();
@@ -3167,9 +3215,16 @@ int mainThrows(int argc, char * argv[]) {
unsigned short debug_level = 0;
std::string certificateFile;
std::string privateKeyFile;

AcceleratorCounterState *accs_;
accs_ = AcceleratorCounterState::getInstance();
null_stream nullStream;
check_and_set_silent(argc, argv, nullStream);
ACCEL_IP accel=ACCEL_NOCONFIG; //default is IAA
bool evtfile = false;
std::string specify_evtfile;
// ACCEL_DEV_LOC_MAPPING loc_map = SOCKET_MAP; //default is socket mapping
MainLoop mainLoop;
std::string ev_file_name;

if ( argc > 1 ) {
std::string arg_value;
@@ -3228,11 +3283,69 @@ int mainThrows(int argc, char * argv[]) {
{
forceRTMAbortMode = true;
}
else if (check_argument_equals(argv[i], {"-iaa", "/iaa"}))
{
accel = ACCEL_IAA;
}
else if (check_argument_equals(argv[i], {"-dsa", "/dsa"}))
{
accel = ACCEL_DSA;
std::cout << "Aggregator firstest : " << accs_->getAccelCounterName() << accel;
}
#ifdef __linux__
else if (check_argument_equals(argv[i], {"-qat", "/qat"}))
{
accel = ACCEL_QAT;
}
// else if (check_argument_equals(argv[i], {"-numa", "/numa"}))
// {
// loc_map = NUMA_MAP;
// }
#endif
else if (extract_argument_value(argv[i], {"-evt", "/evt"}, arg_value))
{
evtfile = true;
specify_evtfile = std::move(arg_value);
}
else if ( check_argument_equals( argv[i], {"-silent", "/silent"} ) )
{
// handled in check_and_set_silent
continue;
}

#ifdef __linux__
// check kernel version for driver dependency.
if (accel != ACCEL_NOCONFIG)
{
std::cout << "Info: IDX - Please ensure the required driver(e.g idxd driver for iaa/dsa, qat driver and etc) correct enabled with this system, else the tool may fail to run.\n";
struct utsname sys_info;
if (!uname(&sys_info))
{
std::string krel_str;
uint32 krel_major_ver=0, krel_minor_ver=0;
krel_str = sys_info.release;
std::vector<std::string> krel_info = split(krel_str, '.');
std::istringstream iss_krel_major(krel_info[0]);
std::istringstream iss_krel_minor(krel_info[1]);
iss_krel_major >> std::setbase(0) >> krel_major_ver;
iss_krel_minor >> std::setbase(0) >> krel_minor_ver;

switch (accel)
{
case ACCEL_IAA:
case ACCEL_DSA:
if ((krel_major_ver < 5) || (krel_major_ver == 5 && krel_minor_ver < 11))
{
std::cout<< "Warning: IDX - current linux kernel version(" << krel_str << ") is too old, please upgrade it to the latest due to required idxd driver integrated to kernel since 5.11.\n";
}
break;
default:
std::cout<< "Info: Chosen "<< accel<<" IDX - current linux kernel version(" << krel_str << ")";

}
}
}
#endif
#if defined (USE_SSL)
else if ( check_argument_equals( argv[i], {"-C", "--certificateFile"} ) ) {

@@ -3315,6 +3428,7 @@ int mainThrows(int argc, char * argv[]) {
// A HTTP interface to change the programming is planned
PCM::ErrorCode status;
PCM * pcmInstance = PCM::getInstance();
pcmInstance->setAccel(accel);
assert(pcmInstance);
if (forceRTMAbortMode)
{
@@ -3326,7 +3440,8 @@ int mainThrows(int argc, char * argv[]) {
switch ( status ) {
case PCM::PMUBusy:
{
if ( forcedProgramming == false ) {
if ( forcedProgramming == false )
{
std::cout << "Warning: PMU appears to be busy, do you want to reset it? (y/n)\n";
char answer;
std::cin >> answer;
@@ -3356,7 +3471,18 @@ int mainThrows(int argc, char * argv[]) {

//TODO: check return value when its implemented
pcmInstance->programCXLCM();
if (pcmInstance->getAccel()!=ACCEL_NOCONFIG)
{
if (pcmInstance->supportIDXAccelDev() == false)
{
std::cerr << "Error: IDX accelerator is NOT supported with this platform! Program aborted\n";
exit(EXIT_FAILURE);
}

accs_->setEvents(pcmInstance,accel,specify_evtfile,evtfile);

accs_->programAccelCounters();
}
#if defined (USE_SSL)
if ( useSSL ) {
if ( port == 0 )
3 changes: 2 additions & 1 deletion src/topology.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2016-2022, Intel Corporation

#include "cpucounters.h"
#include "topology.h"
#include "pcm-accel-common.h"

namespace pcm {

@@ -87,6 +87,7 @@ void Aggregator::dispatch( SystemRoot const& syp ) {
PCM* pcm = PCM::getInstance();
pcm->readQPICounters( sycs_ );
pcm->readAndAggregateCXLCMCounters( sycs_ );
readAccelCounters(sycs_);
}

Aggregator::Aggregator()
5 changes: 4 additions & 1 deletion src/utils.h
Original file line number Diff line number Diff line change
@@ -539,9 +539,12 @@ inline uint64 extract_bits(uint64 myin, uint32 beg, uint32 end)
}

#ifdef _MSC_VER

#define PCM_MSR_DRV_NAME TEXT("\\\\.\\RDMSR")

inline HANDLE openMSRDriver()
{
return CreateFile(TEXT("\\\\.\\RDMSR"), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
return CreateFile(PCM_MSR_DRV_NAME, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
}
#endif

4 changes: 1 addition & 3 deletions src/windows/windriver.h
Original file line number Diff line number Diff line change
@@ -100,9 +100,7 @@ class Driver
{
if (0 != StartService(hService, 0, NULL))
{
tstring convDriverName(&driverName_[0]);
tstring driverPath = TEXT("\\\\.\\") + convDriverName;
restrictDriverAccess(driverPath.c_str());
restrictDriverAccess(PCM_MSR_DRV_NAME);
return true;
}
DWORD err = GetLastError();
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/tests)
if(UNIX)

# daemon_alignment_test on Linux and Unix
file(GLOB TEST_FILE daemon_alignment_test.cpp)
file(GLOB TEST_FILE daemon_alignment_test.cpp pcm-accel-common.cpp)
add_executable(daemon_alignment_test ${TEST_FILE})
target_link_libraries(daemon_alignment_test)

0 comments on commit 8fec46e

Please sign in to comment.