https://github.com/hobywan/wrappi
A profiling library based on PAPI hardware counters targetted for Linux-based multicore compute nodes.
https://github.com/hobywan/wrappi
cpp hpc linux multicore profiling
Last synced: about 1 year ago
JSON representation
A profiling library based on PAPI hardware counters targetted for Linux-based multicore compute nodes.
- Host: GitHub
- URL: https://github.com/hobywan/wrappi
- Owner: hobywan
- License: mit
- Created: 2019-04-10T12:22:47.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-16T12:39:33.000Z (almost 7 years ago)
- Last Synced: 2025-02-04T11:04:47.669Z (about 1 year ago)
- Topics: cpp, hpc, linux, multicore, profiling
- Language: C++
- Homepage:
- Size: 147 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

**wrappi** is a C++ library for core events profiling based on [PAPI](http://icl.utk.edu/papi/) hardware counters.
It is targetted for multicore and [manycore](https://en.wikipedia.org/wiki/Manycore_processor) compute nodes endowed with a Linux kernel.
It provides a simple and clean interface to retrieve:
* core cycles,
* cache hits/misses ratios,
* branch prediction,
* [translation lookaside buffer](https://en.wikipedia.org/wiki/Translation_lookaside_buffer) misses,
* instructions load/store.
on a given **section** of the code, or for a **set** of compute kernels.
[](https://travis-ci.com/hobywan/wrappi)
[](https://www.codacy.com?utm_source=github.com&utm_medium=referral&utm_content=hobywan/wrappi&utm_campaign=Badge_Grade)
[](https://opensource.org/licenses/MIT)
### Build and use
###### Build
**wrappi** is almost standalone.
It requires a [C++14](https://isocpp.org/wiki/faq/cpp14-language) compiler endowed with [OpenMP](https://www.openmp.org).
It can be built on any Linux distribution with [PAPI](http://icl.utk.edu/papi/) installed, using [CMake](https://cmake.org):
``` bash
mkdir build # out-of-source build recommended
cd build #
cmake .. # CMAKE_BUILD_TYPE=[Debug|Release]
make -j4 # use multiple jobs for compilation
make install # optional, can use a prefix
```
###### Linking to your project
**wrappi** is exported as a package.
To enable it, please update your CMakeLists.txt with:
``` cmake
find_package(wrappi) # in build or install tree
target_link_libraries(target PRIVATE wrappi) # replace 'target'
```
And then include `wrappi.h` in your application.
###### Setting thread-core affinity
In a multicore context, you have to explicitly set [thread-core affinity](https://eli.thegreenplace.net/2016/c11-threads-affinity-and-hyperthreading/) before profiling.
Indeed, threads should be bind to physical cores to prevent the OS from migrating them.
Besides, [simultaneous multithreading](https://en.wikipedia.org/wiki/Simultaneous_multithreading) (or hyperthreading on Intel) should be disabled in this case.
It can be done by setting some environment variables:
```bash
export OMP_PLACES=core OMP_PROC_BIND=close # with Gnu or LLVM compiler
export KMP_AFFINITY=[granularity=core,compact] # with Intel compiler
```
###### Basic usage
[](https://www.codacy.com?utm_source=github.com&utm_medium=referral&utm_content=hobywan/wrappi&utm_campaign=Badge_Grade)
**wrappi** was designed with simplicity and ease of use in mind.
It can retrieve stats on each invidual core as well as for all cores.
Here is a basic usage:
``` c++
using namespace wrappi;
Manager profile(Mode::Cache, nb);
for (int i = 0; i < nb; ++i) {
profile.start(i);
kernel[i].run();
profile.stop(i);
}
profile.dump();
```
>You can profile cycles, caches, instructions, [TLB](https://en.wikipedia.org/wiki/Translation_lookaside_buffer), or any event supported by [PAPI](http://icl.utk.edu/papi/) as well.
### Contribute
###### Copyright 2018, Hoby Rakotoarivelo
[](https://opensource.org/licenses/MIT)
**wrappi** extends the initial work of [Sean Chester](https://github.com/sean-chester/papi-wrapper).
Improvements are welcome.
To get involved, you can:
- report bugs or request features by submitting an [issue](https://github.com/hobywan/wrappi/issues).
- submit code contributions using feature branches and [pull requests](https://github.com/hobywan/wrappi/pulls).
Enjoy! 😊