A simulated cache system program. This program allows you to simulate the cache performance loading, storing, and modifying data by running a memory address trace file generated by Valgrind. You can dynamically specify the configuration of the cache structure including the number of sets (S), the block size (B), and the number of cache lines per set (E) to understand how a memory trace performs for diffrent cache structures.
Note that there no actual data is being cached, it is simply a performance simulation tool to understand the number of hits, misses, and evictions. This is an implementation of the cache lab problem from the CS:APP3e textbook.
-
Clone the repository:
git clone https://github.com/Navnedia/Cache-Simulator.git cd Cache-Simulator
-
Compile the code and test cases: run the
make
command in your terminal.
-
Manually running the cache simulator: after compiling, you can run the simulator by specifiying a few paramters for the cache structure configuration.
-h
(optional) help flag prints usage info message.-v
(optional) verbose flag that displays trace info.-s <num>
Number of set index bits (S = 2^s is the number of sets).-E <num>
Associativity (number of line per set).-b <num>
Number of block offset bits (B = 2^b is the block size).-t <file>
Name of the valgrind trace file to replay.
./csim [-hv] -s <num> -E <num> -b <num> -t <file>
Examples:
./csim [-hv] -s 4 -E 1 -b 4 -t traces/yi.trace ./csim [-hv] -v -s 8 -E 2 -b 4 -t traces/yi.trace
-
Automated test cases: use
./test-csim
to run the cache simulator test script. -
Running matrix transpose algorithm test cases:
./test-trans -M 32 -N 32 ./test-trans -M 64 -N 64 ./test-trans -M 61 -N 67
-
Check everything at once:
./driver.py
Cache and transpose algorithm implmentations:
csim.c
Your cache simulatortrans.c
Your transpose function
Tools for evaluating th cache simulator and transpose algorithms:
Makefile
Builds the simulator and toolsREADME.md
Project repository description and usage instructions (this file)driver.py
The driver program, runs test-csim and test-transcachelab.c
Required helper functionscachelab.h
Required header filecsim-ref
The executable reference cache simulatortest-csim
Tests your cache simulatortest-trans.c
Tests your transpose functiontracegen.c
Helper program used by test-transtraces/
Trace files used by test-csim.c
Note: This program must be run on a 64-bit x86-64 system.