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
1 change: 1 addition & 0 deletions cpucounters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2061,6 +2061,7 @@ bool PCM::checkModel()
if (cpu_model == BROADWELL_XEON_E3) cpu_model = BROADWELL;
if (cpu_model == SKL_UY) cpu_model = SKL;
if (cpu_model == KBL_1) cpu_model = KBL;
if (cpu_model == CML) cpu_model = KBL;

if(!isCPUModelSupported((int)cpu_model))
{
Expand Down
1 change: 1 addition & 0 deletions cpucounters.h
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,7 @@ class PCM_API PCM
SKL_UY = 78,
KBL = 158,
KBL_1 = 142,
CML = 166,
ICL = 126,
BDX = 79,
KNL = 87,
Expand Down
55 changes: 9 additions & 46 deletions pcm-core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include <vector>
#define PCM_DELAY_DEFAULT 1.0 // in seconds
#define PCM_DELAY_MIN 0.015 // 15 milliseconds is practical on most modern CPUs
#define PCM_CALIBRATION_INTERVAL 50 // calibrate clock only every 50th iteration
#define MAX_CORES 4096

using namespace std;
Expand Down Expand Up @@ -136,6 +135,7 @@ void print_usage(const string progname)
cerr << " [-e event1] [-e event2] [-e event3] .. => optional list of custom events to monitor\n";
cerr << " event description example: cpu/umask=0x01,event=0x05,name=MISALIGN_MEM_REF.LOADS/ \n";
cerr << " -yc | --yescores | /yc => enable specific cores to output\n";
cerr << " -i[=number] | /i[=number] => allow to determine number of iterations\n";
print_help_force_rtm_abort_mode(41);
cerr << " Examples:\n";
cerr << " " << progname << " 1 => print counters every second without core and socket output\n";
Expand Down Expand Up @@ -292,10 +292,8 @@ int main(int argc, char * argv[])
char **sysArgv = NULL;
uint32 cur_event = 0;
bool csv = false;
long diff_usec = 0; // deviation of clock is useconds between measurements
uint64 txn_rate = 1;
int calibrated = PCM_CALIBRATION_INTERVAL - 2; // keeps track is the clock calibration needed
unsigned int numberOfIterations = 0; // number of iterations
MainLoop mainLoop;
string program = string(argv[0]);
EventSelectRegister regs[PERF_MAX_COUNTERS];
PCM::ExtendedCustomCoreEventDescription conf;
Expand Down Expand Up @@ -335,17 +333,8 @@ int main(int argc, char * argv[])
continue;
}
else
if (strncmp(*argv, "-i", 2) == 0 ||
strncmp(*argv, "/i", 2) == 0)
if (mainLoop.parseArg(*argv))
{
string cmd = string(*argv);
size_t found = cmd.find('=', 2);
if (found != string::npos) {
string tmp = cmd.substr(found + 1);
if (!tmp.empty()) {
numberOfIterations = (unsigned int)atoi(tmp.c_str());
}
}
continue;
}
else if (strncmp(*argv, "-c",2) == 0 ||
Expand Down Expand Up @@ -515,38 +504,12 @@ int main(int argc, char * argv[])
}


unsigned int ic = 1;

while ((ic <= numberOfIterations) || (numberOfIterations == 0))
mainLoop([&]()
{
if(!csv) cout << std::flush;
int delay_ms = int(delay * 1000);
int calibrated_delay_ms = delay_ms;
#ifdef _MSC_VER
// compensate slow Windows console output
if(AfterTime) delay_ms -= (int)(m->getTickCount() - BeforeTime);
if(delay_ms < 0) delay_ms = 0;
#else
// compensation of delay on Linux/UNIX
// to make the samling interval as monotone as possible
struct timeval start_ts, end_ts;
if(calibrated == 0) {
gettimeofday(&end_ts, NULL);
diff_usec = (end_ts.tv_sec-start_ts.tv_sec)*1000000.0+(end_ts.tv_usec-start_ts.tv_usec);
calibrated_delay_ms = delay_ms - diff_usec/1000.0;
}
#endif
if (sysCmd == NULL || numberOfIterations != 0 || m->isBlocked() == false)
{
MySleepMs(calibrated_delay_ms);
}

#ifndef _MSC_VER
calibrated = (calibrated + 1) % PCM_CALIBRATION_INTERVAL;
if(calibrated == 0) {
gettimeofday(&start_ts, NULL);
}
#endif
calibratedSleep(delay, sysCmd, mainLoop, m);

AfterTime = m->getTickCount();
m->getAllCounterStates(SysAfterState, DummySocketStates, AfterState);

Expand Down Expand Up @@ -611,9 +574,9 @@ int main(int argc, char * argv[])

if ( m->isBlocked() ) {
// in case PCM was blocked after spawning child application: break monitoring loop here
break;
return false;
}
++ic;
}
return true;
});
exit(EXIT_SUCCESS);
}
21 changes: 14 additions & 7 deletions pcm-latency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,13 @@ void build_registers(PCM *m, PCM::ExtendedCustomCoreEventDescription conf, bool
m->programServerUncoreLatencyMetrics(enable_pmm);
}

