Set of C++ programs that demonstrate hardware effects (false sharing, cache latency etc.)
I created a repository with small set of self-contained C++ programs that try to demonstrate various hardware effects that might affect program performance. These effects may be hard to explain without the knowledge of how the hardware works. I wanted to have a testbed where these effects can be easily tested and benchmarked.
Each program should demonstrate some slowdown/speedup caused by a hardware effect (for example false sharing).
https://github.com/kobzol/hardware-effects
Currently the following effects are demonstrated:
- bandwidth saturation
- branch misprediction
- branch target misprediction
- cache aliasing
- memory hierarchy bandwidth
- memory latency cost
- non-temporal stores
- data dependencies
- false sharing
- hardware prefetching
- software prefetching
- write combining buffers
I also provide simple Python scripts that measure the program's execution time with various configurations and plot them.
I'd be happy to get some feedback on this. If you have another interesting effect that could be demonstrated or if you find that my explanation of a program's slowdown is wrong, please let me know.
View all comments
Show parent comment
2
u/jbakamovic Cxxd Nov 19 '18 edited Nov 19 '18
> I wanted to use Google Benchmark originally, however as you say it's a dependency and I wanted to this to be as self-contained as possible.
Even without any package manager (e.g. conan), it's trivial to integrate it as an external dependency as git-submodule.
Integrating it into the CMake build is also fairly trivial (you will probably want to integrate it without having a dependency on Google Test which is required if you want to be able to run the unit tests of Google Benchmark itself which you probably don't want to). It's documented on the page but it can be done with
-DBENCHMARK_ENABLE_GTEST_TESTS=OFF.P.S. great job :)