Your cart is currently empty!
INTRODUCTION Caches are complex memory and sometimes difficult to understand. One way to understand them is to build them. However, due to time constraints and lack of hardware expertise, we will instead write a cache simulator. In this project, you will be implementing a cache simulator and then running some design experiments to find…
INTRODUCTION
Caches are complex memory and sometimes difficult to understand. One way to understand them is to build them. However, due to time constraints and lack of hardware expertise, we will instead write a cache simulator. In this project, you will be implementing a cache simulator and then running some design experiments to find an optimal cache for the given workloads. We have provided you the following files, written in your favorite programming language C:
You will be filling in the subroutines in the cachesim.c file, and then validating your output against the sample output the TA’s have generated.
This is a simple assignment that will check your understanding of how caches work. However, keep in mind that your choice of data structure used will greatly impact the difficulty of coding the simulator If you are struggling to write code, then step back and review the concepts.
RULES
Please make sure to follow the following rules:
Tech Honor Code.
CACHE – CORE CAPABILITIES
Here are the specifications that your simulator must meet:
IMPLEMENTATION
Your task is to fill out the following functions:
void cache init(uint64 t c, uint64 t s, uint64 t b)
This is the subroutine that initializes the cache. You may add and initialize as many global or heap (mal- loc’ed) variables here.
void cache access(char type, uint64 t address, cache stats t *stats)
This is the subroutine that will simulate cache accesses, one access at a time. The ‘type‘ is going to be either READ or WRITE kind. The ‘address‘ field is the memory address that is being accessed. ‘stats‘ should be used for updating the cache statistics.
void cache cleanup(cache stats t *stats)
Use this function to cleanup any memory and for calculating final statistics. Update changes in the ‘stats‘
parameter. Hint – All malloc’ed memory must be freed here.
STATISTICS – AKA THE OUTPUT
The output from your final cache is the statistics that your cache calculates for each workload. Here is the list of fields inside the cache stats t struct and their meaning:
The driver displays the output for these parameters onto the terminal screen. You only need to fill in the
‘stats‘ structure passed in the cache access() and cache cleanup() functions.
VALIDATION REQUIREMENT
Four sample simulation outputs will be provided on T-square. You must run your simulator and debug till your output perfectly matches all the statistics given in the sample output.
DESIGN EXPERIMENT
After validating your cache against the output given by the TA’s, you need to design a cache for each trace in the trace directory under the following constraints:
You can vary any parameter, cache size, associativity and block size (C, B, S). However, keep in mind that the maximum block size is 64 bytes, that is B is maximum 6.
Write a 1 – 2 page report giving the specifications of the best cache you came up with for each of the 4 traces we have provided you.
HOW TO RUN YOUR CODE
We have provided you a ‘Makefile‘ that you can use to compile your code. Modify the Makefile at your own risk
Use these commands to run the cache simulator driver:
$: make
$: ./cachesim -c <Cache Size>-b <Block Size>-s <Associativity>-i <Trace File Name>
To run a script that will run all the tests, do the following:
$: bash run script
Finally: To pipe the output for all the test cases to a text file, you could run
$: bash run script >> <Filename>
To verify that you are matching the TA generated output, you can use the ‘diff‘ command. Here is how you can do it:
$: diff <File Name> solution.txt
WHAT TO SUBMIT
To generate a submittable version of your project, type in ‘make submit‘ into the terminal. You need to submit the following:
HINTS
Don’t forget to sign up for a demo! We will announce when these are available. Failure to demo will result in a score of 0!