实例介绍
CSAPP 六个重要实验 lab4 实验指导书
2014年9月7E CSE 351 Course Website- Spring 2014 The distribution includes an optional script, run. pl, that automates some of the chore of running the four executables and gathering measurements. To run it, type /run. pl. It compiles each of the source files (and cacheExperiment c twice; with and without optimizations), runs each with the time command, and reports the sum of the user and system times run. pl should work in most environments(including the CSE virtual machine). It should work for you, but it is an optional (and unsupported)tool So, to summarize 1. Compile and measure each of the java implementations as they come in the distribution. Compile and measure the C program with and without optimizations 2. Edit each source file to un comment the assignment to array src Re-compile and re-measure 3. Edit to switch the order of the i and j loops. Recompile and re-measure 4. Edit to re-comment out the statement assigning to array src(with the i and j loops still reversed). Re-compile and re- measure 5. Edit to put the loops back in the original order. (At this point the code is the same as it was when you first fetched it. Change the code to copy an array of size 4096X 4096. Then repeat steps 1-4 above Test results CollectyourresultsinashortpDfdocument(http://www.google.com/search?q=pdf)withthefollowingsections 1. The Test System o A short string describing the system your ran on(e.g, " my Mac laptop""the CSE home VM an my Windows laptop"or "lab Linux workstation) o What the CPU is on that system. You can obtain that on any Linux system by issuing the command cat /proc/cpuinfo. Give us the model name, as listed 2. Test Results Four tables of numbers giving the measured CPu time consumed when executing each of the four executables under the different configurations. Each table should look like this. It doesn't have to be exactly this, to every detail of formatting, but please keep your information in the same order; it makes reading 50 copies of these tables easier if theyre all laid out the same way. Array Size Performing src assignment? App Time with i then Time withj then i Java Javalnteger 2048 No Optimized c 3. Q&A Answer these questions 1. What are the source code differences among the two Java implementations? 2. Pick a single pair of results that most surprised you. What is it about the results that surprised you?(That is from the 32 pairs of measurement results, pick one pair whose relationship is least like what you would have guessed. 3. Optional extra credit None of these programs appear to actually do anything, so one is tempted to optimize them by simply eliminating all code(resulting in an empty main() Is that a correct optimization? Related to that, try compiling this c program, with and without optimization, and then time running it #include <stdio h> #define size 10o0ooo http://courses.cs.washington.edu/courses/cse351/14sp/lab-4.html 3/6 2014年9月7E CSE 351 Course Website- Spring 2014 int main(i int i, j,k; for(i=0: i< SIZE; i++)1 for(j=0; j< SIZE: j++)t for(k=0: k< SIZE, k++)i sum =-sum i printf("hello, world \n") return o Now replace the printf line with printf("Sum is %d\n", sum) and compile/run unoptimized and optimized Part II: Inferring Mystery Cache Geometries Overview Chip D. Signer, Ph. D, is trying to reverse engineer a competitor's microprocessors to discover their cache geometries and has recruited you to help. Instead of running programs on these processors and inferring the cache layout from timing results, you will approximate his work by using a simulator. This lab should be done on a 64-bit machine Use attu, the lab computers, or your own persona/64-bit computer Instructions Specifically, each of these"processors"is provided as an object file (. o file)against which you will link your code. See the file mystery-cache. h for documentation of the function interface that these object files export. Your job is to fill in the function stubs in cache-test-skel c Which, when linked with one of these cache object files, will determine and then output the cache size, associativity, and block size. Some of the provided object files are named with this information(e.g cache_64c_2a_16b.o is a 64 KB capacity, 2-way set-associative cache with 16b blocks )to help you check your work. There are also 4 mystery cache object files, whose parameters you must discover on your own You can assume that the mystery caches have sizes that are powers of 2 and use a least recently used replacement policy You cannot assume anything else about the cache parameters except what you can infer from the cache size. Finally, the mystery caches are all pretty realistic in their geometries, so use this fact to sanity check your results You will need to complete this assignment on a Linux machine with the c standard libraries(e.g attu. All the files you need are in lab4. tar. gz(labs/ab4/ab4 tar. gz. To extract the files from this archive, simply use the command http://courses.cs.washington.edu/courses/cse351/14sp/lab-4.html 46 2014年9月7E CSE 351 Course Website- Spring 2014 tar xzf lab4 tar gz and the files will be extracted into a new subdirectory of the current directory named lab4. the provided makefile includes a target cache-test To use it, set TEST_ CACHE to the object file to link against on the command line -i.e. from within the lab4 directory run the command i make cache-test TEST__CACHE-cache_ 64c_2a 16b.o This will create an executable cache-test that will run your cache-inference code against the supplied cache object. Run this executable like so: /cache-test and it will print the results to the screen Your tasks Complete the 3 functions in cache-test-skel c which have / YOUR CODE GOES HERE * comments in them Additionally, determine the geometry of each of the four mystery caches and list these in a comment, along with your name, at the top of your modified cache-test-skel c Tips Note that the exact style of for loops with which you may be familiar from Java was not allowed in c until a later standard Instead of writing for (int i=.,i write this instead, declaring your loop variable outside the loop header (and at the top of your function body t i i for (1= ){..} There is also a flag to tell the compiler to allow the first version but the second version will work either way Errata/clarifications The main function in cache-test-skel c contains the following The cache needs to be initialized but the parameters will be ignored by the mystery caches, as they are hard coded You can test your geometry paramter discovery routines by calling cache_inito W/ your own size and block size values cache_init(o,0) The first sentence in the comment is true but the second is false for the files we have distributed all the cache simulator object files we provided ignore the arguments to cache_init(). You are welcome to implement your own simulated cache (with the interface described in mystery-cache h to test on other geometries, but this will likely be more work than the rest of http://courses.cs.washington.edu/courses/cse351/14sp/lab-4.html 5/6 2014年9月7E CSE 351 Course Website- Spring 2014 the assignment itself Submitting your work Part I: Please turn in a pdf file containing your answers to part to the catalyst drop Box for this assignment (https:catalystuw.edu/collectit/assignment/gaetano/31190/125997).wewillnotacceptsubmissionsthatarenotinPdf format Part ll Submit your modified version of cache-test-skel c to the Catalyst Drop Box for this assignment http://courses.cs.washingtonedu/courses/cse351/14sp/lab-4.html 6/6 【实例截图】
【核心代码】
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论