Docsity

Midterm Exam 2 with Solution - Computer Architecture | CS 3853, Exams of Computer Architecture and Organization

Toggle sidebar
bg1
CS 3853 Midterm Exam 2 Solutions — Spring 2013
1) (4 points) 1 + .08 ×7 = 1.56
2) (5 points) 1 + 1.32 ×.05 ×21 = 1 + 1.386 = 2.386
3) (5 points) Separate caches avoid a structural hazard which occurs on a load or store if there is aunified cache.
4) (8 points, 2 points each)
a) tag index offset
----------------------------------
| 16 | 10 | 6 |
----------------------------------
b) as above with tag of 17 bits and index of 9 bits.
c) as above with tag of 18 bits and index of 8 bits.
d) as above, with no index, just a tag of 26 bits and an offset of6 bits.
5) (2 points) 0x17b456 = [1 0111 1011 0100 0101 0110] = [101111011010001 010110]
so the block address is [101111011010001] = [101 1110 1101 0001] = 0x5ed1 and the offset is [010110] = 0x16
6) (8 points, 2 points each)
a) 0x5ed1 = [101 1110 1101 0001] = [10111 1011010001] os the tag is 0x17 and the block address is 0x2d1.
Compare the tag for block 0x2d1 with 0x17, and if they match, the byte is in this cache block at offset 0x16.
b) The set number is [011010001] = 0xd1 and the tag is [101111] = 0x2f. Compare the 2 tags of set 0xd1 with
0x2f and if either matches, the byte is in the corresponding block at offset 0x16.
c) The set number is [11010001] = 0xd1 and the tag is [1011110] = 0x5e. Compare the 4 tags of set 0xd1 with
0x5e and if any match, the byte is inthe corresponding block at offset 0x16.
d) Compare all of the tags to[101 1110 1101 0001] = 0x5ed1 and if any matches, the byte is in the corrsponding
block at offset 0x16.
7) (11 points)
a) (2 points each) These describe what happens on a write hit. With write-through, any write to the cache is
also done to the memory. With write-back, a write to the cache does not cause a write to memory, but the
entire block is written to memory when it is replaced if it has been modified.
b) (2 points each) These describe what happens on a write miss. With write-allocate, the cache is filled with
the corresponding block, just as with a read. With no-write allocate, a write miss does not load the cache.
c) (3 points) A dirty bit indicates that the block in the cache has been written to. It is useful when write-back
is used so that a replaced block is only written back to memory if it has been modified.
8) (10 points)
virtual address: physical address
page number offset frame number offset
---------------------------- -------------------------------
| 18 | 14 | | 28 | 14 |
---------------------------- -------------------------------
Max memory 242 bytes = 4096 GB
9) (6 points) Access time = L1 hit time + L1 miss rate ×L1 miss penalty
L1 miss penalty = L2 access time = L2 hit time + L2 miss rate ×L2 miss penalty
L2 miss penalty = L3 access time = L3 hit time + L3 miss rate ×L3 miss penalty = 15 ns + .05(60 ns) = 18 ns.
L1 miss penalty = 7 ns + .08(18 ns) = 8.44 ns.
Access time = 1 ns + .15(8.44 ns) = 2.266 ns.
pf2

Partial preview of the text

Download Midterm Exam 2 with Solution - Computer Architecture | CS 3853 and more Exams Computer Architecture and Organization in PDF only on Docsity!

CS 3853 Midterm Exam 2 Solutions — Spring 2013

  1. (4 points) 1 +. 08 × 7 = 1. 56

  2. (5 points) 1 + 1. 32 ×. 05 × 21 = 1 + 1.386 = 2. 386

  3. (5 points) Separate caches avoid a structural hazard which occurs on a load or store if there is a unified cache.

  4. (8 points, 2 points each) a) **tag index offset


