Professional Documents
Culture Documents
Instructions
1. This is a closed book online proctored exam.
1. You should not refer to books, notes or online resources.
2. You should not discuss questions or answers with anyone (including
outsiders)
3. You should have your camera and microphone ON at at all times and no
headphones
2. Write the solutions clearly and legibly in A4 sheets, using pen (NOT pencil) and at
the end of the exam you should submit the scanned copy of your solutions as
explained by the faculty
3. Follow all other instructions given by the faculty during the exam
Descriptive Questions
Note: For problems show step-by-step solution
Show what happens in the pipeline during each clock cycle for executing the above code
starting from the first instruction to the last instruction. Also find the total number of
clockcycles needed if each stage takes 1 cycle. Assume:
● The pipeline follows static branch prediction and predicts that the branch will be
taken
● In reality the branch is not taken i.e. the branch prediction is wrong.
(5)
1b. Identify and list all the data dependencies in the following code. Highlight separately the
data hazards that will result in a stall even with forwarding.
SUB $T4,$T3,$T1
ADD $T5,$T4,$T2
ST $T5,100($T4)
LW $T6,200($T5)
SUB $T6,$T6,$T5 (5)
Answer:
SUB $T4,$T3,$T1
ADD $T5,$T4,$T2 //T4 with Sub
ST $T5,100($T4) //T4 with Sub and T5 with add
LW $T6,200($T5) //T5 with add
SUB $T6,$T6,$T5 //T6 with LW and T5 with add
II. If replacing the cache with a 2-way set associative increases the hit
rate to 96%, but increases the hit time to 6 ns, what is the new AMAT?
AMAT = Hit time + Miss rate x Miss penalty
AMAT = 5 + 0.04 x 100 = 09 ns
III. List out any two methods to Improve performance of cache
i. Reduce the miss rate,
ii. Reduce the miss penalty,
iii. Reduce the time to hit in the cache.
(2+2+1)
2b. A computer system has the following cache configuration. It uses 4-bit memory
addresses. It has a 16 bytes cache organized in a direct-mapped manner with 2
bytes/blocks. There are 4 sets and one block per set. The no of bit for tag, set, block
given bellow
Address trace
(reads, one byte per read):
1[0001]
3[0011]
5 [0101]
6 [0110]
7[0111]
8[1000]
Answer:
Address trace
(reads, one byte per Cache status after miss [ Set-No : address
read): Hit/Miss Justification ]
1[0001] Miss Data miss S-0: [0-1]
3[0011] Miss Data miss S-0: [0-1],S-0: [2-3]
5 [0101] Miss Data miss S-0: [0-1],S-1: [2-3], S-2: [4-5]
6 [0110] Miss Data miss S-0: [0-1],S-1: [2-3], S-2: [4-5], S-3: [6-7]
7[0111] Hit Data is at set 3 S-0: [0-1],S-1: [2-3], S-2: [4-5], S-3: [6-7]
8[1000] Miss Data Miss S-0: [8-9],S-1: [2-3], S-2: [4-5], S-3: [6-7]
1. Procedure calls
Example - a procedure call that returns the same value every time but called
multiple times
Use of global variables in procedure.
● Procedure may have side effects
○ Alters global state each time called
● Function may not return same value for given arguments
● Depends on other parts of global state
● Procedure lower could interact with strlen
2. Memory aliasing
Example - where two pointers point to the same memory location and how it
affects the result of calculation.
● Two different memory references specify single location
● Easy to have happen in C
○ Since allowed to do address arithmetic
● Direct access to storage structures
● Get in habit of introducing local variables
● Accumulating within loops