For a tree layout using cache line reading _next_ cacheline ( reading _next_ cacheline cheap), I need to quickly resolve the address layout. I was able to solve this problem:
newIndex = nowIndex + 1 + (localChildIndex*X)
x will be, for example: X = 4 5 + 4 4 + 4 3 + 4 2 +4, 0 .
Note: 4 - branching coefficient. In reality it will be 16, so that is power 2. Should it be useful to use bitwise things?
It would be very bad if we needed a loop to compute X ( performancewise ), etc. like division / multiplication. This attracts an interesting problem, and I could not come up with any good way to calculate it.
With its part of tree traversal, 2 modes are possible: absolute calculation, regardless of previous calculations, and incremental calculation, which begins with the fact that high X is stored in a variable, and then some minimal things done with it at each deeper level of the tree.
Hopefully I was able to clarify what mathematics should do. Not sure if there is a way to do this quickly and without a loop - but maybe someone can come up with a really smart solution. I would like to thank everyone for their help - StackOverflow has been a great teacher for me in the past, and I hope that I can return more in the future as my knowledge grows.
source share