Requirements
CS10 – Lab 5, Introduction to MARS and MIPS
Loop Unroll
1. Mac, Windows or Linux PC
2. Java standard edition (SE) version 9 or higher.
3. MARS Java program
Introduction
In this lab, you will use MARS (MIPS Assembler and Runtime Simulator) to take your previous 4 x 4 matrix multiply program and loop unroll it. You will take the program written for Lab 4 and expand it for this lab. The purpose of this lab is to observe the register pressure caused by loop unrolling and mitigate this pressure with clever coding techniques.
As before, if you have any problems running MARS refer to the instructions in Lab 1.
Exercise 1
1. Make a copy of lab 4 and call it “Lab 5a”.
2. Refresh your memory on how loop unrolls work: https://www.youtube.com/watch?v=hsQj7n-8Q3A
3. Write a program that unrolls the inner loop two times and iterates through it two times.
Exercise 2
1. Make a copy of your program from exercise 1 and call it “Lab 5b”
2. Modify this program so that it is completely unrolled; i.e., there are no iterations of the inner loop.
Turn in two separate programs, one for 5a, and one for 5b.
Make sure to use different registers for each multiply-add and its associated variables so that the computations (multiply-adds) could all be done in parallel if sufficient hardware resources were available (that is one of the primary reasons for unrolling, the other being to eliminate some of the loop overhead – branches and counters).
In your comments, compare the program length, register usage and conceptual complexity.
Tom Riordan Page 1 of 1 Revised Jan 2020