You will be both writing a small amount of code (for Part II), and performing analysis on the results of running code on a machine in the Linux lab (for both Parts I and II). You will have to turn in both the code that you write, and a report summarizing results, by answering the questions in each part.
Using the code in Exercise 5.2 of Hennessy and Patterson, create and run a program on
a Linux lab machine to analyze the size of the caches on the machine. A
file with the code is located here.
Then answer the following questions in a written report:
Use the information you gathered in Part I to evaluate the performance of the
six possible loop orderings for matrix-matrix multiplication. You should
write a function, MM, that performs matrix multiplication on N x N
matrices. The inputs to
your matrix multiplication function are two matrices, A of dimension NxN
and B of dimension NxN, along with N. The output of the function is the NxN matrix
C = A · B. Implement all six variants in the C programming
language, with three levels of manual loop unrolling for each variant - none, 2
and 4 (loop unrolling at level i means i iterations of the loop
are merged into 1 iteration of the unrolled loop). You can assume that N
is divisible by 4. Evaluate the
performance of all the programs (18 in total) for values of N up to 512, for N a power of 2, starting at
16 (i.e. N = 16, 32, 64, ..., 512). Run each variant multiple
times to be sure you get consistent timings (i.e. throw out outliers, and
average the run times for a given variant).
The matrix entries should have type double. You can fill in the
matrix entries however you want (but don't make them all the same). The
overall idea is to
determine which variations work best for which values of N, and why.
Write up the results of your program, including:
You must run your code on the CSIC Linux cluster, available via ssh at linuxlab.csic.cs.umd.edu (that IP address corresponds to the remote login server machines), so that's where you should do your development work and run the programs. More information about the lab is available here. To get accurate timing results, we suggest going to the lab and sitting at one of the machines, so that you are likely to be the only user on the machine. Also, for Part II, the timing routines from Exercise 5.2 for Part I are not accurate enough to time your matrix multiply programs. For more accurate timing routines, look at the man page for the gettimeofday() C library function.
Submission will be handled using the submit program, located in ~cs411001/bin, as project 1 (i.e. submit 1 *.c *.h report.pdf). Submit all the code you ran (but not the code from Exercise 5.2), and a file with the documentation in Word, Postscript, or PDF format. You don't need to tar or compress your files - the submit program does that for you.