for(i = 0; i < 100; i++)
{
sum+=A[i];
}
$s0 = &A
$v0 = sum correct answers add $t0, $t0, $zero #let i = 0
addi $t1, $zero, 100 #temp = 100
LOOP: lw $t3, 0($s0) #temp1 = A[i]
add $v0, $v0, $t3 #sum += temp1
addi $s0, $s0, 4 #addr of A[i+1]
addi $t0, $t0, 1 #i = i+1
bne $t1, $t0, LOOP #if i < 100
To implement the following C code, what are the
instructions that we should put in the box?
for(i = 0; i < 100; i++)
A[i] = i;
add $t0, $zero, $zero
addi $t1, $zero, 100
LOOP: ??
??
addi $t0, $t0, 1
beq $t0, $t1, LOOP correct answers sw $t0, 0($s2)
,addi $s2, $s2, 4
Which of the following is NOT correct about these two
ISAs?
A. x86 provides more instructions than MIPS
B. x86 usually needs more instructions to express a program
C. An x86 instruction may access memory for 3 times
D. An x86 instruction may be shorter than a MIPS instruction
E. An x86 instruction may be longer than a MIPS instruction correct answers B. x86 usually
needs more instructions to express a program
Assume that we have an application composed with a total of 500000
instructions, in which 20% of them are the load/store instructions with an
average CPI of 6 cycles, and the rest instructions are integer instructions
with average CPI of 1 cycle. If the processor runs at 1GHz, how long is
the execution time?
A. 500000 ns
B. 1000000 ns
C. 1750000 ns
D. 3500000 ns
E. None of the above
500000 correct answers B. 1000000 ns
500000 * (0.8*1+0.2*6) * 1 ns = 1000000 ns
http://cseweb.ucsd.edu/classes/su12/cse141-a/slides/Performance_20120809.pdf
, • Assume that we have an application composed with a total of 500000
instructions, in which 20% of them are the load/store instructions with
an average CPI of 6 cycles, and the rest instructions are integer
instructions with average CPI of 1 cycle.
• If we double the clock rate to be 2GHz without improve the
memory latency, the average CPI for load/store instruction will also
be doubled to 12 cycles. What's the performance improvement after
this change?
A. No change
B. 1.25
C. 1.5
D. 2
E. None of the above correct answers B. 1.25
ETnew = 500000 * (0.8*1+0.2*12) * 0.5 ns = 800000 ns
Speedup = ETold/ETnew=1000000/800000 = 1.25
http://cseweb.ucsd.edu/classes/su12/cse141-a/slides/Performance_20120809.pdf
Why does an Intel Core i7 @ 2.8 GHz usually
perform better than an Intel Core 2 Extreme @ 3.2
GHz or AMD Phenom II X4@3.4GHz?
A. Because the instruction count of the program are different
B. Because the clock rate of Phenom II is higher
C. Because the CPI of Core i7 is better
D. Because the clock rate of Phenom II is higher and CPI of Core i7 is better
E. None of the above correct answers C. Because the CPI of Core i7 is better