Cache Lines, Locality, and Reuse
Count cache-line transfers for sequential and strided accesses and distinguish compulsory work from repeated misses.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
A miss normally brings a group of neighboring bytes
Assume aligned 64-byte lines and four-byte elements. Reading 256 consecutive elements uses 16 lines in this simple model. Reading one element from every one of 256 disjoint lines uses 256 line fills without reuse. Both cases execute the same number of logical reads. The difference arises because sequential data reuse the remainder of each fetched line.
Whether a line stays depends on intervening work
A second scan can reuse the first scan’s lines if they fit and do not conflict with other accesses. A footprint too large for the relevant cache, or unfortunate mapping into the same sets, can destroy that benefit. Measurements should say which hierarchy level and event count are being considered. Cache associativity formalizes conflicts. The external-memory model emphasizes block transfers independently of a particular machine.[1][2]