






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!







College of Computing
CS6290/CS4290 — High-Performance Computer Architecture Spring 2003
CS6290/CS4290 Issued: January 6, 2003 Project 1 Due: February 7, 2001
Purpose: The goal of this project is to understand the tradeoffs in caches by designing a multilevel cache hierarchy. The project will also expose you to some architecture evaluation techniques.
Reading: H&P Chapter 5, [Jouppi90]
Problems: 1. Warmup: Benchmarks
To turn in: Turn in a write-up that describes your cache configuration, its cost and performance and a justification (including data) for your con- clusions.
Collaboration: (As in the syllabus) collaboration on projects and homework in pairs is encouraged. If you work in a pair, turn in one write-up with the names of both collaborators. You’re welcome to discuss high-level concepts with other groups, but all homework solutions must be worked out and written up separately.
Appendix: Bus busy time approximation
NOTE: support files for this assignment are available via NFS on CoC machines in the following directory: /users/projects/class/6290/spring03/
Problem 1: Cache Simulation
This is a warm-up problem: find the cache simulator and benchmarks. To make the exercise concrete, pick one benchmark and simulate it with a range of cache sizes. The results should reveal the “characteristic” of this application with respect to the cache.
I’ve provided the simulator sim-cache, for Sun SPARC-based machines only. The source is available, though, if you want to compile it for other platforms.
Machines
Use the Sun Ultra 10 workstations in the CoC “cities” cluster. The benchmarks are sized to require about 10 minutes of CPU time on these machines for one run with a cache.
Please observe the following policy when using machines remotely:
Simulator Executable
The simulator is called “sim-cache”. To prepare to run the simulator, set your path as follows (on an Ultra running Solaris):
set path = ($path /users/projects/class/6290/spring03/bin/sol8)
sim-cache -cache:dl1 dl1:256:16:1:l -cache:il1 il1:256:16:1:l -cache:il2 none -cache:dl2 none sor.ss 128 128 500 [...] sim: ** simulation statistics ** sim_num_insn 6174345 # total number of instructions executed sim_num_refs 2550233 # total number of loads and stores executed sim_elapsed_time 16 # total simulation time in seconds sim_inst_rate 385896.5625 # simulation speed (in insts/sec) il1.accesses 6174345 # total number of accesses il1.hits 6171832 # total number of hits il1.misses 2513 # total number of misses il1.replacements 2257 # total number of replacements il1.writebacks 0 # total number of writebacks il1.invalidations 0 # total number of invalidations il1.miss_rate 0.0004 # miss rate (i.e., misses/ref) il1.repl_rate 0.0004 # replacement rate (i.e., repls/ref) il1.wb_rate 0.0000 # writeback rate (i.e., wrbks/ref) il1.inv_rate 0.0000 # invalidation rate (i.e., invs/ref) dl1.accesses 3043803 # total number of accesses dl1.hits 2936830 # total number of hits dl1.misses 106973 # total number of misses dl1.replacements 106717 # total number of replacements dl1.writebacks 89924 # total number of writebacks dl1.invalidations 0 # total number of invalidations dl1.miss_rate 0.0351 # miss rate (i.e., misses/ref) dl1.repl_rate 0.0351 # replacement rate (i.e., repls/ref) dl1.wb_rate 0.0295 # writeback rate (i.e., wrbks/ref) dl1.inv_rate 0.0000 # invalidation rate (i.e., invs/ref) [...]
B: Find the miss rates for a range of cache sizes using your bench- mark. Use separate I and D caches (to keep the effects separate) and a 16-byte block size. In the spirit of striving to avoid work better performed by a machine, here’s an example of a shell script for test- ing a range of cache designs.
#!/bin/csh
foreach rows (8 16 32 64 128 256 512 1024 2048 4096 8192 16384) @ nbytes = $rows * 16 echo "$nbytes-bytes:" sim-cache -cache:dl1 ’dl1:’$rows’:16:1:l’ -cache:il1 ’il1:’$rows’:16:1:l’ -cache:il2 none -cache:dl2 none sor.ss 128 128 500 |& fgrep ’1.miss_rate’ end
Note the use of the fgrep command to select only the L1 “miss rate” lines out of the output.
C: Plot the results obtained above for your selected benchmark. Plot percent misses versus cache size on a semi-log plot.
D: What can you deduce about the memory needs of the appli- cation from the plot? E.g. how big is the “hot” part (the “working- set”) of instructions? of data? Is there more than one working-set size?
Different benchmarks will obviously lead to different results. We’ll try to compare results for all three benchmarks in class at some point.
Memory array
Row decoder
Sense amplifiers
Column multiplexor
Data in/out
Address in
A row or "wordline"
A column or "bitline"
One bit cell at intersection
Figure 1: Usual design for a memory. The memory is laid out as a 2D array, as nearly square as possible. A particular bit is addressed by driving the appropriate row and then driving or sampling the appropriate column.
To explain the time and space models, here’s a quick review of how to build a memory array.
Figure 1 depicts a typical memory array. The bits are laid out in a 2D matrix. To address a particular bit you must identify the corresponding row and column. The address is thus split into a part used to decide which row to drive and a part used to decide with column to sample (for a read) or drive (for a write). N -way set associate caches (for small N ) look much the same – the multiplexors between banks can be imagined to be part of the column multiplexor shown in the figure.
B: SPACE MODEL In order to meet the space constraint, you need to know how much space a proposed design occupies. The space occupied by a direct-mapped or N -way-associative-with-small- N cache is dominated by the array of bit cells in its memory, so we’ll adopt a simple model: count only the space occupied by the transis- tors used for memory bits. A standard SRAM cell (appropriate for a cache) requires six transistors. The space model is then: i. Limit associtivity to 1 < N < 8-way. ii. Count all the memory bits required, including data, tags, valid bit, dirty bit if any, LRU state if any. Call the total Nbits. iii. Ntransistors = Nbits · 6
The total number of transistors, Ntransistors, estimated for your de- sign using this model must fit within the budget of 10,000,000 tran- sistors.
C: HIT TIME MODEL Similarly, in order to know the number of clock cycles your cache(s) require, you need to be able to estimate the delay through a cache. The largest component of delay through a memory is generally the time required to charge the (long) row and column wires. The time is proportional to the length of the wires. We’ll adopt a timing model that uses this length as the basic delay estimate and then add a penalty for associativity as suggested by the text. The timing model is then (for each individual cache):
i. Estimate the base time as Tarray = 2 ·
Nbits · 2pS, where Nbits is the total number of bits in the memory array as estimated earlier and 2pS/wire is a wild guess. Note, pS is picoseconds – 10−^12 seconds. ii.a. If the cache is direct, Tcache = Tarray. ii.b. Otherwise, Tcache = T array · (1.10 + 0. 02 · (dlog 2 (N )e − 1)) for N -way associativity. i.e., 10% for the first multiplexor plus 2% for each additional multiplexor. iii. All accesses require integral numbers of clock cycles, so be sure to round Tcache up to the next multiple of 1nS.
There are no restrictions per se on the number of clocks required to access a cache; the number just contributes to Thit for that level of the cache. However, my bet is that the lowest AMAT will be achieved with a single-cycle L1 cache.
D: MISS PENALTY TIME MODEL Finally, the miss penalty for each cache must account for all three components of miss time: bus busy time, access time and transfer time.
i. The access time is the time to get the first block from the next lower level of memory. For the lowest level of cache, this time is 200 cycles (200nS) by definition for the first 16 bytes. ii. The transfer time is the time to fetch subsequent blocks if necessary. From main memory, subsequent blocks require 20 cycles (20ns) each by definition. iii. Bus busy time is the time the bus the occupied with other work before an access can begin. Not all designs will have a bus busy time and designs that do will be scrutinized closely. Bus busy can only arise if there can
tag 20b
data 128b
V 1b
tag 20b
data 128b
V 1b
256 rows
LRU 1b
32 bit address: tag^ index^ blk
20 bits 8 bits 4b
Figure 2: Logical organization of an example cache: 8KB total, two-way set associative with 16-byte blocks. The write policy is write-through, so no dirty bit is needed. The replacement policy is LRU, so 1 bit per row is required to remember which block in each row is the oldest.
F: EXAMPLE Here’s an example: take a cache that is 8KB total size, two-way set associative, with 16-byte blocks, LRU replace- ment policy and a write-through write policy. The logical organiza- tion is illustrated in Figure 2. i. Nbits = 256 · (2 · (1 + 20 + 128) + 1) = 76544 ii. Ntransistors = 6 · 76544 = 459264 iii. Tcache = 1. 10 ·
Nbits · 4pS = 1.2nS, which is then rounded up to 2nS (2 clocks).
If this were the only cache in the system, the equation for AMAT would be AMAT = Thit + (1 − h) · Tmiss = 2 + (1 − h) · 100nS or = 2 + (1 − h) · 100 clock cycles.
where the miss rate, (1 − h), has to be determined by simulation. Note that since the cache is write-through and there is no write buffer, all writes must be treated as misses.
Problem 3: Cache Design and Writeup
A: Go design some caches!
Limit yourself to what you can simulate with sim-cache (see the [Burger97] document on the web page). For instance, sim-cache doesn’t model victim caches (unless you feel like extending it...). Happily, all these dimensions are available:
i. Blocksize. ii. Write policy. iii. Associativity (1-way to 8-way). iv. Replacement policy. v. Single and two-level caches (I can’t imagine more than two levels being profitable). vi. Split instruction and data (I&D) caches versus a unified.
I’d start by doing some arithmetic to feel out the limits for what will fit, then simulating a few points with one of the benchmarks to get a feel for what is sane. Finally, when you’ve narrowed the space down to just a few candidates, set up some simulations to do the final tuning.
B: Write up your design in the form of a lab report. The writeup should address at least the following points: i. Describe the final design, draw its logical structure and label all the components. ii. Give the sim-cache command line you use. iii. Give the cost in space and time of each cache and each miss penalty according to the models. iv. Give the AMAT equation for your hardware. Note that it is a good practice to compute your AMAT by dividing the total using the total counts of events and instructions reported by the simulator rather than using the ratios reported by the simulator. v. List any other assumptions you had to make. vi. Explain how you narrowed the design space, describe your experiments and present the data you used to justify the final design. vii. Explain any parameters or other ambiguities you couldn’t pin down (e.g., because pinning them down would have required prohibitive simulation time).
Finally,
viii. How (where) would you add a victim cache? Would you expect much benefit?