从程序员的角度看cache(四)

附:

记下查看cache信息的方法:

cat /sys/devices/system/cpu/cpu0/cache/index2/size

sudo  dmidecode -t cache

还有一个链接http://igoro.com/archive/gallery-of-processor-cache-effects      上面的1、2、3、4示例在本地都做了测试,满有意思的。

 

本文内容如下:

在中心又跑了下指令集测试,顺便测试下在cache miss时write allocate和read allocate的区别。

当读时,无论对于write through 或 write back型cache,当发生cache miss时都会将数据调入cache

 

代码:

 1     movl r0, #0x7000
 2     movl r1, #0xaaaaaaaa
 3     stw r1, [r0]
 4     movl r1, #0xbbbbbbbb
 5     stw r1, [r0]
       ldw r1, [r0]
6 movl r0, #0x94007000 7 stw r1, [r0] 8 mytest: 9 stw, r1, [r0] 10 b mytest

对于unicore当使用write through(0x0c), 对应了read allocate

即:当对应数据不在cache中时,则在写的时候不会将数据不会调入cache

 1 UNITY WRITE HADDR 00007000 Size 2 Data aaaaaaaa
 2 UNITY WRITE HADDR 00007000 Size 2 Data bbbbbbbb
 3 UNITY READ HADDR 00007000 Size 2 Data bbbbbbbb
 4 UNITY READ HADDR 00007004 Size 2 Data xxxxxxxx
 5 UNITY READ HADDR 00007008 Size 2 Data xxxxxxxx
 6 UNITY READ HADDR 0000700c Size 2 Data xxxxxxxx
 7 UNITY READ HADDR 00007010 Size 2 Data xxxxxxxx
 8 UNITY READ HADDR 00007014 Size 2 Data xxxxxxxx
 9 UNITY READ HADDR 00007018 Size 2 Data xxxxxxxx
10 UNITY READ HADDR 0000701c Size 2 Data xxxxxxxx

对于unicore当使用writeback(0x1c), 对应了write allocate

即:当对应数据不在cache时,则在写的时候会将数据调入cache

UNITY READ HADDR 00007000 Size 2 Data xxxxxxxx
UNITY READ HADDR 00007004 Size 2 Data xxxxxxxx
UNITY READ HADDR 00007008 Size 2 Data xxxxxxxx
UNITY READ HADDR 0000700c Size 2 Data xxxxxxxx
UNITY READ HADDR 00007010 Size 2 Data xxxxxxxx
UNITY READ HADDR 00007014 Size 2 Data xxxxxxxx
UNITY READ HADDR 00007018 Size 2 Data xxxxxxxx
UNITY READ HADDR 0000701c Size 2 Data xxxxxxxx
UNITY WRITE HADDR 14007000 Size 2 Data bbbbbbbb

 注意:对于writeback下的数据记录中出现14007000地址,这时unicore特有的现象,和体系结构有关(此处没有开mmu,因此不涉及地址转换)

posted on 2013-04-21 19:08  阿加  阅读(266)  评论(0编辑  收藏  举报

导航