Skip to content

Cache Associativity - Incomplete explanation is maybe misleading #340

Open
@ttmx

Description

@ttmx

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions