Question: (25 points) Performance of a MIPS program (The following code fragment processes two single-precision floating-point arrays A and B , and modifies the array B

(25 points) Performance of a MIPS program

(The following code fragment processes two single-precision floating-point arrays A and B, and modifies the array B.

Each array consists of 500 single-precision floats.

The addresses of A and B are stored in $a0 and $a1 respectively.

Note that there is an outer loop and an inner loop in the MIPS assembly language code.

(Say thank you! you dont have to write these MIPS codes)

li

move

$a2, 500

$t0, $a0

#

#

$a2 = 500

$t0 = address of array A

move

$t4, $zero

#

$t4 = 0

mtc1

$zero, $f4

#

$f4 = 0 (move to coprocessor 1)

outer:

lwc1

$f0, ($t0)

# #

outer loop

load single-precision float

add.s

move

$f4, $f4, $f0

$t1, $a1

#

$t1 = address of Array B

move

$t5, $zero

#

$t5 = 0

inner:

lwc1

$f1, ($t1)

# #

inner loop

load single-precision float

mul.s

div.s swc1 addi addi bne

$f2, $f1, $f0

$f3, $f2, $f4

$f3, ($t1)

$t1, $t1, 4

$t5, $t5, 1

$t5, $a2, inner

#

#

store single-precision float

end of inner loop

addi addi bne

$t0, $t0, 4

$t4, $t4, 1

$t4, $a2, outer

#

end of outer loop

The above code is executed on a processor with a 2 GHz clock that requires the following number of cycles for each instruction:

Instructions

Cycles

Li, move, mtc1, addi

3

Lwc1, swc1

5

Add.s, mul.s

10

div.s

20

bne

4

(5 pts) Count the total number of instructions executed by the above code fragment, including those executed outside the outer loop.

(8 pts) How many cycles does it take to execute the above code?

(4 pts) What is the execution time in nanoseconds?

(4 pts) What is the average CPI for the above code?

(4 pts) What is the MIPS rate for the above code?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!