Docsity

Computer System Organization - Final Exam Solutions | CS 433, Exams of Computer Architecture and Organization

Partial preview of the text

Download Computer System Organization - Final Exam Solutions | CS 433 and more Exams Computer Architecture and Organization in PDF only on Docsity!

CS433ug Final Exam

Prof Josep Torrellas

May 9, 2007

Time: 2 hours

Name:

Alias:

Instructions:

  1. This is a closed-book, closed-notes examination.
  2. The Exam has 4 Questions. Please budget your time.
  3. Calculators are allowed.
  4. Please write your answers neatly. Good luck!

Problem No. Maxm Points Points Scored 1 60 2 60 3 60 4 60 Total 240

  1. [60 points] Pipelines

A. [40 points] Baseline MIPS Pipeline. Consider the baseline MIPS pipeline, where branches are resolved at the end of the ID stage. Consider the following code.

loop: LD F2, 0(Rx) ; load X(i) MULTD F2,F0,F2 ; aX(i) LD F4,0(Ry) ; load Y(i) ADDD F4,F2,F4 ; aX(i)+Y(i) SD F4,0(Ry) ; store into Y(i) ADDI Rx,Rx,#8 ; increment index to X ADDI Ry,Ry,#8 ; increment index to Y SUB R20,R4,Rx ; compute the bound BNEZ R20,loop ; check if done

i. Unroll the loop 4 times, and schedule the instruction to elim- inate all NOPS. The multiply and add functional units take 4 EX cycles each and are fully pipelined. The branch has 1 delay slot that you need to fill with an instruction. SOLUTION

LD F1 0(Rx) LD F2 8(Rx) LD F3 16(Rx) LD F5 24(Rx) MULTD F1 F0 F MULTD F2 F0 F MULTD F3 F0 F MULTD F5 F0 F LD F6 0(Ry) LD F7 8(Ry) LD F8 16(Ry) LD F9 24(Ry) ADDD F6 F1 F ADDD F7 F2 F ADDD F8 F3 F ADDD F9 F5 F SD F6 0(Ry) SD F7 8(Ry)

iii. When do you normally remove an instruction from the ROB?

iv. What happens when an instruction that is not at the head of the ROB completes? And one that is at the head?

v. What happens when an instruction that is not at the head of the ROB suffers an exception? And one that is at the head?

vi. What happens when an branch instruction that is not at the head of the ROB is mispredicted? And one that is at the head?

  1. [60 points] Multiprocessors

A. [30 points] Coherence Protocols. Consider three caches, each of which can contain only 1 line. Each line is 2 words. Words a and b share the same line, while words x and y share the same line. We want to test which is the best cache coherence protocol: base invalidate, firefly, or the illinois protocol. Fill the following tables with the state of the line in the cache and what line it is, and the number of words transferred in the bus. To compute the number of words, assume that a cache line accounts for 2, a write back accounts for 2, and an invalidate or update accounts for 1. In the figure, 1:Rx means: processor 1 reads variable x. The initial state is that all processors have read a. Please write the state as Sab, meaning, the line is shared and it is the line that contains ab.

Base Invalidate Firefly Illinois Proc1 Proc2 Proc3 Words Proc1 Proc2 Proc3 Words Proc1 Proc2 Proc3 Words

Init Sab Sab Sab 6 Sab Sab Sab 6 VSab VSab VSab 6

1:Rx 2:Wy 3:Wb 3:Ry 1:Ra 2:Rb 3:Wx

B. [10 points] Sharing Patterns Write a small C program where the Illinois protocol does better than the invalidate protocol. Explain why.

C. [20 points] Synchronization

i. How many cycles does this above code take to execute? Solution: Without misses: 8cycles× 16 iterations+8cycles× 16 iterations× 16 iteerations = 128 + 2048 = 2176cycles

Miss penalty: a misses 16/ 4 × 16 = 64 times. b misses 16/ 4 × 16 = 64 times. c misses 16/4 = 4 times. 64 + 64 + 4 = 132 ∗ 25 = 3300

Total Execution time: 2176 + 3300 = 5476 ii. We want to add prefetches to the inner loop to improve perfor- mance. The prefetch instruction takes 4 cycles to execute and the data will be available in the cache 25 cycles after the in- struction completes execution. The format of the instruction is prefetch(arr[index]) where arr[index] is an element in the block of data you want to fetch (just like the homework). Unroll the loop the minimum number of times to elimate cache misses (except on the first iteration of the inner loop). Solution:

for (x = 0; x < 16; x++) { for (j = 0; y < 16; y += 4) { prefetch(a[x][y]); prefetch(b[y]); c[x] += a[x][y] + b[y]; c[x] += a[x][y + 1] + b[y + 1]; c[x] += a[x][y + 2] + b[y + 2]; c[x] += a[x][y + 3] + b[y + 3]; } sum += c[x]; } iii. How many cache misses are there in the unrolled code? Solutions: Answer varies based on students code. For correct solutions its a misses 16 times. b misses 16 times. c misses 16/4 = 4 times. 16 + 16 + 4 = 36 times

B. [20 points] Virtual Memory

Consider this system:

  • 64 KB 2-way associative cache with 64 byte blocks
  • 64 bit Virtual Address
  • 32 bit Physical Address
  • 8 KB page size
  • A fully associative TLB with 128 entries
  • byte addressible i. How many bits are needed for the index and block offset of the cache? Solution: 6 bits for the block, 9 bits for the index. ii. How many bits are the Page offset, Virtual Page Number and Physical Page Number? Solution: Page offset is 13 bits, VPN is 64−13 = 51 bits, PPN is 32−13 = 19 bits. iii. Why is this cache a physically tagged, physically indexed cache? Why is this bad? Why doesn’t this problem occur in a physi- cally tagged, virtually indexed cache? Solution: The number of bits for the page offset is smaller than the num- ber of bits for the block and index so part of the index bits need to come from the PPN. This is bad because we have to wait for the TLB translation before we can do anything. In a physically tagged, virtually indexed cache, the page offset is equal to or larger than the number of bits for the block and index so we can send the page offset bits directly to the cache and begin to lookup the data while the rest of the address is being translated. iv. If we wanted to make this cache physically tagged, virtually indexed without modifying the cache, how could we do this? Solution: We could increase the page size to 32 KB which would make the pageoffset equal to the block offset + index. v. If we wanted to make this cache physically tagged, virtually indexed by modifying the cache without reducing the cache size, how could we do this? Solution: We could increase the associativity to 8 or more to reduce the number of index bits.

C. [20points] Cache Short Answers

i. What are the 2 types of Virtual Memory Systems? Whats the difference between the 2? Which one is more popular and why? Solution: The 2 types are Paged and Segmented. Paged uses fixed sized

(conflict misses). So by the next iteration, the first block is no longer in the cache. b. Suppose we modify the cache by adding a 2 entry fully associative victim cache. Will this improve the performance of this code. Why or why not? Solution: No. The victim cache is too small to cache all the evicted entries, so by the next iteration of the loop, the first block of data will already be evicted from both caches. c. Suppose we want to modify the original cache by increasing set associativity to improve performance. What will we need to increase the associativity to in order to improve performance on this piece of code? Solution:

  1. Each set will need to be able to hold 4 different blocks in order to have the data available for the next iteration.
  2. [60 points] I/O

A. [15 points] Disk Accesses Suppose we have a hard drive with the following specifications Average Seek Time 8 ms Rotation Rate 10000 rpm Transfer Rate 10 MB / s Controller Overhead 1 ms

cylinders 16394

Sector Size 1 KB Sectors / Track 64 i. What is the average time to read or write a single sector? Solution: tsector = AverageSeekT ime+RotationDelay+T ransf erT ime+ Overhead tsector = 8 + 60000/10000 + 1/(10 ∗ 1024) + 1 = 15. 1 ms ii. What is the average time to read or write a entire track on the disk (64 consecutive sectors)? Solution: ttrack = 8s + 60000/10000 + 64/(10 ∗ 1024) + 1 = 21. 25 ms iii. Fragmentation is when parts of the same piece of data (such as files) are stored in different locations on a disk. Many oper- ating systems have tools to reduce file fragmentation and frag- mentation is also considered in file system design. Systems such as databases care a lot about data fragmentation. Why?

More specifically, how is fragmentation bad for a system per- formance? Solution: If a something such as a file is highly fragmented, then the system will need to seek and read from many different locations to read the data whereas if the file was stored in cosecutive sectors we would only need to seek once. The overhead in locating a sector is very high relative to the time it takes to read a sector.

B. [25 points] MTTF Suppose we have a device with the following com- ponents:

  • 1 CPU with a mean time to failure of 100,000 hours
  • 2 RAM modules with a mean time to failure of 50,000 hours
  • 2 hard drives with a mean time to failure of 40,000 hours (no RAID) i. Assuming that component lifetimes are exponentially distributed, what is the mean time to failure of the entire system? You may leave your answer in fractional form. Solution: M T T Fsystem = 1 1 100 , 000 +^

2 50 , 000 +^

2 40 , 000

= 10, 000 hours

ii. Suppose someone proposes replacing the 2 hard drives with 1 larger hard drive. How reliable would the larger drive have to be to be worth the switch? Solution: 2 40 , 000 =^

1 x x > 20 , 000 iii. The mean time to repair a failure is 48 hours. What is the availability of the original system? Solution: M T T F M T T F +M T T R =^

10000 10048 = 0.^995 iv. Now consider the 2 RAM modules only. Suppose the system can still run with 1 working memory module and that we can replace modules while the system is still on. It only takes 1 hour to replace a damaged module. What is the MTTF for the memory? Solution: M T T Fmodules 2 = 50000/2 = 25000hours M T T Fmodules 1 = 50000 M T T Ftotal = 25000 × 50000 = 1, 250 , 000 , 000

C. [20 points] RAID and Short Answer