void collect_data(PCM *m, bool enable_pmm, bool enable_verbose, int delay_ms)
void collect_data(PCM *m, bool enable_pmm, bool enable_verbose, int delay_ms, MainLoop & mainLoop)
{

BeforeState = new ServerUncoreCounterState[m->getNumSockets()];
AfterState = new ServerUncoreCounterState[m->getNumSockets()];

while (1)
mainLoop([&]()
{
collect_beforestate_uncore(m);
collect_beforestate_core(m);
Expand All @@ -470,7 +470,8 @@ void collect_data(PCM *m, bool enable_pmm, bool enable_verbose, int delay_ms)

print_all_stats(m, enable_pmm, enable_verbose);
std::cout << std::flush;
}
return true;
});

delete[] BeforeState;
delete[] AfterState;
Expand All @@ -479,9 +480,10 @@ void collect_data(PCM *m, bool enable_pmm, bool enable_verbose, int delay_ms)
void print_usage()
{
cerr << "\nUsage: \n";
cerr << " -h | --help | /h => Print this help and exit\n";
cerr << " --PMM | -pmm => to enable PMM (Default DDR uncore latency)\n";
cerr << " -v | --verbose => Verbose Output\n";
cerr << " -h | --help | /h => print this help and exit\n";
cerr << " --PMM | -pmm => to enable PMM (Default DDR uncore latency)\n";
cerr << " -i[=number] | /i[=number] => allow to determine number of iterations\n";
cerr << " -v | --verbose => verbose Output\n";
cerr << "\n";
}

Expand All @@ -493,6 +495,7 @@ int main(int argc, char * argv[])
bool enable_pmm = false;
bool enable_verbose = false;
int delay_ms = 1000;
MainLoop mainLoop;
if(argc > 1) do
{
argv++;
Expand All @@ -505,6 +508,10 @@ int main(int argc, char * argv[])
print_usage();
exit(EXIT_FAILURE);
}
else if (mainLoop.parseArg(*argv))
{
continue;
}
else if (strncmp(*argv, "--PMM",6) == 0 || strncmp(*argv, "-pmm", 5) == 0)
{
argv++;
Expand All @@ -528,7 +535,7 @@ int main(int argc, char * argv[])
PCM * m = PCM::getInstance();

build_registers(m, conf, enable_pmm, enable_verbose);
collect_data(m, enable_pmm, enable_verbose, delay_ms);
collect_data(m, enable_pmm, enable_verbose, delay_ms, mainLoop);

exit(EXIT_SUCCESS);
}
57 changes: 8 additions & 49 deletions pcm-memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

#define PCM_DELAY_DEFAULT 1.0 // in seconds
#define PCM_DELAY_MIN 0.015 // 15 milliseconds is practical on most modern CPUs
#define PCM_CALIBRATION_INTERVAL 50 // calibrate clock only every 50th iteration

#define DEFAULT_DISPLAY_COLUMNS 2

Expand Down Expand Up @@ -91,6 +90,7 @@ void print_help(const string prog_name)
<< " to a file, in case filename is provided\n";
cerr << " -columns=X | /columns=X => Number of columns to display the NUMA Nodes, defaults to 2.\n";
cerr << " -all | /all => Display all channels (even with no traffic)\n";
cerr << " -i[=number] | /i[=number] => allow to determine number of iterations\n";
#ifdef _MSC_VER
cerr << " --uninstallDriver | --installDriver=> (un)install driver\n";
#endif
Expand Down Expand Up @@ -826,12 +826,8 @@ int main(int argc, char * argv[])
uint32 no_columns = DEFAULT_DISPLAY_COLUMNS; // Default number of columns is 2
char * sysCmd = NULL;
char ** sysArgv = NULL;
#ifndef _MSC_VER
long diff_usec = 0; // deviation of clock is useconds between measurements
int calibrated = PCM_CALIBRATION_INTERVAL - 2; // keeps track is the clock calibration needed
#endif
int rankA = -1, rankB = -1;
unsigned int numberOfIterations = 0; // number of iterations
MainLoop mainLoop;

string program = string(argv[0]);

Expand Down Expand Up @@ -867,17 +863,8 @@ int main(int argc, char * argv[])
continue;
}
else
if (strncmp(*argv, "-i", 2) == 0 ||
strncmp(*argv, "/i", 2) == 0)
if (mainLoop.parseArg(*argv))
{
string cmd = string(*argv);
size_t found = cmd.find('=', 2);
if (found != string::npos) {
string tmp = cmd.substr(found + 1);
if (!tmp.empty()) {
numberOfIterations = (unsigned int)atoi(tmp.c_str());
}
}
continue;
}
else
Expand Down Expand Up @@ -1097,39 +1084,11 @@ int main(int argc, char * argv[])
MySystem(sysCmd, sysArgv);
}

unsigned int i = 1;

