Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CS10 – Lab 6, Introduction to MARS and MIPS

Caches & Associativity

Requirements

1.   Mac, Windows or Linux PC

2.   Java standard edition (SE) version 9 or higher.

3.   MARS Java program

Introduction

We learned in class that since matrix multiply accesses both the columns and rows of a matrix, that one or the other will not fit nicely into our caches; that is, either the stride of the rows or the stride of the columns will be big and therefore will have poor locality.

We want to use the MARS cache simulator (under tools tab) to show that we can improve the performance of caches by:

1)  Increasing their associativity

2)  By modifying our program to fit better in the cache.

 

 

Exercise 1

1.   Make a copy of lab 4 and save as Lab 6” .

2.   Change your program to use 8x8 matrices.

3.   Don’t read in the matrices, just initialize them in the array declarations.

4.   Run it with a cache containing 64 words direct mapped.

5.   Then run it with 64 words 2-way set associative.

6.   Change the cache size and/or block size if necessary, so that when you change the associativity between runs that the performance improves (lower miss rate). Don’t change the size – keep the total cache size  the same!

Exercise 2

1.   Block your matrix multiply routine to do the 8x8 multiply using blocking with four 4x4 matrices (4x4 blocks).

Stated mathematically,

For A, B and C matrices,

First compute C = A*B and compare the performance for direct-mapped and 2-way set associative caches, then using a 4x4 block size, compute:

A1 | A2       B1 | B2      C1 | C2

--------  *   --------  =  -------- = C

A3 | A4       B3 | B4      C3 | C4

A1, A2, B1,… are 4x4 matrices

2.   Using the same cache size that you used in exercise 1, again, compare the result using direct-mapped and 2-way set associative. Change the cache size and/or block size if necessary, so that the result improves after blocking.

3.   Comment on the results.

4.   Upload the program and include in the comments the cache parameters you used so that your results can be recreated.