Docsity

Data Cache Simulation Project: Building L1 and Hybrid Caches with Victim Cache - Prof. Eri, Study Guides, Projects, Research of Electrical and Electronics Engineering

Toggle sidebar
bg1
–1–
ECE 463/521: Fall 2002
Project #1: Data-Cache System Design
Due: Monday, Sept. 30, 11:00 PM
Project rules
1. All students are encouraged to work in teams of two, using pair programming. Pair
programming means programming where two people sit at the same workstation,
writing the code collaboratively.
2. ECE 521 students will have additional parts to do; therefore both members of a pair
should be from the same class (463 or 521).
3. You may not work with the same partner on more than one project this semester.4.You
must register your partnership by posting on the Pair-Programming Partners message
board, under the topic Project 1.”
5. Sharing of code between teams will be considered cheating, and will be penalized in
accordance with the Academic Integrity policy.
6. It is acceptable for you to compare your results with other groups to help debug your
program. It is not acceptable to collaborate on the final experiments.
7. You must do all your work in the C/C++ or Java languages. C++ (or Java) is
encouraged because it enables straightforward code-reuse and division of labor.
8. Homework will be submitted over the Wolfware Submit system and run in the
Eos/Unity environment.
Project description
This project will give you a chance to build three general data-cache models: a one-level
(L1) cache, and two hybrid caches (L1+victim cache, L1+MRU cache). You will write a
trace-driven simulator, which inputs a “trace” (a sequence of references) from a dynamic
instruction stream to simulate hardware operations.
Data-cache simulator
In
p
ut Out
p
u
t
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Data Cache Simulation Project: Building L1 and Hybrid Caches with Victim Cache - Prof. Eri and more Study Guides, Projects, Research Electrical and Electronics Engineering in PDF only on Docsity!

ECE 463/521: Fall 2002

Project #1: Data-Cache System Design

Due: Monday, Sept. 30, 11:00 PM

Project rules

  1. All students are encouraged to work in teams of two, using pair programming. Pair programming means programming where two people sit at the same workstation, writing the code collaboratively.
  2. ECE 521 students will have additional parts to do; therefore both members of a pair should be from the same class (463 or 521).
  3. You may not work with the same partner on more than one project this semester.4.You must register your partnership by posting on the Pair-Programming Partners message board, under the topic Project 1.”
  4. Sharing of code between teams will be considered cheating, and will be penalized in accordance with the Academic Integrity policy.
  5. It is acceptable for you to compare your results with other groups to help debug your program. It is not acceptable to collaborate on the final experiments.
  6. You must do all your work in the C/C++ or Java languages. C++ (or Java) is encouraged because it enables straightforward code-reuse and division of labor.
  7. Homework will be submitted over the Wolfware Submit system and run in the Eos/Unity environment.

Project description

This project will give you a chance to build three general data-cache models: a one-level (L1) cache, and two hybrid caches (L1+victim cache, L1+MRU cache). You will write a trace-driven simulator, which inputs a “trace” (a sequence of references) from a dynamic instruction stream to simulate hardware operations.

Data-cache simulator

Input Output

Input: Trace file

The simulator reads a trace file that contains one reference per line in the following format (an address consists of 32 bit):

r|w r|w ...

Example:

r ffe r ffe w 0eff r ffe ... Simulator: Your task

Specification of simulator

Cache simulation capabilities

a. The simulator models a memory hierarchy with (1) an L1 data cache and (2) an optional victim cache (the system can be configured with or without a victim cache). Ti p: If you are using C++ or Java, note that the victim cache code is quite different from the L1 cache code, so it is best to implement different classes for each.

b. L1 cache description:

o SIZE : total bytes of data storage o ASSOC : the associativity of the cache ( ASSOC = 1 is a direct mapped cache) o BLOCKSIZE : the number of bytes in a block o LRU replacement policy

There are a few constraints on the above parameters: (i) BLOCKSIZE is a power of two and (ii) the number of sets is a power of two. Note that ASSOC (and, therefore SIZE) need not be a power of tw o. The number of sets is determined by the following equation:

sets =

SIZE BLOCKSIZE x ASSOC

You may assume that a miss to the L1 cache that has to be satisfied from memory takes as long to process as 20 hits.

c. Victim cache description: o The victim cache is fully-associative and uses LRU replacement policy. o The number of victim cache entries, V, is adjustable. o L1 cache miss / victim cache hi t: If there is a miss in the L1 cache and a hit in the victim cache (say for block X), block X is placed in the L1 cache. Then, the block that X replaced in the L1 cache (say block Y, which we call the victim block) is

the example above). Now, if a block that is IN TRANSITION is referenced, a stall must occur until that time. So in the simulator, we can simply set current_time = time_prefetch_done. This takes care of handling the stall. (Note that we can get by with a single time_prefetch_done variable, since only one block can be being prefetched at a time.)

Of course, before we handle a prefetch-induced stall, we need to be careful that the block is still IN TRANSITION. If the current time is after the time that the prefetch finishes, we don’t need to stall (indeed, we better not stall!). We just need to set the block’s status to VALID. An easy way to implement references to blocks IN TRANSITION would be to set current_time = min(current_time+1, time_prefetch_done) and set the block’s status to VALID.

There’s another special case we need to consider. That is, what happens when a miss occurs while a prefetch is in progress? We can’t start to process the miss until the prefetch is finished. (Actually, high-performance processors use split-transaction buses , which allow transfers to memory to be overlapped, but in our first project, we will opt for the simpler approach of assuming that only one transfer is active at a time.) So this means that if the current time is t , the miss will not finish being processed at time t +20, but rather at time_prefetch_done+20. Thus, prefetching makes it possible to have stalls that are almost twice as long as the stalls without prefetching. We hope that this doesn’t happen very often, and that the cost is outweighed by having prefetched blocks made available without any processor stalls.

f. The write policy is either WTNA or WBWA, described in detail below.

g. WTNA: o Write hits in L1 cach e: The write also goes to the victim cache (write-through). It should not hit in the victim cache, since a block cannot be in both caches at once (see victim cache description). You should access the victim cache anyway, just to assert that the block isn’t found. o Write misses in L1 cach e: Since we do not allocate on a write miss (WTNA), there cannot be a victim (no block is replaced in L1 cache). So, victim cache activity is minimal. The write is also issued to the victim cache (write-through) to keep its data up-to-date. In the simulator, you only need to update LRU if it hits; nothing is done if it misses.

h. WBWA: Both the L1 cache and victim cache have dirty bits. Blocks are managed exactly as described above (see victim cache description), only make sure to carry dirty bits with blocks wherever they go. Definition of “writeback”: In a system without a victim cache, replacing a dirty block in the L1 cache causes a writeback to memory, and it is counted towards the “writeback” statistic. However, if there is a victim cache, the replaced block and its dirty bit are sent to the victim cache, and we do not call this a “writeback” because it isn’t sent to memory. When a LRU dirty block is replaced in the victim cache (not swapped!), it is written back to memory and counts toward the “writeback” statistic. In summary, in a system with a victim cache, writebacks can only occur from the victim cache; in a system without a victim cache, writebacks occur from the L1 cache.

i. Five parameters completely specify the system: SIZ E, ASSO C, BLOCKSIZ E, WRITE_POLIC Y, V, and M. The variable V is the size of the victim cache. If V=0, the victim cache is disabled. M is a boolean; iff M is false, there is no MRU cache..

j. The size of an address is 32 bits.

Output: Statistical information

In overview, this is the kind of information you will be collecting for each of the cache systems. For more complete information, refer to the specific lists in the descriptions of each type of cache system, below.

  1. Number of cache reads
  2. Number of read misses
  3. Number of cache writes
  4. Number of write misses
  5. Number of writebacks (if WBWA policy was used)
  6. Total memory traffic (number of blocks transferred to/from main memory, including misses to memory and writebacks)
  7. Cache miss rate = cache read misses + cache write misses cache reads + cache writes

Project Specification

Model 1: L1 cache

(Both 463 and 521 students should complete this part)

