CIS 629: Project No.1

The Effect of Cache on Performance

Sameer S. Shende

December 6, 1994

1. The program that creates two n x n matrices (A and B) of random real numbers between 0 and 1 and computes the product (C) is written and is enclosed as Appendix A. It uses dynamic memory allocation (malloc) for creating the matrices and uses ftime and getrusage routines to get the wall clock time and system information respectively.

2. The complexity of the program is O(n^{3}). It requires n^{3} additions and n^{3} multiplications for an nxn matrix. So, it needs to perform 2n^{3} floating point operations for multiplying the two matrices.

3. The table of execution times as a function of matrix size n. This data was obtained by running the program on majestix the multiprocessor server (Sun) in the department. The time taken is reported as the sum of the user time and the system time instead of the wall clock time as a large number of processes running concurrently on the system could give very different timings. The same experiment was also carried out on a Sparcstation ELC (atlantix) in a single use mode. The data set used for this machine was 1 to 100 size of the matrix as the cache size on this machine is very small. Discontinuities were observed at sizes 50 and 60 (Appendix B - additional plots). In this case the wallclock time was measured. The table for majestix is presented on the next page.

Matrix Size Time (u+s) in sec
10  0.27
20  0.2
30  0.59
40  0.41
50  0.56
60  0.83
70  1.17
80  1.77
90  2.36
100  3.23
110  4.27
120  5.36
130  7.12
140  8.75
150  10.61
160  16.18
170  15.56
180  21.63
190  21.59
200  24.47
210  28.61
220  33.59
230  37.18
240  42.71
250  156.27
260  55.47
270  66.67
280  71.91
290  259.83
300  126.41

4. The data is plotted with gnuplot. The entries in the table do agree with the predicted performance. For e.g., the time for 100x100 matrix is 3.4 sec and for 200x200 matrix the predicted value should be 8 times the previous value or 24.84sec. The actual value obtained is 24.47 which is close enough.

5. From the plot one can see that a discontinuity is observed at 250 matrix size. At this point the matrices become large enough so as not to fit into the matrix.