3 ms·
I believe when traversing memory in a predictable, linear fashion the CPU will prefetch data. I thought the CPUs are smart enough to do that for the more compl
by tcbawo 14y ago
I believe when traversing memory in a predictable, linear fashion the CPU will prefetch data. I thought the CPUs are smart enough to do that for the more complex examples as well, but maybe not for steps of 1024.
- kd0amg 14y agoIntel Core architecture has a stride prefetcher, but it will not prefetch across page boundaries (which you hit pretty often with a 1k step size).
- alexkus 14y agoYou'll hit it every time given a typical x86 4KB page size and a step of 1024*sizeof(double)=8KB. I would guess that the example was explicitly contrived so that prefetching would be useless.
- cperciva 14y agoI would guess that the example was explicitly contrived so that prefetching would be useless. Yes -- even if prefetching could happen, the first function would be faster than the second, but I thought removing the whole issue of prefetching would simplify the question.