Skip to content

A simulated cache system program. Test cache performance by dynamically specifying the cache structure to see how well optimized an algorithm is on different cache structures.

Notifications You must be signed in to change notification settings

Navnedia/Cache-Simulator

Repository files navigation

Cache-Simulator

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.

Installation

  1. Clone the repository:

    git clone https://github.com/Navnedia/Cache-Simulator.git
    cd Cache-Simulator
  2. Compile the code and test cases: run the make command in your terminal.

Usage

  • 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

Files

Cache and transpose algorithm implmentations:

  • csim.c Your cache simulator
  • trans.c Your transpose function

Tools for evaluating th cache simulator and transpose algorithms:

  • Makefile Builds the simulator and tools
  • README.md Project repository description and usage instructions (this file)
  • driver.py The driver program, runs test-csim and test-trans
  • cachelab.c Required helper functions
  • cachelab.h Required header file
  • csim-ref The executable reference cache simulator
  • test-csim Tests your cache simulator
  • test-trans.c Tests your transpose function
  • tracegen.c Helper program used by test-trans
  • traces/ Trace files used by test-csim.c

Note: This program must be run on a 64-bit x86-64 system.

About

A simulated cache system program. Test cache performance by dynamically specifying the cache structure to see how well optimized an algorithm is on different cache structures.

Topics

Resources

Stars

Watchers

Forks