CS 473

Homework : OoO and Cache

Solutions

OoO Execution

  1. (10 points) Suppose the following code is to executed on a CDC 6600. Draw a timing chart showing the execution.
    X1 <- X2 / X3
    X7 <- X1 * X4
    X0 <- X7 * X1
    X4 <- X7 + X6
    X1 <- X0 + X4
    
  2. total is 50 cycles

Cache (30 points)

To make these problems tractable, we'll assume a byte-addressed computer with an eight bit address.

Consider the following cache access string:

0xb4, 0xb4, 0x13, 0x83, 0x84, 0xd8, 0xd9, 0xda, 0x87, 0x88, 0x6c, 0x8e, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x4c, 0x4d

For each of the following cache organizations, show the contents of the cache following each access. In each organization, the cache can hold a total of 16 bytes of data.

  1. Direct-mapped, four-byte line

    Since the line size is four bytes, two bits are required for the offset into the cache line. Since there are sixteen bytes in the cache and a line is four bytes, there are four lines. Since it's direct-mapped, the number of sets is the same as the number of lines, so there are four sets, so the index field is two bits. This leaves four bits for the tag.

    Access Fields Tags in Blocks
    Tag Index Offset 00 01 10 11
    b4 1011 01 00 1011
    b4 1011 01 00 1011
    13 0001 00 11 0001 1011
    83 1000 00 11 1000 1011
    84 1000 01 00 1000 1000
    d8 1101 10 00 1000 1000 1101
    d9 1101 10 01 1000 1000 1101
    da 1101 10 10 1000 1000 1101
    87 1000 01 11 1000 1000 1101
    88 1000 10 10 1000 1000 1000
    6c 0110 11 00 1000 1000 1000 0110
    8e 1000 11 10 1000 1000 1000 1000
    32 0011 00 10 0011 1000 1000 1000
    33 0011 00 11 0011 1000 1000 1000
    34 0011 01 00 0011 0011 1000 1000
    35 0011 01 01 0011 0011 1000 1000
    36 0011 01 10 0011 0011 1000 1000
    37 0011 01 11 0011 0011 1000 1000
    4c 0100 11 00 0011 0011 1000 0100
    4d 0100 11 01 0011 0011 1000 0100

  2. Two-way set-associative, four-byte line, using LRU replacement

    There are two bits for the offset, as before. This time there are two lines in every set; since there are still four lines, we have two sets. This time we have five bits for the tag.

    Access Fields Tags in Blocks
    0 1
    Tag Index Offset MRU MRU
    b4 10110 1 00 10010 L
    b4 10110 1 00 10010 L
    13 00010 0 11 00010 L 10010 L
    83 10000 0 11 00010 R 10000 10010 L
    84 10000 1 00 00010 R 10000 10010 R 10000
    d8 11011 0 00 11011 L 10000 10010 R 10000
    d9 11011 0 01 11011 L 10000 10010 R 10000
    da 11011 0 10 11011 L 10000 10010 R 10000
    87 10000 1 11 11011 L 10000 10010 R 10000
    88 10001 0 00 11011 R 10001 10010 R 10000
    6c 01101 1 00 11011 R 10001 01101 L 10000
    8e 10001 1 10 11011 R 10001 01101 R 10001
    32 00110 0 10 00110 L 10001 01101 R 10001
    33 00110 0 11 00110 L 10001 01101 R 10001
    34 00110 1 00 00110 L 10001 00110 L 10001
    35 00110 1 01 00110 L 10001 00110 L 10001
    36 00110 1 10 00110 L 10001 00110 L 10001
    37 00110 1 11 00110 L 10001 00110 L 10001
    4c 01001 1 00 00110 L 10001 00110 R 01001
    4d 01001 1 01 00110 L 10001 00110 R 01001

  3. Fully associative, one-byte line, using LRU replacement.

    Since the block is one byte, the width of the offset field is 0 (so, effectively, there is no offset field). As it's all one set, the width of the index field is also 0 (so, effectively, there is no index field). That leaves all eight bits as tag.

    In the following figure, I'm showing the blocks in LRU order, as if the data were moving in the cache. Of course, it would really remain in whatever block it got placed, and LRU counters would be maintained)

    Access Contents
    b4 b4
    b4 b4
    13 13 b4
    83 83 13 b4
    84 84 83 13 b4
    d8 d8 84 83 13 b4
    d9 d9 d8 84 83 13 b4
    da da d9 d8 84 83 13 b4
    87 87 da d9 d8 84 83 13 b4
    88 88 87 da d9 d8 84 83 13 b4
    6c 6c 88 87 da d9 d8 84 83 13 b4
    8e 8e 6c 88 87 da d9 d8 84 83 13 b4
    32 32 8e 6c 88 87 da d9 d8 84 83 13 b4
    33 33 32 8e 6c 88 87 da d9 d8 84 83 13 b4
    34 34 33 32 8e 6c 88 87 da d9 d8 84 83 13 b4
    35 35 34 33 32 8e 6c 88 87 da d9 d8 84 83 13 b4
    36 36 35 34 33 32 8e 6c 88 87 da d9 d8 84 83 13 b4
    37 37 36 35 34 33 32 8e 6c 88 87 da d9 d8 84 83 13
    4c 4c 37 36 35 34 33 32 8e 6c 88 87 da d9 d8 84 83
    4d 4d 4c 37 36 35 34 33 32 8e 6c 88 87 da d9 d8 84


Last modified: Thu Apr 28 10:29:35 MDT 2005