Skip to content

Commit 179be0e

Browse files
committed
PMCTrack v1.5
1 parent 54c0b4d commit 179be0e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+6176
-439
lines changed

README.md

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@ Despite being an OS-oriented tool, PMCTrack still allows gathering PMC values fr
66

77
## Project Contributors
88

9-
* Juan Carlos Saez Alcaide (<jcsaezal@ucm.es>) - Creator of PMCTrack and main maintainer.
10-
* Jorge Casas Hernan - Maintainer of PMCTrack-GUI
11-
* Abel Serrano Juste (aka [@Akronix](https://github.com/Akronix))
12-
* Javier Setoain
9+
* Juan Carlos Saez Alcaide (<jcsaezal@ucm.es>) - Creator of PMCTrack and main maintainer
10+
* Adrián García García (aka [@Mizadri](https://github.com/mizadri))
11+
* Jaime Sáez de Buruaga Brouns (aka [@jaimesaez97](https://github.com/jaimesaez97))
1312

1413
## Past Contributors
1514

16-
* Guillermo Martinez Fernandez
17-
* Sergio Sanchez Gordo
18-
* Sofia Dronda Merino
15+
* Jorge Casas Hernan
16+
* Abel Serrano Juste (aka [@Akronix](https://github.com/Akronix))
17+
* Germán Franco Dorca
18+
* Andrés Plaza Hernando
19+
* Javier Setoain
20+
* Guillermo Martinez Fernández
21+
* Sergio Sánchez Gordo
22+
* Sofía Dronda Merino
1923

2024
## Publications
2125

@@ -27,11 +31,11 @@ Despite being an OS-oriented tool, PMCTrack still allows gathering PMC values fr
2731
To support PMCTrack, a patched Linux kernel must be installed on the machine. A number of kernel patches for various Linux versions can be found in the `src/kernel-patches` directory. The name of each patch file encodes the Linux kernel version where the patch must be applied to as well as the processor architecture supported. The format is as follows:
2832

2933
pmctrack_linux-<kernel_version>_<architecture>.patch
30-
34+
3135
To build the kernel for PMCTrack, the following option must be enabled when configuring the kernel:
3236

3337
CONFIG_PMCTRACK=y
34-
38+
3539

3640
The kernel headers for the patched Linux version must be installed on the system as well. This is necessary for a successful out-of-tree build of PMCTrack's kernel module. An out-of-tree-ready Makefile can be found in the sources for the different flavors of the kernel module.
3741

@@ -56,7 +60,7 @@ On Mac OS X, PMCTrack-GUI has been succesfully tested after installing the above
5660
## Set up default configuration for matplotlib
5761
$ mkdir ~/.matplotlib
5862
$ cp /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc ~/.matplotlib
59-
63+
6064
## Select MacPorts Python27 interpreter by default
6165
$sudo port select --set python python27
6266
$sudo port select --set ipython ipython27
@@ -67,7 +71,7 @@ On Mac OS X, PMCTrack-GUI has been succesfully tested after installing the above
6771
The `PMCTRACK_ROOT` environment variable must be defined for a successful execution of the various PMCTrack command-line tools. The `shrc` script found in the repository's root directory can be used to set the `PMCTRACK_ROOT` variable appropriately as well as to add command-line tools' directories to the PATH. To make this possible, run the following command in the root directory of the repository:
6872

6973
$ . shrc
70-
74+
7175
Now kernel-level and user-level components can be easily built with the `pmctrack-manager` script as follows:
7276

7377
$ pmctrack-manager build
@@ -77,7 +81,7 @@ Now kernel-level and user-level components can be easily built with the `pmctrac
7781
Processor_bitwidth=64
7882
***********************************************
7983
Press ENTER to start the build process...
80-
84+
8185
*************************************************
8286
*** Building supported PMCTrack kernel modules **
8387
*************************************************
@@ -174,15 +178,16 @@ After that, load any of the available flavors of the PMCTrack's kernel module co
174178

175179
The following table summarizes the properties of the various flavors of the kernel module:
176180

177-
| Name | Path of the .ko file | Supported processors |
178-
| -----| ---------------------| ---------------------|
179-
| intel-core | `src/modules/pmcs/intel-core/mchw_intel_core.ko` | Most Intel multi-core processors are compatible with this module, including recent processors based on the Intel "Broadwell" microarchitecture. |
180-
| amd | `src/modules/pmcs/amd/mchw_amd.ko` | This module has been successfully tested on AMD opteron processors. Nevertheless, it should be compatible with all AMD multicore processors. |
181-
| arm | `src/modules/pmcs/arm/mchw_arm.ko` | This module has been successfully tested on ARM systems featuring 32-bit big.LITTLE processors, which combine ARM Cortex A7 cores with and ARM Cortex A15 cores. Specifically, tests were performed on the ARM Coretile Express Development Board (TC2). |
182-
| odroid-xu | `src/modules/pmcs/odroid-xu/mchw_odroid_xu.ko` | Specific module for Odroid XU3 and XU4 boards. More information on these boards can be found at [www.hardkernel.com](http://www.hardkernel.com) |
183-
| arm64 | `src/modules/pmcs/arm64/mchw_arm64.ko` | This module has been successfully tested on ARM systems featuring 64-bit big.LITTLE processors, which combine ARM Cortex A57 cores with and ARM Cortex A53 cores. Specifically, tests were performed on the ARM Juno Development Board. |
184-
| xeon-phi | `src/modules/pmcs/xeon-phi/mchw_phi.ko` | Intel Xeon Phi Coprocessor |
185-
| core2 | `src/modules/pmcs/phi/mchw_core2.ko` | This module has been specifically designed for the Intel QuickIA prototype system. The Intel QuickIA is a dual-socket asymmetric multicore system that features a quad-core Intel Xeon E5450 processor and a dual-core Intel Atom N330. The module also works with Intel Atom processors as well as "old" Intel multicore processors, such as the Intel Core 2 Duo. Nevertheless, given the numerous existing hacks for the QuickIA in this module, users are advised to use the more general "intel-core" flavor. |
181+
| Name | Path of the .ko file | Supported processors |
182+
| -----| ---------------------| ---------------------|
183+
| intel-core | `src/modules/pmcs/intel-core/mchw_intel_core.ko` | Most Intel multi-core processors are compatible with this module, including recent processors based on the Intel "Broadwell" microarchitecture. |
184+
| amd | `src/modules/pmcs/amd/mchw_amd.ko` | This module has been successfully tested on AMD opteron processors. Nevertheless, it should be compatible with all AMD multicore processors. |
185+
| arm | `src/modules/pmcs/arm/mchw_arm.ko` | This module has been successfully tested on ARM systems featuring 32-bit big.LITTLE processors, which combine ARM Cortex A7 cores with and ARM Cortex A15 cores. Specifically, tests were performed on the ARM Coretile Express Development Board (TC2). |
186+
| odroid-xu | `src/modules/pmcs/odroid-xu/mchw_odroid_xu.ko` | Specific module for Odroid XU3 and XU4 boards. More information on these boards can be found at [www.hardkernel.com](http://www.hardkernel.com) |
187+
| arm64 | `src/modules/pmcs/arm64/mchw_arm64.ko` | This module has been successfully tested on ARM systems featuring 64-bit big.LITTLE processors, which combine ARM Cortex A57 cores with and ARM Cortex A53 cores. Specifically, tests were performed on the ARM Juno Development Board. |
188+
| xeon-phi | `src/modules/pmcs/xeon-phi/mchw_phi.ko` | Intel Xeon Phi Coprocessor |
189+
| core2 | `src/modules/pmcs/phi/mchw_core2.ko` | This module has been specifically designed for the Intel QuickIA prototype system. The Intel QuickIA is a dual-socket asymmetric multicore system that features a quad-core Intel Xeon E5450 processor and a dual-core Intel Atom N330. The module also works with Intel Atom processors as well as "old" Intel multicore processors, such as the Intel Core 2 Duo. Nevertheless, given the numerous existing hacks for the QuickIA in this module, users are advised to use the more general "intel-core" flavor. |
190+
| perf | `src/modules/pmcs/perf/mchw_perf.ko` | Experimental backend that uses Perf Events's kernel API to access performance monitoring counters |
186191

187192

188193
Once the most suitable kernel model for the system has been identified, the module can be loaded in the running PMCTrack-enabled kernel as follows:
@@ -408,7 +413,7 @@ The `pmc-events` command can be used to list the virtual counters exported by th
408413

409414
$ pmc-events -V
410415
[Virtual counters]
411-
416+
412417
energy_pkg
413418
energy_dram
414419

bin/pmc-metric

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ def parse_pmctrack_output(infile,outfile,metrics,bypass,verbose,acum_mode,csv_mo
226226
try:
227227
metric_val=eval(expr,counts)
228228
if len(expr.co_names)==1: ## Only one variable
229-
metric_val=metric_val/nr_samples
229+
if not name.startswith("energy"):
230+
metric_val=metric_val/nr_samples
230231
except ZeroDivisionError:
231232
metric_val=0.0
232233
counts[name]=metric_val ## Evaluate recursive metrics

bin/pmctrack-manager

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ function update_compatible_modules(){
107107
local vendor_str=$1
108108
local bitw=$2
109109
if [ "$vendor_str" == "Intel" ]; then
110-
compatible_modules=(intel-core core2)
111-
module_names=(mchw_intel_core mchw_core2)
110+
compatible_modules=(intel-core core2 perf)
111+
module_names=(mchw_intel_core mchw_core2 mchw_perf)
112112
elif [ "$vendor_str" == "AMD" ]; then
113113
compatible_modules=(amd)
114114
module_names=(mchw_amd.ko)

etc/events/armv8.cortex_a73.csv

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
event_name,subevent_name,event_code,description,flags
2+
cycles_allmodes,-,-,-,type=fixed;pmc=0
3+
cycles,-,0x11,-,-
4+
instr,-,0x8,-,-
5+
instr_arch_executed,-,0x8,-,-
6+
l2_cache_accesses,-,0x16,-,-
7+
l2_cache_refills,-,0x17,-,-
8+
l2_cache_writebacks,-,0x18,-,-
9+
l1_data_refills,-,0x03,-,-
10+
l1_data_accesses,-,0x04,-,-
11+
llc_accesses,-,0x16,-,-
12+
llc_references,-,0x16,-,-
13+
llc_misses,-,0x17,-,-
14+
data_read_retired,-,0x66,-,-
15+
data_write_retired,-,0x67,-,-
16+
l1_instr_refills,-,0x1,-,-
17+
itlb_misses,-,0x2,-,-
18+
dtlb_misses,-,0x5,-,-
19+
mispred_branches,-,0x10,-,-
20+
inmediate_branches_retired,-,0x0d,-,-
21+
potentially_predicted_branches,-,0x12,-,-
22+
bus_accesses,-,0x19,-,-
23+
data_mem_access,-,0x13,-,-
24+
instr_cache_access,-,0x14,-,-
25+
data_cache_eviction,-,0x15,-,-
26+
instr_spec_executed,-,0x1b,-,-
27+
bus_read_accesses,-,0x60,-,-
28+
bus_write_accesses,-,0x61,-,-
29+
ld_spec,-,0x70,Instruction speculatively executed. load,-
30+
st_spec,-,0x71,Instruction speculatively executed. store,-
31+
ldst_spec,-,0x72,Instruction speculatively executed. load/store,-
32+
dp_spec,-,0x73,Instruction speculatively executed. integer/data processing,-
33+
ase_spec,-,0x74,Instruction speculatively executed. advanced SIMD extension,-
34+
vfp_spec,-,0x75,Instruction speculatively executed. floating point extension,-
35+
br_indirect_spec,-,0x7a,Branch speculatively executed. indirect branch,-

etc/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0
1+
1.5

src/cmdtools/pmctrack/pmctrack.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ struct options {
8989
int timeout_secs;
9090
int msecs;
9191
int max_samples;
92+
int max_ebs_samples;
9293
int kernel_buffer_size;
9394
unsigned long cpumask;
9495
int optind;
@@ -303,9 +304,8 @@ static void print_process_statistics(FILE* fout,
303304
if (opt->flags & CMD_FLAG_SHOW_TIME_SECS) {
304305
fprintf (fout, "real\t%ld.%02ld\n",
305306
end->tv_sec,
306-
end->tv_usec / 10000);
307-
}
308-
else {
307+
end->tv_usec / 10000);
308+
} else {
309309
if (end->tv_sec >= 3600)
310310
fprintf (fout, "real\t%ld:%02ld:%02ld\n", /* Format: H:M:S */
311311
end->tv_sec / 3600,
@@ -316,7 +316,7 @@ static void print_process_statistics(FILE* fout,
316316
end->tv_sec / 60,
317317
end->tv_sec % 60,
318318
end->tv_usec / 10000);
319-
}
319+
}
320320

321321
/* User time. */
322322
fprintf (fout, "user\t%ld.%02ld\n",
@@ -498,7 +498,7 @@ static void monitoring_counters(struct options* opts,int optind,char** argv)
498498
if(pid == -1) {
499499
err(1,"Error forking process.");
500500
} else if(pid == 0) {
501-
// CHILD CODE:
501+
// CHILD CODE:
502502
if (restore_signal_handlers())
503503
exit(1);
504504

@@ -509,6 +509,9 @@ static void monitoring_counters(struct options* opts,int optind,char** argv)
509509
if (opts->kernel_buffer_size!=-1 && pmct_set_kernel_buffer_size(opts->kernel_buffer_size))
510510
pmctrack_exit(1);
511511

512+
if (opts->max_ebs_samples>0)
513+
pmct_config_max_ebs_samples(opts->max_ebs_samples);
514+
512515
/* Configure counters if there is something to configure */
513516
if (opts->strcfg[0] && pmct_config_counters((const char**)opts->strcfg,0))
514517
pmctrack_exit(1);
@@ -644,7 +647,7 @@ void monitoring_counters_syswide(struct options* opts,int optind,char** argv)
644647
} else if(pid == 0) {
645648
// CHILD CODE:
646649
if (restore_signal_handlers())
647-
exit(1);
650+
exit(1);
648651

649652
/* Bind first */
650653
bind_process_cpumask(getpid(),opts->cpumask);
@@ -1122,6 +1125,7 @@ void init_options( struct options* opts)
11221125

11231126
opts->cpumask = NO_CPU_BINDING;
11241127
opts->max_samples = -1;
1128+
opts->max_ebs_samples= -1;
11251129
opts->flags=0;
11261130
opts->target_pid=-1;
11271131
opts->kernel_buffer_size = -1;
@@ -1238,7 +1242,7 @@ static void usage(const char* program_name,int status)
12381242
printf ("\n\t-n\t<max-samples>\n\t\tRun command until a given number of samples are collected");
12391243
printf ("\n\t-N\t<secs>\n\t\tRun command for secs seconds only");
12401244
printf ("\n\t-e\n\t\tEnable extended output");
1241-
printf ("\n\t-E\n\t\tShow additional column with elapsed time between samples");
1245+
printf ("\n\t-E\n\t\tShow additional column with elapsed time between samples");
12421246
printf ("\n\t-A\n\t\tEnable aggregate count mode");
12431247
printf ("\n\t-k\t<kernel_buffer_size>\n\t\tSpecify the size of the kernel buffer used for the PMC samples");
12441248
printf ("\n\t-b\t<cpu or mask>\n\t\tbind monitor program to the specified cpu o cpumask.");
@@ -1247,8 +1251,9 @@ static void usage(const char* program_name,int status)
12471251
printf ("\n\t-P\t<pmu>\n\t\tSpecify the PMU id to use for the event configuration");
12481252
printf ("\n\t-L\n\t\tLegacy-mode: do not show counter-to-event mapping");
12491253
printf ("\n\t-t\n\t\tShow real, user and sys time of child process");
1250-
printf ("\n\t-st\n\t\tDisplay real time in seconds (when -t option is enabled)");
1254+
printf ("\n\t-st\n\t\tDisplay real time in seconds (when -t option is enabled)");
12511255
printf ("\n\t-p\t<pid>\n\t\tAttach to existing process with given pid");
1256+
printf ("\n\t-K\t<nsamples>\n\t\tSetup maximum number of samples (in EBS mode) that the application will actually execute");
12521257
printf ("\nPROG + ARGS:\n\t\tCommand line for the program to be monitored.\n");
12531258
break;
12541259
case -2:
@@ -1278,7 +1283,7 @@ int main(int argc, char *argv[])
12781283
usage(argv[0],0);
12791284

12801285
/* Process command-line options ... */
1281-
while ((optc = getopt(argc, argv, "+hc:T:o:b:n:V:B:eAk:SrP:LtN:p:sE")) != (char)-1) {
1286+
while ((optc = getopt(argc, argv, "+hc:T:o:b:n:V:B:eAk:SrP:LtN:p:sEK:")) != (char)-1) {
12821287
switch (optc) {
12831288
case 'o':
12841289
if((fo = fopen(optarg, "w")) == NULL)
@@ -1343,7 +1348,10 @@ int main(int argc, char *argv[])
13431348
break;
13441349
case 'E':
13451350
opts.flags|=CMD_FLAG_SHOW_ELAPSED_TIME;
1346-
break;
1351+
break;
1352+
case 'K':
1353+
opts.max_ebs_samples=atoi(optarg);
1354+
break;
13471355
default:
13481356
fprintf(stderr, "Wrong option: %c\n", optc);
13491357
exit(1);

0 commit comments

Comments
 (0)