while ((i <= numberOfIterations) || (numberOfIterations == 0))
mainLoop([&]()
{
if(!csv) cout << flush;
int delay_ms = int(delay * 1000);
int calibrated_delay_ms = delay_ms;
#ifdef _MSC_VER
// compensate slow Windows console output
if(AfterTime) delay_ms -= (int)(m->getTickCount() - BeforeTime);
if(delay_ms < 0) delay_ms = 0;
#else
// compensation of delay on Linux/UNIX
// to make the samling interval as monotone as possible
struct timeval start_ts, end_ts;
if(calibrated == 0) {
gettimeofday(&end_ts, NULL);
diff_usec = (end_ts.tv_sec-start_ts.tv_sec)*1000000.0+(end_ts.tv_usec-start_ts.tv_usec);
calibrated_delay_ms = delay_ms - diff_usec/1000.0;
}
#endif

if (sysCmd == NULL || numberOfIterations != 0 || m->isBlocked() == false)
{
MySleepMs(calibrated_delay_ms);
}

#ifndef _MSC_VER
calibrated = (calibrated + 1) % PCM_CALIBRATION_INTERVAL;
if(calibrated == 0) {
gettimeofday(&start_ts, NULL);
}
#endif
calibratedSleep(delay, sysCmd, mainLoop, m);

AfterTime = m->getTickCount();
for(uint32 i=0; i<m->getNumSockets(); ++i)
Expand All @@ -1150,10 +1109,10 @@ int main(int argc, char * argv[])

if ( m->isBlocked() ) {
// in case PCM was blocked after spawning child application: break monitoring loop here
break;
return false;
}
++i;
}
return true;
});

delete[] BeforeState;
delete[] AfterState;
Expand Down
44 changes: 12 additions & 32 deletions pcm-numa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include <vector>
#define PCM_DELAY_DEFAULT 1.0 // in seconds
#define PCM_DELAY_MIN 0.015 // 15 milliseconds is practical on most modern CPUs
#define PCM_CALIBRATION_INTERVAL 50 // calibrate clock only every 50th iteration

using namespace std;
using namespace pcm;
Expand All @@ -57,6 +56,7 @@ void print_usage(const string progname)
cerr << " -h | --help | /h => print this help and exit\n";
cerr << " -csv[=file.csv] | /csv[=file.csv] => output compact CSV format to screen or\n"
<< " to a file, in case filename is provided\n";
cerr << " -i[=number] | /i[=number] => allow to determine number of iterations\n";
cerr << " Examples:\n";
cerr << " " << progname << " 1 => print counters every second without core and socket output\n";
cerr << " " << progname << " 0.5 -csv=test.log => twice a second save counter values to test.log in CSV format\n";
Expand Down Expand Up @@ -111,8 +111,7 @@ int main(int argc, char * argv[])
char * sysCmd = NULL;
char ** sysArgv = NULL;
bool csv = false;
long diff_usec = 0; // deviation of clock is useconds between measurements
int calibrated = PCM_CALIBRATION_INTERVAL - 2; // keeps track is the clock calibration needed
MainLoop mainLoop;
string program = string(argv[0]);

PCM * m = PCM::getInstance();
Expand Down Expand Up @@ -142,6 +141,10 @@ int main(int argc, char * argv[])
}
continue;
}
else if (mainLoop.parseArg(*argv))
{
continue;
}
else if (strncmp(*argv, "--", 2) == 0)
{
argv++;
Expand Down Expand Up @@ -256,36 +259,12 @@ int main(int argc, char * argv[])
MySystem(sysCmd, sysArgv);
}

while (1)
mainLoop([&]()
{
if (!csv) cout << flush;
int delay_ms = int(delay * 1000);
int calibrated_delay_ms = delay_ms;
#ifdef _MSC_VER
// compensate slow Windows console output
if (AfterTime) delay_ms -= (int)(m->getTickCount() - BeforeTime);
if (delay_ms < 0) delay_ms = 0;
#else
// compensation of delay on Linux/UNIX
// to make the samling interval as monotone as possible
struct timeval start_ts, end_ts;
if (calibrated == 0) {
gettimeofday(&end_ts, NULL);
diff_usec = (end_ts.tv_sec - start_ts.tv_sec) * 1000000.0 + (end_ts.tv_usec - start_ts.tv_usec);
calibrated_delay_ms = delay_ms - diff_usec / 1000.0;
}
#endif
if (sysCmd == NULL || m->isBlocked() == false)
{
MySleepMs(calibrated_delay_ms);
}

#ifndef _MSC_VER
calibrated = (calibrated + 1) % PCM_CALIBRATION_INTERVAL;
if (calibrated == 0) {
gettimeofday(&start_ts, NULL);
}
#endif
calibratedSleep(delay, sysCmd, mainLoop, m);

AfterTime = m->getTickCount();
m->getAllCounterStates(SysAfterState, DummySocketStates, AfterState);

Expand Down Expand Up @@ -326,9 +305,10 @@ int main(int argc, char * argv[])

if (m->isBlocked()) {
// in case PCM was blocked after spawning child application: break monitoring loop here
break;
return false;
}
}
return true;
});

exit(EXIT_SUCCESS);
}
Loading