Memory Mountain

How do caches improve read throughput?
Measure time of following loop (after running it once to "warm up" the cache) for given values of "size" and "stride" (simplified from BO Fig 6.40):

long data[MAXELTS];
long sum = 0;
int elems = size / sizeof(long);

for (i = 0; i < elems; i += stride) {
    sum += data[i];
}

Memory Mountain from CS:APP, 3nd edition, 2016

Intel Core i7 Haswell


Memory Mountain from CS:APP, 2nd edition, 2010

Intel Core i7
2.67GHz
32KB L1 i/d cache each
256KB L2 cache
8MB L3 cache


Memory Mountain from CS:APP, 1st edition, 2003