Sie sind auf Seite 1von 2

CSCE 231 Computer Organization and Assembly Language Programming

Spring 2012

Project 2: Cache Performance

1. Introduction
1.2 MARS Data Cache Simulator Tool
1. Open the program row-major.asm. This program will traverse a 16 by 16 element integer matrix in row-
major order, assigning elements the values 0 through 255 in order. It performs the following algorithm:
for (row = 0; row < 16; row++)
for (col = 0; col < 16; col++)
data[row][col] = value++;
2. Assemble the program.
3. 3. From the Tools menu, select Data Cache Simulator. A new frame will appear in the middle of the
screen. This is a MARS Tool that will simulate the use and performance of cache memory when the
underlying MIPS program executes.

Notice its three major sections
Cache Organization: You can use the combo boxes to specify how the cache will be configured for
this run. Feel free to explore the different settings, but the default is fine for now.
Cache Performance: With each memory access during program execution, the simulator will
determine whether or not that access can be satisfied from cache and update the performance display
accordingly.
Tool Control: These buttons perform generic control functions as described by their labels.
4. Click the tool's Connect to MIPS button. This causes the tool to register as an observer of MIPS memory
and thus respond during program execution.
5. Back in MARS, adjust the Run Speed slider to 30 instructions per second. It is located at the right side of
the toolbar. This slows execution so you can watch the Cache Performance animation.
6. In MARS, run the program using the Run toolbar button, the menu item or keyboard shortcut. Watch
the Cache Performance animate as it is updated with every access to MIPS memory.
7. Observe the cache Hit Rate

1.2 Matrix Multiplication
If you recall, matrices are 2-dimensional data structures wherein each data element is accessed via two
indices. To multiply two matrices, we can simply use 3 nested loops, assuming that matrices A, B, and C are
all n-by-n and stored in one-dimensional column-major arrays (i.e., the single dimensional array stores the
first column followed by the 2
nd
column, etc):
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
for (int k = 0; k < n; k++)
C[i+j*n] += A[i+k*n] * B[k+j*n];
Matrix multiplication operations are at the heart of many linear algebra algorithms, and efficient matrix
multiplication is critical for many applications within the applied sciences.
2. Requirements
1) Develop a MIPS assembly program that implements a multiplication algorithm similar to that in
section 1.2; but, assuming that the matrices are stored in one-dimensional row-major arrays. Verify
the algorithm by running it using test data (for example, set n=3, fill matrix A & matrix B with some
data, do the matrix multiplication by hand then compare the results you obtained by hand vs. the
result you obtained from running your program). [30%]
2) Assume that the cache size is 1024 bytes (1KB) and n=1000. Optimize the cache parameters to get
the best hit ratio for your implementation in Section 2.1. [30%]
3) Find the minimum cache size and its parameters that give the best hit ratio for n=1000. [40%]

3. Guidelines
1. Work in a group of 2 or 3 students.
2. You need to submit your work (source code and a report) to mai.said88@live.com before May 12,
2012 11:59PM.
3. In your report you need to address the last 2 requirements and you have to validate your
conclusion(s).

Das könnte Ihnen auch gefallen