Let's say I have a C++ class whose implementation looks something like this:
// ...
MyClass::iterativeFunction() {
for (int i = 0; i < 1000000; i++) {
performAction(i);
}
}
MyClass::performAction(int index) {
// Block of code (non-inline-able)
}
// ...
At the C++ level, do I have any control over the spacial locality of these methods, or do I just have to hope the compiler will notice the related methods and optimise its assembly accordingly? Ideally I would like them to be right next to each other so they will be loaded into the instruction cache together, but I have no idea how to let the compiler know I'd really like this to happen.