《系统级编程_lab11》由会员分享,可在线阅读,更多相关《系统级编程_lab11(6页珍藏版)》请在金锄头文库上搜索。
1、Lab11:Memory MountainRequirementsPlatform: This lab assumes that you are using Visual C+ under a 32-bit version of Windows, using Intel Pentium or Pentium-equivalent machines. The exact compiler and platform are mostly unimportant, as the lab is reasonably portable.Get to know your Cache This platfo
2、rm of Intel Pentium machines has a memory hierarchy, which includes multi level of Cache, such as L1 cache, L2 cache, and sometimes L3 Cache maybe also exist. You can use the some tools, such as everest.exe, to find out the basic information of Cache of the computer system, which you are uings. For
3、example, to using everest.exe, just double-click to run it. After it makes some information collection, it will show all the information about you computer system in its frame. The following is an example of its main frame. You can see the information about the Cache.Now, run everest.exe to find out
4、 the information of your computer systems Cache, and fill the blank. TypeSize in byteL1 cache64KB L2 cache2M L3 cacheThe project of memory_mountain Please download the project of memory_mountain.rar first. This project if the Windows-version of CMU CSAPP of mountain.c, which you can find in the text
5、book chapter 6.6(Notes: this is the first version), or from http:/csapp.cs.cmu.edu/public/1e/public/code.html/mountain.c(Notes: this is the first version) or from http:/csapp.cs.cmu.edu/public/code.html/mountain.c(Notes: this is the first version)Your Task1Read the source code in mountain.cpp, and a
6、nswer the following questions: (Notes: you dont have to pay too much attention on the function fcyc2() ) 1) What is the variable of size and stride used for? size 是工作集的大小,即操作的数组的总大小,size 越小,得到的工作集越小,时间局部性也就越好。stride 是步长,表示读取的两个元素之间的间隔,stride 越小,得到的空间局部性越好。步长 stride 的范围为 116。1) What is the meaning of
7、 the return value of the function run()? Run()是一个封装函数,对于每个工作集大小 size 和步长 stride 的组合,它调用 test()函数,并返回测量出的读吞吐率,单位为 MB/s。2If necessary, make some change to the value of MINBYTES, MAXBYTES, and MAXSTRIDE. 3Build the project and run it, the you can get an output file named as out.txt.4Copy the data in ou
8、t.txt into an Excel file. Just as shown in the following figure.5Click any cell in this Excel file, then add a chart.Then click Finish.5Then you can get a figure alike this:6. The following two figures are from CSAPP e1 and CSAPP e2Figure of CSAPP e1Figure of CSAPP e27Just Paste your figure here:1 3
9、 57911131516m256k4k0200400600800100012001000-1200 800-1000 600-800 400-600 200-400 0-2008How many ridges(山脊) do you get? And what are they correspond to? 有 3 个山脊。最高的是:L1 缓存;中间是 L2 缓存;最低的是:memory;9Just compare the mountain with the information that you just got by running as everest.exe. And explain
10、the How the spatial locality and temporal locality are shown in this figure.x 轴可以看出 stride 与吞吐量的关系:stride 越小,吞吐量越大,空间局部性越好,吞吐量 随stride 的增大而减小。图中二级缓存和 memory 的山脊上随着 stride 的增加有明显的空间局 部性的斜坡,即 stride 越大吞吐量越小,空间局部性也越差。y 轴可以看出 size 与吞吐量的关系:size 越小,吞吐量越大,时间局部性越好,吞吐量随 size 的增大而减小。图中当 size为 1K32K 时工作集能全部在 L1,能够达到最大的吞吐量;当工作集能完全在 L2 中,可 以看到吞吐量随 size 增加有所下降;当超过 2M 需要从主存中读取时,吞吐量下降更明显。 随着 size 的增加,吞吐量下降,时间局部性也越差。