In this project, our objective is to determine the CPI (Cycles Per Instruction) stack by leveraging Hardware Performance Counters in conjunction with Linear Regression.
In this project, we employed SPEC CPU 2017 as the benchmark suite for our performance evaluation. SPEC CPU 2017 is a comprehensive collection of benchmarks developed by the Standard Performance Evaluation Corporation (SPEC), designed to rigorously assess and measure various aspects of a computer system's performance, with a particular focus on CPU (Central Processing Unit) performance. By utilizing this benchmark suite, we were able to conduct a thorough evaluation of the system's capabilities, covering areas such as integer and floating-point computation, memory access, and other critical aspects.
In our project, we utilized 'perf' to access hardware counters and gather performance-related data for analysis.
perf is a Linux command-line tool that provides performance monitoring and profiling capabilities, allowing users to analyze system and application performance by collecting and displaying a wide range of performance-related data. It can be used to investigate CPU, memory, and other resource usage for optimizing software and diagnosing performance issues.
To install perf use following command:
apt-get install linux-tools-common linux-tools-generic linux-tools-uname -r
Monitoring CPU Events:
- To monitor CPU events, use the perf stat command followed by the name of the program you want to profile:
perf stat ./myprogram
Profiling Events:
- Use perf record to profile specific events. For example, to profile cache misses:
perf record -e cache-misses ./myprogram
After running perf, you can view the results using the perf report command:
perf report
To generate data point for regression model use following command:
sudo perf stat -o perf_output_XXX_refrate.txt -e cpu-cycles,instructions,branch-misses,cache-misses,L1-dcache-load-misses,L1-icache-load-misses,LLC-load-misses,LLC-store-misses,branch-load-misses,dTLB-load-misses,dTLB-store-misses,iTLB-load-misses,l2_rqsts.code_rd_miss,l2_rqsts.demand_data_rd_miss,l2_rqsts.all_demand_miss -I 300 ./command.sh
This command runs the 'perf' tool with elevated privileges to monitor and collect a comprehensive set of hardware performance statistics. These statistics include events such as CPU cycles, cache misses, branch misses, and various cache and TLB (Translation Lookaside Buffer) misses. The '-o' flag is used to specify that the collected performance data should be saved to a file named 'perf_output_XXX_refrate.txt'. With the '-I' flag, a sampling interval of 300 milliseconds is set, meaning that 'perf' will sample and record performance data at this interval.
Content of command.sh
. /home/sahillathiya/Desktop/Projects/SPEC2017/shrc
runcpu --config=walter-try1.cfg --size=refrate 511 --iteration=3
Before applying linear regression to the data generated by 'perf,' the initial step is to convert the data from its text file format into a more suitable format, specifically a CSV file.
To facilitate this conversion, we utilized the 'Text to CSV.ipynb' file.
For conducting linear regression, we employed the file 'Linear Regression on Perf Dataset using Library.ipynb.' "# CPI_Stack"