Systems and low latency
Walking a matrix through the cache, part 1 of 3
Walking a matrix through the cache · Part 1 of 3
A 1,024 × 1,024 matrix of float64 is stored row-major (C order), starting on a cache-line boundary. A cache line is 64 bytes, and at the start none of the matrix is cached. The cache holds 512 lines, far fewer than the matrix needs, and evicts the least recently used line.
You sum the matrix row by row. How many cache lines are loaded from memory?
Answer with a number. Fractions, powers and expressions like 23/6 or C(52,5) are read correctly in practice.
The worked solution is in Premium
The answer, the full working and the one idea to take away – for this and all 1,322 questions in the bank. Answer it in practice and your working is marked, with a known mistake named when you make one.
Report an issue with this question
Learn the method
More systems and low latency questions
- A single scan reads 1 GB from main memory at a sustained 20 GB/s.Foundation · Premium
- Traversing a linked list and traversing an array are both O(n).Applied · Premium
- An L1 data cache holds 32 KB. How many float64 values fit in it?Applied · Premium
- A loop executes 10⁸ data-dependent branches, half of them mispredicted, each…Applied · Premium
- A hot loop reads only the price field of a million order records, each record…Applied · Premium
- A burst on the feed, part 2 of 4Applied · Premium