CMSC 411 Fall 2004 Programming Project Cache Organization and Performance Evaluation Due December 3 2004 6 00PM In this assignment you will become familiar with how caches work and how to evaluate their performance To achieve these goals you will first build a cache simulator and validate its correctness Then you will use your cache simulator to study several different cache organizations and management policies as discussed in lecture and in Chapter 5 of Hennessy Patterson Section 1 will walk you through how to build the cache simulator and Section 2 will specify the performance evaluation studies you will undertake using your simulator 1 Cache Simulator In the first part of this assignment you will build a cache simulator The type of simulator you will build is known as a trace driven simulator because it takes as input a trace of events in this case memory references The trace which we will provide for you was acquired on another machine Once acquired it can be used to drive simulation studies In this assignment the memory reference events specified in the trace s we will give you will be used by your simulator to drive the movement of data into and out of the cache thus simulating its behavior Your cache simulator will be configurable based on arguments given at the command line and must support the following functionality Total cache size Block size Unified vs split I and D caches Associativity Write back vs write through Write allocate vs write no allocate see p 402 in H P In addition to implementing the functionality listed above your simulator must also collect and report several statistics that will be used to verify the correctness of the simulator and that will be used for performance evaluation later in the assignment In particular your simulator must track Number of instruction references Number of data references Number of instruction misses Number of data misses Number of words fetched from memory Number of words copied back to memory 1 1 1 Files The first thing you should do is copy the program files from the afs csic umd edu users als 411 fall04 Project code directory on the Linuxlab cluster into your own local directory Alternatively the files can be downloaded from the class projects web page There are five program files in total as indicated in the table below which lists the file names and a short description of their contents Note there are also three other files spice trace cc trace and tex trace in the traces sub directory under the Project directory on the Linuxlab cluster Do not copy these files since they are very large We will explain what to do with them later File Name Makefile main c main h cache c cache h Description Builds the simulator Top level routines for driving the simulator Header file for main c Cache model Header file for cache c The Makefile is a UNIX make file Try typing make in the local directory where you ve copied the files This will build the simulator from the program files that have been provided and will produce an executable called sim Of course the executable doesn t do very much since the files we have given you are only a template for the simulator However you can use this make file to build your simulator as you add functionality Be sure to update the make file if you have additional source files other than the four program files we ve given you The four program files main c main h cache c and cache h contain a template for the simulator written in C These files contain many useful routines that will save you time since you don t have to write them yourself main c contains the top level driver for the simulator It has a front end routine called parse args that parses command line arguments to allow configuring the cache model with all the different parameters specified earlier To see a list of valid command line arguments try typing sim h after compiling the template files Note that your simulator code should interpret the four size parameters block size unified cache size instruction cache size and data cache size in units of bytes main c also contains a top level simulator loop called play trace and a routine that parses lines from the trace file called read trace element For each trace element read play trace calls the cache model via the routine perform access to simulate a single memory reference to the cache While you are free to modify main c you should be able to complete the assignment without making any modifications to this file cache c contains the cache model itself There are three routines in this file which you should be able to use without modification set cache param is the cache model interface to the argument parsing routine in main c It intercepts all the parameter requests and sets the proper parameter values which have been declared as static globals in cache c delete and insert are deletion and insertion routines for a doubly linked list data structure which we will explain below dump settings prints the cache configuration based on the configured parameters and print stats prints the statistics that you will gather In addition to these five routines there are three template functions which you will have to write init cache is called once to build and initialize the cache model data structures perform access is called once for each iteration of the simulator loop to simulate a single memory reference to the cache And flush is called at the very end of the simulation to purge the cache of its contents Note that the simulation is not finished until all dirty cache lines if there are any are flushed out of the cache and all statistics are updated as a result of such flushes 2 main h is self explanatory cache h contains several constants for initializing and changing the cache configuration and contains the data structures used to implement the cache model we will explain these in the next section Finally cache h also contains a macro for computing the base 2 logarithm called LOG2 which should become useful as you build the cache model In addition to the five program files there are also three trace files that you will use to drive your simulator Their names are spice trace cc trace and tex trace These files are the result of tracing the memory reference behavior of the spice circuit simulator a C compiler and the TeX text formatting program respectively They represent roughly 1 million memory references each These files are very large so you should not copy them into your local directory Instead when
View Full Document