Giter Site home page Giter Site logo

jthanat / cache-simulator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pqrsooo/cache-simulator

0.0 2.0 0.0 7.6 MB

A cache simulator for studying the factors that affects the performance of cache accesses

Makefile 0.32% C++ 98.70% Objective-C 0.41% C 0.57%

cache-simulator's Introduction

Cache Simulator

A cache simulator for studying the factors that affects the performance of cache accesses

Getting Started

Prerequisites

This project requires the GNU Compiler Collection (GCC) as the compiler.
See this link for further details about GCC

Compilation

If you have ever compiled before, please clean an executable program and object files first by running this command in project's root directory. Otherwise, just skip this step.

make clean

Now, you can compile by running this command:

make

How to use this Cache Simulator

Usage

./bin/Simulator [options] <path_to_address_file>

Options

Option Description
-s, --size <cache_size> Set cache size (kilobyte)
-sb, --size-b <cache_size> Set cache size (byte)
-dm, --direct-mapped <block_size>? Set cache structure to a direct mapped with specific block size (4 by default)
-as, --associativity <n_way>? Set cache structure to an associativity with specific n (2 by default)
-lru, --least-recently-used Set least recently used as a replacement algorithm when --associativity option is triggered (default)
-rr, --round-robin Set round robin as a replacement algorithm when --associativity option is triggered
-h, --help Show help message

Note that ? after <argument> indicates that <argument> is optional and you can also view this help message by including --help or -h option after command.

Example

Example 1

Specification Value
Cache type Direct Mapped
Cache size 4 KB
Block size 4 Bytes
./bin/Simulator input/gcc_ld_trace.txt --direct-mapped 4 --size 4

Example 2

Specification Value
Cache type Associativity
Cache size 1024 KB
N-way 4
Replacement algorithm Least recently used
./bin/Simulator input/gcc_ld_trace.txt --associativity 4 --size 1024 --least-recently-used

Address File

An address file fed to this simulator must be conform to the following pattern:

name_label
address
address
...

Example

gcc_ld_trace
0x40119618
0x1ffff1d0
0x40119618
0x1ffff1d0
0x1ffff1d0

Report

Direct Mapped

Command:

./bin/Simulator input/gcc_ld_trace.txt --direct-mapped <block_size> --size <cache_size>

Hit

Direct mapped (Hit)
Block Size
(Bytes)
Cache Size (KB)
4 8 16 32
4 1669560 1775198 1849934 1895088
8 1652147 1766215 1846558 1895885
16 1677463 1784151 1860161 1906747
32 1687566 1793431 1867498 1911848

Miss

Direct mapped (Miss)
Block Size
(Bytes)
Cache Size (KB)
4 8 16 32
4 330440 224802 150066 104912
8 347853 233785 153442 104115
16 322537 215849 139839 93253
32 312434 206569 132502 88152

Miss rate

Direct mapped (Miss rate)
Block Size
(Bytes)
Cache Size (KB)
4 8 16 32
4 0.1652 0.1124 0.0750 0.0525
8 0.1739 0.1169 0.0767 0.0521
16 0.1613 0.1079 0.0699 0.0466
32 0.1562 0.1033 0.0663 0.0441

Associativity

Command:

./bin/Simulator input/gcc_ld_trace.txt --associativity <n_way> --size <cache_size> [--round-robin | --least-recently-used]

Hit

Associativity (Hit)
Cache Size
(KB)
Two-way Four-Way
LRU RR LRU RR
1 1491704 1458831 1527679 1475129
4 1759588 1740139 1786471 1759111
8 1834446 1821673 1852267 1834498
32 1939563 1934739 1950492 1943335
512 1974599 1974538 1974745 1974736
1024 1974717 1974691 1974753 1974753

Miss

Associativity (Miss)
Cache Size
(KB)
Two-way Four-Way
LRU RR LRU RR
1 508296 541169 472321 524871
4 240412 259861 213529 240889
8 165554 178327 147733 165502
32 60437 65261 49508 56665
512 25401 25462 25255 25264
1024 25283 25309 25247 25247

Miss rate

Associativity (Miss rate)
Cache Size
(KB)
Two-way Four-Way
LRU RR LRU RR
1 0.2541 0.2706 0.2362 0.2624
4 0.1202 0.1299 0.1068 0.1204
8 0.0828 0.0892 0.0739 0.0828
32 0.0302 0.0326 0.0248 0.0283
512 0.0127 0.0127 0.0126 0.0126
1024 0.0126 0.0127 0.0126 0.0126

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.