Requirements

  1. The parameters, such as cache size, block size, and associativity ( n ≥ 1), and write mode (WBWA or WTNA) are adjustable in your simulator.
  2. LRU is the only replacement policy.

Output of your simulator

  1. Number of L1 reads
  2. Number of L1 read misses
  3. Number of L1 writes
  4. Number of L1 write misses
  5. Number of writebacks
  6. Total memory traffic (number of blocks transferred to/from main memory, including misses to memory and writebacks)
  7. L1 miss rate = L1 read misses + L1 write misses L1 reads + L1 writes

Data analysis: Use your data collected from your experiments to analyze the relationship of the miss rate, AAT (average access time—refer to AAT calculation and CACTI tool ), cache size, block size, and other parameters of cache (better with table and graphic). Find two data cache systems with the best AAT for each trace file.

Output of your simulator

  1. Number of cache cache reads
  2. Number of cache read misses
  3. Number of cache writes
  4. Number of cache write misses
  5. Number of MRU read misses
  6. Number of MRU write misses
  7. Number of writebacks
  8. Total memory traffic
  9. MRU miss rate = MRU read misses + MRU write misses MRU reads + MRU writes
  10. Cache miss rate = cache read misses + cache write misses cache reads + cache writes

Data analysis

Use the data collected from your experiments to analyze the relationship of miss rate, AAT (average access time), cache size, block size, and other parameters of the cache (ideally, with tables and graphics). Find two data-cache systems with the best AAT for each trace file.

Overall analysis

From an architectural perspective, analyze and compare the characters of those three models with the results from your experiments.

CACTI tool

Installing

Log into your Unity home directory in UNIX.

// link to the tool on the server eos% ln –s /afs/eos.ncsu.edu/courses/ece/ece521/lec/001/www/projects/CACTI.FUD GED.fixwarnings // the directory name CACTI.FUDGED.fixwarnings will show up at your home directory eos% cd CACTI.FUDGED.fixwarnings // then cacti will work. eos% cacti

Using

CACTI Syntax cacti

OR

cacti csize - size of cache in bytes (i.e. 16384) bsize - block size of cache in bytes (i.e. 32) assoc - associativity of cache (i.e. 2 or FA) direct mapped caches - DM set associative caches - number n (where cache is n-way associative) fully associative caches - FA tech - technology size in microns (0.35um we use) RWP - number of read/write ports (we use defaults) RP - number of read ports (we use defaults) WP - number of write ports (we use defaults)

Example:

eos% cacti 16384 32 2 0.35um will return the following timing and power analysis for a 16K 2-way set associative cache with a 32-byte blocksize at a 0.35um feature (technology) size: ……………… ……………… Technology Size: 0.35um Vdd: 2.6V Access Time (ns): 2.36865 Ä----------------------------this is what we need. Cycle Time (wave pipelined) (ns): 0. Power (nJ): 3. Wire scale from mux drivers to data output: 0. …………….. ………………

AAT calculation

The access times of the L1 cache, MRU cache and victim cache can be determined using the CACTI tool. Below, T (^) L1 , T (^) MRU and T (^) V refer to the L1 cache, MRU cache and victim cache access times (in ns), respectively.

However, for the case of MRU+L1 cache, we will assume that the access time to the L cache is two cycles. It needs to be some multiple of the MRU cache’s cycle time, and 2 cycles seems reasonable in almost all cases.

For L1 cache

AAT (s) = T L1 + Miss RateL1 × Miss PenaltyL It takes 20 cycles to fetch a block from memory, and the remaining bytes are transferred at a rate of 8 bytes/cycle. Assuming the clock period of the processor is set by the L access time (i.e., the clock period in ns is equal to TL1) Memory-to-L1 transfer time = 20 cycles Miss PenaltyL1 = 20 cycles

  1. Project report (Microsoft Word .doc file recommended)
  • No executable file is needed; just submit your source code and makefile.

Grading

0% You do not hand in (submit electronically) anything by the due date. +10% Your Makefile works, and creates three simulators (executable files). +10% Your simulator can read trace files from the command line and has the proper interface for parameter settings. +50% Your simulator produces the correct output. +30% You have done a good analysis of the experiment.