| 16 | 10 | 6 | ----------------------------------** b) as above with tag of 17 bits and index of 9 bits. c) as above with tag of 18 bits and index of 8 bits. d) as above, with no index, just a tag of 26 bits and an offset of 6 bits.

  1. (2 points) 0x17b456 = [1 0111 1011 0100 0101 0110] = [101111011010001 010110] so the block address is [101111011010001] = [101 1110 1101 0001] = 0x5ed1 and the offset is [010110] = 0x

  2. (8 points, 2 points each) a) 0x5ed1 = [101 1110 1101 0001] = [10111 1011010001] os the tag is 0x17 and the block address is 0x2d1. Compare the tag for block 0x2d1 with 0x17, and if they match, the byte is in this cache block at offset 0x16. b) The set number is [011010001] = 0xd1 and the tag is [101111] = 0x2f. Compare the 2 tags of set 0xd1 with 0x2f and if either matches, the byte is in the corresponding block at offset 0x16. c) The set number is [11010001] = 0xd1 and the tag is [1011110] = 0x5e. Compare the 4 tags of set 0xd1 with 0x5e and if any match, the byte is in the corresponding block at offset 0x16. d) Compare all of the tags to [101 1110 1101 0001] = 0x5ed1 and if any matches, the byte is in the corrsponding block at offset 0x16.

  3. (11 points) a) (2 points each) These describe what happens on a write hit. With write-through, any write to the cache is also done to the memory. With write-back, a write to the cache does not cause a write to memory, but the entire block is written to memory when it is replaced if it has been modified. b) (2 points each) These describe what happens on a write miss. With write-allocate, the cache is filled with the corresponding block, just as with a read. With no-write allocate, a write miss does not load the cache. c) (3 points) A dirty bit indicates that the block in the cache has been written to. It is useful when write-back is used so that a replaced block is only written back to memory if it has been modified.

  4. (10 points) **virtual address: physical address page number offset frame number offset


| 18 | 14 | | 28 | 14 | ---------------------------- -------------------------------** Max memory 242 bytes = 4096 GB

  1. (6 points) Access time = L1 hit time + L1 miss rate × L1 miss penalty L1 miss penalty = L2 access time = L2 hit time + L2 miss rate × L2 miss penalty L2 miss penalty = L3 access time = L3 hit time + L3 miss rate × L3 miss penalty = 15 ns + .05(60 ns) = 18 ns. L1 miss penalty = 7 ns + .08(18 ns) = 8.44 ns. Access time = 1 ns + .15(8.44 ns) = 2.266 ns.
  1. (8 points) a) A page table is an array of frame numbers indexed by page numbers. A virtual address has two parts, a page number and an offset. A physical address has two parts, a frame number and and offset. The page table is used to convert the page number into a frame number and the offset is copied from the virtual address to the physical address. b) A TLB is a translation lookaside buffer which is a cache for the page table. It is used to speed up address translations because without it a page translation would require a memory access. An entry contains a valid bit, a page number, and a frame number.

  2. (6 points, 2 points each) The offset requires 14 so a page number is 50 bits and a frame number is 26 bits. In each case a TLB entry contains a valit bit, a tag, and a frame number. a) The index is 6 bits, so the tag is 50-6 = 44 bits, for a total of 1+44+26 = 71 bits per entry or 71(64) = 4544 bits total. b) The index is 5 bits, so the tag is 50-5 = 45 bits, for a total of 1+45+26 = 72 bits per entry or 72(64) = 4608 bits total. b) There are no index bits so the tag is 50 bits, for a total of 1+50+26 = 77 bits per entry or 77(64) = 4928 bits total.

  3. (13 points)

a b c d e f g h i j k l m n o p q r

64 48 16 43 5 10 6 43 31 31 512 31 47 27 14 6 27 512

  1. (10 points) a) direct: 30/.55 = 54.5 rounds up to 55 cycles, 4-way: 30/.62 = 48.4 rounds up to 49. b) direct: 1 + 1.35(.07)(55) = 6.1975, 4-way: 1 + 1.35(.06)(49) = 4.9690. c) direct: 6.1975(.55) = 3.4086 ns, 4-way: 4.9690(.62) = 3.0808 ns. The 4-way cache is better because the time per instruction is smaller.

  2. (10 points) a) The index determines where in the cache to look and the tag determines whether the block is in the cache. If the index bits can be determined from the virtual address, the cache is said to be virutally indexed. If the physical address is needed to determine the index, the cache is said to be physically index. Similarly, of the tag bits can be determined by the virtual address, the cache is said to be virtually tagged. Othewise, if the physical address is needed to determine the tag, it is called physically tagged. b) virtaully indexed and physically tagged c) There are two parts to a cache lookup: determining the set of blocks where the item might reside and then checking the tags of those blocks. If the cache is virtually indexed, the first part can be done using only the virtual address so it can be done in parallel with the address translation. d) The block offset and index bits must be contained in the page offset bits. For a direct mapped cache, the total number of bits in the block offset and index (which is the block number in this case) is the log of the cache size. So for a direct mapped cache, the total L1 cache size cannot be larger than the page size. Using n-way set associativity allows for n times as many blocks, so for n-way associativity, the total cache size is at most n times the page size.