Consider a CPU with cache memory such that access time to the cache memory is , the access time to the main memory is , the time to transfer a word from the main memory to the cache is , and the time to execute a loop when a data is in the cache is . Estimate the average memory access time in calculating the inner product of sufficiently long vectors. Here, the block (line) length of the cache memory is assumed to be .
We calculate the inner product thanks to the following loop
inner_product := 0; for i := 1 to vector_length do begin inner_product := inner_product + vector_1[i] * vector_2[i]; end;and we suppose that the vectors are not in the cache at the beginning, so that the first access to the arrays will be a miss. We denote the length of the vectors by . The first step in the computation will cost