Suppose we want to fetch a value from an array.
In some cases, we know that the data is in data[i].
In other cases, we need to move the index by some offset: i += offset[i]
i = ....
FETCH data[i]; // The result could be here if the offset_shifts is 0
// Or if i is very small (data[i] is in the same cache line & page)
i += offset_shifts[i]; // LLC cache miss (and most probably a TLB miss)
result = data[i]; // LLC cache miss (and most probably a TLB miss),
// unless it is obtained by an earlier FETCH
The benefit that I expect from this trick is that if offset_shifts[i] is small, then it means that there will be no TLB & LLC cache misses, so that those lookups can be done with the overhead of ONE memory lookup (instead of two)
How can I fetch the value of data[i] at the same time that offset_shifts[i] is being fetched from memory? In other words, what is the proper way to implement such a "non-blocking fetch" in C++?