Skip to content

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

Notifications You must be signed in to change notification settings

pqrsooo/cache-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages