I'm trying to figure out what would be the best approach to benchmark C++ programs and would like to simulate both the scenario when the data related to the benchmarked section is present in the cache and when it's cold.
Is there a reliable way to enforce good and bad cache locality on x86-64 machines as a form of preparation for a test run, assuming the data it will involve is known?