algorithmica icon indicating copy to clipboard operation
algorithmica copied to clipboard

Cache Associativity - Incomplete explanation is maybe misleading

Open ttmx opened this issue 8 months ago • 0 comments

https://en.algorithmica.org/hpc/cpu-cache/associativity/

The section does not specify that this slowdown only occurs when iterating the array multiple times, leading to confusion, and perhaps believing that a single iteration of an array also suffers of some unspecific cache thrashing slowdown? In my cpu it seems to only exhibit a difference between the two loops when I do a few full iterations of each, not if I allocate a fresh array for each loop.

I suggest changing the loops to the following, in order to prevent confusion.

for (int j = 0; j < K; j++) 
    for (int i = 0; i < N; i += {256,257})
        a[i]++;

Thank you for the truly great resource that is this book!

ttmx avatar May 06 '25 03:05 ttmx