This a benchmark for measuring the performance and profiling C/C++ code. For profiling, it is based on PAPI counters.
- CMake
- C/C++ compiler
- PAPI library is required for profiling, i.e., when
PROFILING_WITH_PAPIis set toONinCMakeLists.txt. PAPI needs paranoid mode to be smaller or equal to 2. You can check the current value withcat /proc/sys/kernel/perf_event_paranoid. And you can set it to 2 withsudo bash -c "echo 2 > /proc/sys/kernel/perf_event_paranoid". - OpenMP is required for profiling, i.e., when
PROFILING_WITH_PAPIis set toONinCMakeLists.txt.
git clone https://github.com/SwiftWare-Lab/benchmark.gitPick one of the following options to build the benchmark.
After installing the requirements, you can build the benchmark with the:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
makeAnd to build with profiling support:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DPROFILING_WITH_PAPI=ON ..
makeFor Niagara, a script is provided to build the benchmark. You can use it as:
./build_bench.shThe script should work for other linux machines as well.
Here we will show how to use the benchmark in your code as a library.
You will first need to add the benchmark to your code base. You can add the repo to your cmakefile similar to the example provided in here.
Then you can follow the example provided in gemvWithPapi to measure the performance of different implementations of gemv.
The output is stored as CSV. You need to write a Python script to analyze the results.
The list of counters is specified in
include/papi_counters.list. Each line
specifies a counter. You can use // to comment out a line.
You can add a new file of performance counters and specify it in by
passing the file name to CMAKE using the COUNTER_FILE variable as
follows:
cmake -DCOUNTER_FILE=your_counter_file.list ..Please provide absolute path to the file. This will work if PAPI profiling is enabled.