CSCI 235 — Caching

How to speed up a program

Start with a dot product.

float dotP = 0.0 ;
for (int i=0; i < 1000; ++i) {
  dotP = dotP + X[i] * Y[i] ;
}

Apply the usual tricks.

Still, most of the time will be spending retrieving numbers from the arrays.

Locality in the dot product loop

The memory hierachy

According to the book, access times vary quite a bit. See CMU lecture notes (p 44).

On chip caching

Now let’s look at the design of a typical cache. Start with a quick look at CMU lecture notes on cache memories (pp 3–14) and a longer look at the Intel 486DX homework example.

Buffers — the software cache

Buffering is a technique used to programmers, programming languages, and operating systems to reduce the number of disk access.