






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







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.
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:
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.
Project Specification
(Both 463 and 521 students should complete this part)
Requirements
Output of your simulator
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
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.
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
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
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.