Dinero cache simulator-Computer Architecture

【问题描述:】
PART A.
The Dinero cache simulator is available on the COE Solaris system (machines alpha, beta). The
following information is for using dineroIII (which is the default dinero installed on COE Solaris
systems). You will also find dineroIV installed on both Solaris and Linux machines. Please use
dineroIII for this assignment. You are welcome to experiment with dineroIV.
Dinero allows you to configure a cache using command line arguments (see attached info on
Dinero). The simulator takes as input an address trace. The Dinero input format "din" is an
ASCII file with one LABEL and one ADDRESS per line. The rest of the line is ignored so that it
can be used for comments.
LABEL = 0 read data
= 1 write data
= 2 instruction fetch
= 3 escape record (treated as unknown access type)
= 4 escape record (causes cache flush)
0 <= ADDRESS <= ffffffff where the hexadecimal addresses are NOT preceded by "0x."
Here are some examples:
2 0 This is an instruction fetch at hex address 0.
0 1000 This is a data read at hex address 1000.
1 70f60888 This is a data write at hex address 70f60888.
Make sure to use lowercase.
After creating a trace file (e.g., trace.txt), you run Dinero as follows:
dinero –i16KB –d32KB –b32 < trace.txt
This will simulate a 16KB instruction cache and a 32KB data cache, each with a 32 byte block
size.
Your job is to generate reference streams in Dinero's din format (see description provided with
trace) and produce the following (where you are asked to generate an address stream, submit in
your report enough of the trace so that we can understand the pattern you are using – do not
submit the full trace since it will only waste paper):
1. Assume that you have a direct-mapped 16KB instruction cache (32B block). Generate an
address stream that will touch every cache line once, but no more than once.
2. Assume the same instruction cache organization as in (1), but now the instruction cache is 2-
way set associative, with LRU replacement. The total cache space is still 16KB with a 32B
block, but now you have 1/2 the number of indices. Generate an address stream that touches
every cache index only 8 times, producing 5 misses and 3 hits, but only accesses 3 unique
addresses per index.

【Solution】
2.
2 20     ----- 0000 0000 0000 0000 000|0 0000 001|0 0000
2 2020   ----- 0000 0000 0000 0000 001|0 0000 001|0 0000
2 4020   ----- 0000 0000 0000 0000 010|0 0000 001|0 0000
2 20     ----- 0000 0000 0000 0000 000|0 0000 001|0 0000
2 4020   ----- 0000 0000 0000 0000 010|0 0000 001|0 0000
2 20     ----- 0000 0000 0000 0000 000|0 0000 001|0 0000
2 4020   ----- 0000 0000 0000 0000 010|0 0000 001|0 0000
2 2020   ----- 0000 0000 0000 0000 001|0 0000 001|0 0000


这是32位的物理地址,Cache 大小16KB = 2^14, 故物理地址的低14位
对Cache是唯一对应的,前提是direct association。 此时有32Byte = 2^5
的block大小,所以低5位是offset。从而有16K/32 = 2^9 = 2^(14-5) 个block,
也就是512个index. 这是direct的情况。如果是2set, 那就是256组,
256个index, 占用8位,每组2个block随机分配或者LRU(Least Recent Use)。

所以:1.对于direct associate: offset的5位若有不同不会造成miss
比如:
2 20     ----- 0000 0000 0000 0000 00|00 0000 001|0 0000 
2 21     ----- 0000 0000 0000 0000 00|00 0000 001|0 0001
2 22     ----- 0000 0000 0000 0000 00|00 0000 001|0 0010
2 20     ----- 0000 0000 0000 0000 00|00 0000 001|0 0000 
2 21     ----- 0000 0000 0000 0000 00|00 0000 001|0 0001
2 22     ----- 0000 0000 0000 0000 00|00 0000 001|0 0010
           $ dinero -i16K -d16K -b32 -a1 < hw6_1_2d.txt 
预测结果: fetch: 6    miss: 1   【符合】

      2.对于direct associate: index的变化会有失效产生
