在阅读了以下论文后,https://people.freebsd.org/~lstewart/articles/cpumemory.pdf("每个程序员应该了解内存的内容")我想尝试一下作者的测试,即测量效果TLB的最终执行时间.
我正在研究嵌入Cortex-A9的三星Galaxy S3.
根据文件:
我们在L1中有两个用于指令和数据缓存的微TLB(http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0388e/Chddiifa.html)
主要TLB位于L2(http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0388e/Chddiifa.html)
Data micro TLB有32个条目(指令微TLB有32或64个条目)
我写了一个小程序,用N个条目分配一个结构数组.每个条目的大小为== 32个字节,因此它适合缓存行.我执行几次读取访问,并测量执行时间.
typedef struct {
int elmt; // sizeof(int) == 4 bytes
char padding[28]; // 4 + 28 = 32B == cache line size
}entry;
volatile entry ** entries = NULL;
//Allocate memory and init to 0
entries = calloc(NB_ENTRIES, sizeof(entry *));
if(entries == NULL) perror("calloc failed"); exit(1);
for(i = 0; i < NB_ENTRIES; i++)
{
entries[i] = mmap(NULL, …Run Code Online (Sandbox Code Playgroud)