Problem 1: Performance
tomato: slt $t0, $al, $a2
beq $t0, $zero, orange
sll $t1, $al, 2
add $tl, $a0, $tl
sll $t2, $a2, 2
add $t2, $a0, $t2
add $t5, $al, $zero
andi $t5, $t5, 1
beq $t5, $zero, lw $t3, 0($t1)
add $t4, $t3, $t3
lw $t3, 0($t2)
lw $t4, 0($t1)
potato: addi $al, $al, 1
addi $a2, $a2, -1
j tomato
orange: 7r Sra
Instruction Type Cycles
Arithmetic 2
Logical 1
Loads 8
Stores 6
Conditional branches 3
Unconditional jumps 1
Table 1. Number of clock cycles for each type of instruction
Part (a) Above is the assembly code for the function declared as: tomato(int array[], int x, int y). Assume that myarray is an array of 500 integers, and the function is called as tomato(myarray, 5, 21).
(i) How many times is the slt instruction executed? Justify your answer to receive credit. (6pts)
(ii) How many times is the lw instruction executed? Justify your answer to receive credit. (6 pts)
(iii) How many clock cycles are required to execute the entire function tomato(myarray, 5, 21)? Show your work (6 points)
Part (d) Your manager claims that it is possible to achieve an overall speedup of 2.2x by optimizing the data memory access time. Is this claim correct? If so, how much speedup is necessary for the data memory accesses to achieve an overall speedup of 2.2x? Show your work to get credit. (10 points)