比如:
2 20     ----- 0000 0000 0000 0000 00|00 0000 001|0 0000   (miss)1
2 2020   ----- 0000 0000 0000 0000 00|10 0000 001|0 0000   (miss)2
2 4020   ----- 0000 0000 0000 0000 01|00 0000 001|0 0000   (miss)3 与1的index相同,冲掉1
2 20     ----- 0000 0000 0000 0000 00|00 0000 001|0 0000   (miss)4 与3的index相同,冲掉3
2 4020   ----- 0000 0000 0000 0000 01|00 0000 001|0 0000   (miss)5 与4的index相同,冲掉4
2 20     ----- 0000 0000 0000 0000 00|00 0000 001|0 0000   (miss)6 与5的index相同,冲掉5
2 4020   ----- 0000 0000 0000 0000 01|00 0000 001|0 0000   (miss)7 与6的index相同,冲掉6
2 2020   ----- 0000 0000 0000 0000 00|10 0000 001|0 0000   与2的index相同,高位也相同,hit
   $ dinero -i16K -d16K -b32 -a1 < hw6_1_2d.txt
仿真结果:fetch:8    miss:7

      3.对于2set associate, 此时只有512/2 = 256 = 2^8 组,index的位数还是视为9:
2 20     ----- 0000 0000 0000 0000 00|00 0000 001|0 0000   1(miss) ->index1-1
2 4020   ----- 0000 0000 0000 0000 01|00 0000 001|0 0000   2(miss) ->index1-2
2 8020   ----- 0000 0000 0000 0000 10|00 0000 001|0 0000   3(miss) 冲掉->index1-1
2 20     ----- 0000 0000 0000 0000 00|00 0000 001|0 0000   4(miss) 冲掉->index1-2
2 8020   ----- 0000 0000 0000 0000 10|00 0000 001|0 0000   5hit same with 3<-index1-1
2 20     ----- 0000 0000 0000 0000 00|00 0000 001|0 0000   6hit same with 4<-index1-2
2 8020   ----- 0000 0000 0000 0000 10|00 0000 001|0 0000   7hit same with 5<-index1-1 
2 4020   ----- 0000 0000 0000 0000 01|00 0000 001|0 0000   8(miss) 冲掉->index1-2  
   $ dinero -i16K -d16K -b32 -a2 < hw6_1_2d.txt
仿真结果:fetch:8    miss:5

思路:同样的地址stream, 如果 视为9 和 视为8 不一样,谁符合仿真结果,谁就正确。
所以要构造地址stream, 使 视为9 和 视为8 的人工预测结果不一样。

      4.1对于2set associate, 此时只有512/2 = 256 = 2^8 组,index的位数还是视为9:
2 20     ----- 0000 0000 0000 0000 00|00 0000 001|0 0000   1(miss) ->index1-1
2 2020   ----- 0000 0000 0000 0000 00|10 0000 001|0 0000   2(miss) ->index2-1
2 4020   ----- 0000 0000 0000 0000 01|00 0000 001|0 0000   3(miss) ->index1-2
2 20     ----- 0000 0000 0000 0000 00|00 0000 001|0 0000   4hit same with 1<- index1-1
2 4020   ----- 0000 0000 0000 0000 01|00 0000 001|0 0000   5hit same with 3<-index1-2
2 20     ----- 0000 0000 0000 0000 00|00 0000 001|0 0000   6hit same with 4<-index1-1
2 4020   ----- 0000 0000 0000 0000 01|00 0000 001|0 0000   7hit same with 5<-index1-2 
2 2020   ----- 0000 0000 0000 0000 00|10 0000 001|0 0000   8hit same with 2<-index2-1 


      4.2对于2set associate, 此时只有512/2 = 256 = 2^8 组,index的位数视为8:
2 20     ----- 0000 0000 0000 0000 000|0 0000 001|0 0000   1(miss) ->index1-1
2 2020   ----- 0000 0000 0000 0000 001|0 0000 001|0 0000   2(miss) ->index1-2
2 4020   ----- 0000 0000 0000 0000 010|0 0000 001|0 0000   3(miss) 冲掉->index1-1
2 20     ----- 0000 0000 0000 0000 000|0 0000 001|0 0000   4(miss) 冲掉->index1-2
2 4020   ----- 0000 0000 0000 0000 010|0 0000 001|0 0000   5hit same with 3<-index1-1
2 20     ----- 0000 0000 0000 0000 000|0 0000 001|0 0000   6hit same with 4<-index1-2
2 4020   ----- 0000 0000 0000 0000 010|0 0000 001|0 0000   7hit same with 5<-index1-1 
2 2020   ----- 0000 0000 0000 0000 001|0 0000 001|0 0000   8(miss) 冲掉->index1-2 

   $ dinero -i16K -d16K -b32 -a2 < hw6_1_2d.txt
仿真结果:fetch:8    miss:5

Published At
comments powered by Disqus