Q1: HTC’s VIVE VR headset, comprising two displays for stereo video, has the following specifications:
Solution: 5.5987
Q2: A processor, which has a clock frequency of 1.3GHz, take 10s to run a program of 6×10^9 instructions. What is the average number of cycles per instruction?
Solution: 2.167
Q3: Suppose, for the program in Question 2, the instructions are composed as follows:
We are trying to redesign the processor to increase performance by a factor of 1.25, but this would lead to an increase in the CPI for load/store instructions from 6 to 8. What clock frequency in GHz would be needed for the redesigned processor?
Solution: 1.875
Q4: Instead of trying to increase the performance of the single processor, we can consider using multiple processor cores in a computer. Suppose, for the program in Question 2, parallelizing the program to use p processor cores divides the number of arithmetic/logic instructions by 0.7p, the number of load/store instructions by 0.8p, and the number of branches by 0.9p. What is the minimum number of processor cores required to improve performance by a factor of 3?
Solution: 4
Q5: What is the actual speedup achieved with the number of processor cores you identified in Question 4?
Solution: 3.14
Q6: What RISC-V instruction is encoded by the hex word 0x0051E933?
Solution: or x18, x3, x5
Q7: What hex word encodes the RISC-V instruction ld x9, -24(x10)?
Solution: 0xFE853483
Q8: If x9 initially contains the value 0xC445028461001003, what value (in hex) is placed in x18 by the following instruction?
srai x18, x9, 6?
Solution: 0xFF11140A11840040
Q9: Which of the following RISC-V instruction sequences extracts the 6-bit field from bits 4 to 9 of x10 and places it in the least-significant 6 bits of x7?
Solution: andi x7, x10, 0x3F0
srli x7, x7, 4
Q10: Write RISC-V instructions for the following C statements, assuming a is in x9 and b is in x18:
if (a == b)
a = a + 1;
else
a = a - 1;
Solution: bne x9, x18, L1
addi x9, x9, 1
beq x0, x0, L2
L1: addi x9, x9, -1
L2:
Q11: What C statements are encoded by the following, assuming x10 contains the signed int variable m?
addi x5, x0, 20
bgeu x10, x5, skip
jal x1, my_func
skip:
Solution: if (m >= 0 && m < 20) my_func(m);
Q12: Write RISC-V instructions for the following leaf function:
int min(int a, b) {
return a < b ? a : b;
}
Solution: min: bge x10, x11, L1
add x10, x0, x10
jalr x0, 0(x1)
L1: add x10, x0, x11
jalr x0, 0(x1)
Q13: Write RISC-V instructions for the following recursive function, without eliminating the recursion (i.e., without replacing it by a loop):
int sum(int n) {
if (n == 0)
return 0;
else
return n + sum(n – 1);
}
Solution: sum: addi sp, sp, -16
sd x1, 8(sp)
sd x8, 0(sp)
beq x10, x0, ret
add x8, x0, x10
addi x10, x10, -1
jal x1, sum
add x10, x8, x10
ret: ld x8, 0(sp)
ld x1, 8(sp)
addi sp, sp, 16
jalr x0, 0(x1)
- Resolution: 1080 × 1200 per eye
- Refresh Rate: 90Hz
Solution: 5.5987
Q2: A processor, which has a clock frequency of 1.3GHz, take 10s to run a program of 6×10^9 instructions. What is the average number of cycles per instruction?
Solution: 2.167
Q3: Suppose, for the program in Question 2, the instructions are composed as follows:
Instruction
class
|
Instruction
count
|
CPI
|
Arithmetic/logic
|
4×10^9
|
1
|
Load/store
|
1×10^9
|
6
|
Branch
|
1×10^9
|
3
|
Solution: 1.875
Q4: Instead of trying to increase the performance of the single processor, we can consider using multiple processor cores in a computer. Suppose, for the program in Question 2, parallelizing the program to use p processor cores divides the number of arithmetic/logic instructions by 0.7p, the number of load/store instructions by 0.8p, and the number of branches by 0.9p. What is the minimum number of processor cores required to improve performance by a factor of 3?
Solution: 4
Q5: What is the actual speedup achieved with the number of processor cores you identified in Question 4?
Solution: 3.14
Q6: What RISC-V instruction is encoded by the hex word 0x0051E933?
Solution: or x18, x3, x5
Q7: What hex word encodes the RISC-V instruction ld x9, -24(x10)?
Solution: 0xFE853483
Q8: If x9 initially contains the value 0xC445028461001003, what value (in hex) is placed in x18 by the following instruction?
srai x18, x9, 6?
Solution: 0xFF11140A11840040
Q9: Which of the following RISC-V instruction sequences extracts the 6-bit field from bits 4 to 9 of x10 and places it in the least-significant 6 bits of x7?
Solution: andi x7, x10, 0x3F0
srli x7, x7, 4
Q10: Write RISC-V instructions for the following C statements, assuming a is in x9 and b is in x18:
if (a == b)
a = a + 1;
else
a = a - 1;
Solution: bne x9, x18, L1
addi x9, x9, 1
beq x0, x0, L2
L1: addi x9, x9, -1
L2:
Q11: What C statements are encoded by the following, assuming x10 contains the signed int variable m?
addi x5, x0, 20
bgeu x10, x5, skip
jal x1, my_func
skip:
Solution: if (m >= 0 && m < 20) my_func(m);
Q12: Write RISC-V instructions for the following leaf function:
int min(int a, b) {
return a < b ? a : b;
}
Solution: min: bge x10, x11, L1
add x10, x0, x10
jalr x0, 0(x1)
L1: add x10, x0, x11
jalr x0, 0(x1)
Q13: Write RISC-V instructions for the following recursive function, without eliminating the recursion (i.e., without replacing it by a loop):
int sum(int n) {
if (n == 0)
return 0;
else
return n + sum(n – 1);
}
Solution: sum: addi sp, sp, -16
sd x1, 8(sp)
sd x8, 0(sp)
beq x10, x0, ret
add x8, x0, x10
addi x10, x10, -1
jal x1, sum
add x10, x8, x10
ret: ld x8, 0(sp)
ld x1, 8(sp)
addi sp, sp, 16
jalr x0, 0(x1)
No comments:
Post a Comment