Final Exam Solutions

O n is very large o the loop counter i the array size

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ; 3 (c) For the following C code: for (int i=0; i<N; i++) { a[i] = b[i] + c[i]; d[i] = e[i] + f[i]; } Assume the following: o The arrays are integer arrays, where an integer is 1 word long. o N is very large. o The loop counter i, the array size N, and the base addresses of the six arrays are kept in registers at all times. o The code runs on a machine whose L1 cache is fully associative and consists of four 4 ­word blocks. Name one optimization that would improve both the cache hit rate and the loop overhead of this code. Loop unrolling. (Loop fission improves the hit rate but does not improve the loop overhead.) Show the code after applying this optimization to the extent that cache misses are minimized. You can abbreviate at your own risk – if it’s completely clear what you mean, you’ll get full credit. To maximize the hit rate, we can unroll the loop 4 times. This way, when we miss on array[i] and bring in a 4-word block, we will im...
View Full Document

This note was uploaded on 02/08/2014 for the course CS 351 taught by Professor Dr.suzannerivoire during the Fall '13 term at Sonoma.

Ask a homework question - tutors are online