|
|
|
|
|
by bananaface
2172 days ago
|
|
Ok turns out I was way off, it's actually completely broken. Just ran the code, printed j at each index. >>> main(20) 2 4 8 16 12 4 8 16 12 4 8 16 12 4 8 16 12 4 8 16 It's not even hitting odd indexes. Over half the array will be garbage at the end. I guess that would count as out-of-order though. |
|
For what it really is - powers of 2 mod NUMBER - when NUMBER is large most reads should be out of the cache. So the first example has to read from main memory only every 64th index, and the second example has to read from main memory on almost every read. I think this agrees with what you are saying. This also explains why it is ~5x slower, which seemed too large from my previous understanding.